diff options
author | Zac Medico <zmedico@gentoo.org> | 2010-08-26 13:29:13 -0700 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2010-08-26 13:29:13 -0700 |
commit | 1112bbcd7f74e8fc507d0057fb153c9bbed8fc50 (patch) | |
tree | e07d5dc2ebae621e34595e668fb44bbb7746419e | |
parent | 5f17d938bdb21871fee46197439da0b1f8d54b7b (diff) | |
download | portage-1112bbcd7f74e8fc507d0057fb153c9bbed8fc50.tar.gz portage-1112bbcd7f74e8fc507d0057fb153c9bbed8fc50.tar.bz2 portage-1112bbcd7f74e8fc507d0057fb153c9bbed8fc50.zip |
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.
-rw-r--r-- | pym/repoman/utilities.py | 22 |
1 files changed, 19 insertions, 3 deletions
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) |