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:
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,))