From 1112bbcd7f74e8fc507d0057fb153c9bbed8fc50 Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Thu, 26 Aug 2010 13:29:13 -0700 Subject: Make parse_metadata_use() emulate the Element.itertext() method from python-2.7, so egencache --update-use-local-desc gets all of the inner text. --- pym/repoman/utilities.py | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) (limited to 'pym/repoman') diff --git a/pym/repoman/utilities.py b/pym/repoman/utilities.py index b2d17fc9a..6dbdeddcd 100644 --- a/pym/repoman/utilities.py +++ b/pym/repoman/utilities.py @@ -38,6 +38,8 @@ from portage import util normalize_path = util.normalize_path util.initialize_logger() +if sys.hexversion >= 0x3000000: + basestring = str def detect_vcs_conflicts(options, vcs): """Determine if the checkout has problems like cvs conflicts. @@ -111,8 +113,6 @@ def have_profile_dir(path, maxdepth=3, filename="profiles.desc"): path = normalize_path(path + "/..") maxdepth -= 1 -whitespace_re = re.compile('\s+') - def parse_metadata_use(xml_tree): """ Records are wrapped in XML as per GLEP 56 @@ -136,7 +136,23 @@ def parse_metadata_use(xml_tree): if flag.text is None: raise exception.ParseError("missing USE description with " + \ "the 'flag' tag (name=%s)" % pkg_flag) - pkg_flag_value = whitespace_re.sub(' ', flag.text).strip() + + # emulate the Element.itertext() method from python-2.7 + inner_text = [] + stack = [] + stack.append(flag) + while stack: + obj = stack.pop() + if isinstance(obj, basestring): + inner_text.append(obj) + continue + if isinstance(obj.text, basestring): + inner_text.append(obj.text) + if isinstance(obj.tail, basestring): + stack.append(obj.tail) + stack.extend(reversed(obj)) + + pkg_flag_value = " ".join("".join(inner_text).split()) if not pkg_flag_value: raise exception.ParseError("missing USE description with " + \ "the 'flag' tag (name=%s)" % pkg_flag) -- cgit v1.2.3-1-g7c22