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 /pym/portage/xml/metadata.py | |
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.
Diffstat (limited to 'pym/portage/xml/metadata.py')
-rw-r--r-- | pym/portage/xml/metadata.py | 21 |
1 files changed, 13 insertions, 8 deletions
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 |