From: Sebastian Pipping Date: Fri, 26 Feb 2010 21:10:43 +0000 (+0100) Subject: Prepare further checks on metadata.xml X-Git-Tag: v2.2_rc68~700 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=4866b8f1bc4cc4c089916ea5cd4b6d44691e8c6c;p=portage.git Prepare further checks on metadata.xml --- diff --git a/bin/repoman b/bin/repoman index c96b18408..61a2c3359 100755 --- a/bin/repoman +++ b/bin/repoman @@ -1296,16 +1296,25 @@ for x in scanlist: else: metadata_bad = False - # load USE flags from metadata.xml + # read metadata.xml into memory try: f = open(os.path.join(checkdir, "metadata.xml")) - utilities.parse_metadata_use(f, muselist) + _metadata_xml = f.read() f.close() - except (EnvironmentError, ParseError) as e: + except (EnvironmentError, ) as e: metadata_bad = True stats["metadata.bad"] += 1 fails["metadata.bad"].append("%s/metadata.xml: %s" % (x, e)) del e + else: + # load USE flags from metadata.xml + try: + utilities.parse_metadata_use(_metadata_xml, muselist) + except (EnvironmentError, ParseError) as e: + metadata_bad = True + stats["metadata.bad"] += 1 + fails["metadata.bad"].append("%s/metadata.xml: %s" % (x, e)) + del e #Only carry out if in package directory or check forced if xmllint_capable and not metadata_bad: diff --git a/pym/repoman/utilities.py b/pym/repoman/utilities.py index 8a2c0f0c6..d30552ed4 100644 --- a/pym/repoman/utilities.py +++ b/pym/repoman/utilities.py @@ -112,14 +112,14 @@ def have_profile_dir(path, maxdepth=3, filename="profiles.desc"): path = normalize_path(path + "/..") maxdepth -= 1 -def parse_metadata_use(mylines, uselist=None): +def parse_metadata_use(metadata_xml_content, uselist=None): """ Records are wrapped in XML as per GLEP 56 returns a dict of the form a list of flags""" if uselist is None: uselist = [] try: - metadatadom = minidom.parse(mylines) + metadatadom = minidom.parseString(metadata_xml_content) except ExpatError as e: raise exception.ParseError("metadata.xml: %s" % (e,))