From 8c8e0b3f6a1cc39b9761f8e0947aa8630400986c Mon Sep 17 00:00:00 2001 From: fuzzyray Date: Wed, 1 Mar 2006 18:01:41 +0000 Subject: [PATCH] Fixes for dependency parsing (bug 123725). Added function to get PDEPENDS svn path=/; revision=282 --- trunk/src/gentoolkit/package.py | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) 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: -- 2.26.2