diff options
author | René 'Necoro' Neumann <necoro@necoro.net> | 2008-03-04 17:23:27 +0100 |
---|---|---|
committer | René 'Necoro' Neumann <necoro@necoro.net> | 2008-03-04 17:23:27 +0100 |
commit | 77439eb1d03d58f1bfc6fc4c0ac63717c4ede39b (patch) | |
tree | 4f8024789cdcbc03956790f09cf3ded835c35bb3 /portato/backend | |
parent | e56f12cbaa9c0d8e88696ce2e32b76dd525fdb6d (diff) | |
download | portato-77439eb1d03d58f1bfc6fc4c0ac63717c4ede39b.tar.gz portato-77439eb1d03d58f1bfc6fc4c0ac63717c4ede39b.tar.bz2 portato-77439eb1d03d58f1bfc6fc4c0ac63717c4ede39b.zip |
First get_dependencies support
Diffstat (limited to '')
-rw-r--r-- | portato/backend/portage/package.py | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/portato/backend/portage/package.py b/portato/backend/portage/package.py index 647dd74..6ac34ba 100644 --- a/portato/backend/portage/package.py +++ b/portato/backend/portage/package.py @@ -301,3 +301,37 @@ class PortagePackage (Package): def matches (self, criterion): return system.cpv_matches(self.get_cpv(), criterion) + + def get_dependencies (self): + deps = " ".join(map(self.get_package_settings, ("RDEPEND", "PDEPEND", "DEPEND"))) + deps = portage_dep.paren_reduce(deps) + depdir = {"global": set()} + + def add (dir, deps): + iter = (x for x in deps) + for dep in iter: + if dep.endswith("?"): + dep = dep[:-1] + if dep not in dir: + dir[dep] = {"global": set()} + n = iter.next() + if isinstance(n, list): + add(dir[dep], n) + else: + dir[dep]["global"].add(n) + elif dep == "||": + if not dep in dir: + dir[dep] = set() + + n = iter.next() # skip + if not isinstance(n, list): + n = tuple(n,) + else: + n = tuple(n) + + dir[dep].add(n) + else: + dir["global"].add(dep) + + add(depdir, deps) + return depdir |