fails["changelog.missing"].append(x+"/ChangeLog")
#metadata.xml file check
- muselist = []
-
if "metadata.xml" not in checkdirlist:
stats["metadata.missing"]+=1
fails["metadata.missing"].append(x+"/metadata.xml")
else:
# load USE flags from metadata.xml
try:
- utilities.parse_metadata_use(_metadata_xml, muselist)
+ musedict = utilities.parse_metadata_use(_metadata_xml)
except portage.exception.ParseError as e:
metadata_bad = True
stats["metadata.bad"] += 1
fails["metadata.bad"].append("%s/metadata.xml: %s" % (x, e))
- muselist = []
+ musedict = {}
# Run other metadata.xml checkers
try:
fails["metadata.bad"].append(x+"/metadata.xml")
del metadata_bad
- muselist = frozenset(muselist)
+ muselist = frozenset(musedict.keys())
changelog_path = os.path.join(checkdir_relative, "ChangeLog")
changelog_modified = changelog_path in modified_changelogs
import codecs
import errno
import logging
+import re
import sys
from portage import os
from portage import subprocess_getstatusoutput
path = normalize_path(path + "/..")
maxdepth -= 1
-def parse_metadata_use(xml_tree, uselist=None):
+whitespace_re = re.compile('\s+')
+
+def parse_metadata_use(xml_tree):
"""
Records are wrapped in XML as per GLEP 56
- returns a dict of the form a list of flags"""
- if uselist is None:
- uselist = []
+ returns a dict with keys constisting of USE flag names and values
+ containing their respective descriptions
+ """
+ uselist = {}
usetag = xml_tree.findall("use")
if not usetag:
for flag in flags:
pkg_flag = flag.get("name")
+ pkg_flag_value = whitespace_re.sub(' ', flag.text).strip()
if pkg_flag is None:
raise exception.ParseError("missing 'name' attribute for 'flag' tag")
- uselist.append(pkg_flag)
+ if not pkg_flag_value:
+ raise exception.ParseError("missing USE description with the 'flag' tag")
+ uselist[pkg_flag] = pkg_flag_value
return uselist
class UnknownHerdsError(ValueError):