diff options
author | Zac Medico <zmedico@gentoo.org> | 2010-09-06 15:11:42 -0700 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2010-09-06 15:11:42 -0700 |
commit | d67b2f75cd77984282e6e8d454c98e015619d125 (patch) | |
tree | 1564a4abae0201325b37871b95fbc7655a5f89b5 | |
parent | 84238b2d0912c68cc679d11ec1240140bb314da1 (diff) | |
download | portage-d67b2f75cd77984282e6e8d454c98e015619d125.tar.gz portage-d67b2f75cd77984282e6e8d454c98e015619d125.tar.bz2 portage-d67b2f75cd77984282e6e8d454c98e015619d125.zip |
Replace the settings and herdstree parameters for the MetaDataXML
constructor with a single herds parameter that can be either a
path to a herds.xml, or a pre-parsed ElementTree.
-rw-r--r-- | pym/_emerge/EbuildPhase.py | 4 | ||||
-rw-r--r-- | pym/portage/xml/metadata.py | 21 |
2 files changed, 16 insertions, 9 deletions
diff --git a/pym/_emerge/EbuildPhase.py b/pym/_emerge/EbuildPhase.py index 75dd123ff..117471335 100644 --- a/pym/_emerge/EbuildPhase.py +++ b/pym/_emerge/EbuildPhase.py @@ -39,8 +39,10 @@ class EbuildPhase(CompositeTask): maint_str = "" metadata_xml_path = os.path.join(os.path.dirname(self.settings['EBUILD']), "metadata.xml") if os.path.isfile(metadata_xml_path): + herds_path = os.path.join(self.settings['PORTDIR'], + 'metadata/herds.xml') try: - metadata_xml = MetaDataXML(metadata_xml_path, self.settings) + metadata_xml = MetaDataXML(metadata_xml_path, herds_path) maint_str = metadata_xml.format_maintainer_string() except SyntaxError: maint_str = "<invalid metadata.xml>" diff --git a/pym/portage/xml/metadata.py b/pym/portage/xml/metadata.py index ca523e4f1..0515c6929 100644 --- a/pym/portage/xml/metadata.py +++ b/pym/portage/xml/metadata.py @@ -159,28 +159,34 @@ class _Upstream(object): class MetaDataXML(object): """Access metadata.xml""" - def __init__(self, metadata_xml_path, settings=None, herdstree=None): + def __init__(self, metadata_xml_path, herds): """Parse a valid metadata.xml file. @type metadata_xml_path: str @param metadata_xml_path: path to a valid metadata.xml file + @type herds: str or ElementTree + @param herds: path to a herds.xml, or a pre-parsed ElementTree @raise IOError: if C{metadata_xml_path} can not be read """ self.metadata_xml_path = metadata_xml_path - self.settings = settings self._xml_tree = None - if self.settings is None: - self.settings = portage.settings - try: self._xml_tree = etree.parse(metadata_xml_path) except ImportError: pass + if isinstance(herds, etree.ElementTree): + herds_etree = herds + herds_path = None + else: + herds_etree = None + herds_path = herds + # Used for caching - self._herdstree = herdstree + self._herdstree = herds_etree + self._herds_path = herds_path self._descriptions = None self._maintainers = None self._herds = None @@ -201,9 +207,8 @@ class MetaDataXML(object): """ if self._herdstree is None: - herds_path = os.path.join(self.settings['PORTDIR'], 'metadata/herds.xml') try: - self._herdstree = etree.parse(herds_path) + self._herdstree = etree.parse(self._herds_path) except (ImportError, IOError, SyntaxError): return None |