From: fuzzyray Date: Wed, 1 Mar 2006 18:01:41 +0000 (-0000) Subject: Fixes for dependency parsing (bug 123725). Added function to get PDEPENDS X-Git-Tag: gentoolkit-0.2.4.3~231 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=8c8e0b3f6a1cc39b9761f8e0947aa8630400986c;p=gentoolkit.git Fixes for dependency parsing (bug 123725). Added function to get PDEPENDS svn path=/; revision=282 --- diff --git a/trunk/src/gentoolkit/package.py b/trunk/src/gentoolkit/package.py index e4c3463..1e5b6cb 100644 --- a/trunk/src/gentoolkit/package.py +++ b/trunk/src/gentoolkit/package.py @@ -63,7 +63,7 @@ class Package: raise "Not implemented yet!" def get_runtime_deps(self): - """Returns a linearised list of first-level compile time dependencies for this package, on + """Returns a linearised list of first-level run time dependencies for this package, on the form [(comparator, [use flags], cpv), ...]""" cd = self.get_env_var("RDEPEND").split() r,i = self._parse_deps(cd) @@ -76,6 +76,13 @@ class Package: r,i = self._parse_deps(rd) return r + def get_postmerge_deps(self): + """Returns a linearised list of first-level post merge dependencies for this package, on + the form [(comparator, [use flags], cpv), ...]""" + pd = self.get_env_var("PDEPEND").split() + r,i = self._parse_deps(pd) + return r + def _parse_deps(self,deps,curuse=[],level=0): # store (comparator, [use predicates], cpv) r = [] @@ -86,7 +93,7 @@ class Package: tok = deps[i] if tok == ')': return r,i - if tok[-1] == "?" or tok[0] == "!": + if tok[-1] == "?": tok = tok.replace("?","") sr,l = self._parse_deps(deps[i+2:],curuse=curuse+[tok],level=level+1) r += sr @@ -97,6 +104,16 @@ class Package: r += sr i += l + 3 continue + # conjunction, like in "|| ( ( foo bar ) baz )" => recurse + if tok == "(": + sr,l = self._parse_deps(deps[i+1:],curuse,level=level+1) + r += sr + i += l + 2 + continue + # pkg block "!foo/bar" => ignore it + if tok[0] == "!": + i += 1 + continue # pick out comparator, if any cmp = "" for c in comparators: