summaryrefslogtreecommitdiffstats
path: root/pym/repoman/utilities.py
diff options
context:
space:
mode:
authorMichał Górny <gentoo@mgorny.alt.pl>2010-08-26 18:51:14 +0200
committerZac Medico <zmedico@gentoo.org>2010-08-26 10:17:32 -0700
commitda50b12d4c6eeca8dda1f97e49163c611c2b78b2 (patch)
treeea249786fb5f1aff4f66faf71e737397f2ebb342 /pym/repoman/utilities.py
parentebfcfc636536a3d6fcaa0c0d8de27cac391b5b3c (diff)
downloadportage-da50b12d4c6eeca8dda1f97e49163c611c2b78b2.tar.gz
portage-da50b12d4c6eeca8dda1f97e49163c611c2b78b2.tar.bz2
portage-da50b12d4c6eeca8dda1f97e49163c611c2b78b2.zip
Parse flag descriptions in repoman.utilities.parse_metadata_use().
Grab the USE descriptions from metadata.xml within parse_metadata_use(). Instead of a plain flag list, return a dict containing both the flag names and their descriptions.
Diffstat (limited to 'pym/repoman/utilities.py')
-rw-r--r--pym/repoman/utilities.py17
1 files changed, 12 insertions, 5 deletions
diff --git a/pym/repoman/utilities.py b/pym/repoman/utilities.py
index 9dd5cde35..ed0de4449 100644
--- a/pym/repoman/utilities.py
+++ b/pym/repoman/utilities.py
@@ -23,6 +23,7 @@ __all__ = [
import codecs
import errno
import logging
+import re
import sys
from portage import os
from portage import subprocess_getstatusoutput
@@ -110,12 +111,15 @@ def have_profile_dir(path, maxdepth=3, filename="profiles.desc"):
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:
@@ -127,9 +131,12 @@ def parse_metadata_use(xml_tree, uselist=None):
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):