diff options
author | René 'Necoro' Neumann <necoro@necoro.net> | 2008-03-12 09:24:06 +0100 |
---|---|---|
committer | René 'Necoro' Neumann <necoro@necoro.net> | 2008-03-12 09:24:06 +0100 |
commit | 6ac3ab0f0e625e8cad02ab6291635e6f2180fe50 (patch) | |
tree | c187c7a738fdac6ae2f30841c0c1175cb991ccae /portato/backend/package.py | |
parent | ce3998575855189e4fb87a8c9777397fac1ffa23 (diff) | |
download | portato-6ac3ab0f0e625e8cad02ab6291635e6f2180fe50.tar.gz portato-6ac3ab0f0e625e8cad02ab6291635e6f2180fe50.tar.bz2 portato-6ac3ab0f0e625e8cad02ab6291635e6f2180fe50.zip |
Moved get_dependencies to top package class
Diffstat (limited to '')
-rw-r--r-- | portato/backend/package.py | 49 |
1 files changed, 39 insertions, 10 deletions
diff --git a/portato/backend/package.py b/portato/backend/package.py index ab3f82a..4d3803f 100644 --- a/portato/backend/package.py +++ b/portato/backend/package.py @@ -12,7 +12,9 @@ from __future__ import absolute_import -from ..helper import debug +from ..helper import debug, paren_reduce +from ..dependency import DependencyTree + from . import _Package, system, flags class Package (_Package): @@ -167,6 +169,42 @@ class Package (_Package): import string return string.join(sp[:-1],"/") + def get_dependencies (self): + """ + Returns the tree of dependencies that this package needs. + + @rtype: L{DependencyTree} + """ + deps = " ".join(map(self.get_package_settings, ("RDEPEND", "PDEPEND", "DEPEND"))) + deps = paren_reduce(deps) + + tree = DependencyTree() + + def add (tree, deps): + iter = (x for x in deps) + for dep in iter: + if dep.endswith("?"): + ntree = tree.add_flag(dep[:-1]) + n = iter.next() + if not hasattr(n, "__iter__"): + n = (n,) + add(ntree, n) + + elif dep == "||": + n = iter.next() # skip + if not hasattr(n, "__iter__"): + n = tuple(n,) + else: + n = tuple(n) + + tree.add_or(n) + + else: + tree.add(dep) + + add(tree, deps) + return tree + # # Not implemented # @@ -328,15 +366,6 @@ class Package (_Package): raise NotImplementedError - def get_dependencies (self): - """ - Returns the tree of dependencies that this package needs. - - @rtype: L{DependencyTree} - """ - - raise NotImplementedError - def get_package_settings(self, var, tree = None): """Returns a package specific setting, such as DESCRIPTION, SRC_URI, IUSE ... |