Prepare further checks on metadata.xml
authorSebastian Pipping <sebastian@pipping.org>
Fri, 26 Feb 2010 21:10:43 +0000 (22:10 +0100)
committerZac Medico <zmedico@gmail.com>
Wed, 24 Mar 2010 01:44:13 +0000 (18:44 -0700)
bin/repoman
pym/repoman/utilities.py

index c96b18408560be9e7ecca250fb125667c84426ee..61a2c335917443eef23de213d26ff301cdad3bd7 100755 (executable)
@@ -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:
index 8a2c0f0c63f4b954d766827ece2e73845228bf1a..d30552ed485a723df9d26b8335a344d2a8b87488 100644 (file)
@@ -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,))