summaryrefslogtreecommitdiff
path: root/portato/backend/package.py
diff options
context:
space:
mode:
Diffstat (limited to 'portato/backend/package.py')
-rw-r--r--portato/backend/package.py49
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 ...
2006-10-05Added first support for the masking stuff ... and hoping that it is going to ...necoro5-79/+135 2006-10-05Changed changelog / added config-filenecoro2-0/+10 2006-10-05Added preference windownecoro4-49/+155 2006-10-02Corrected comments, structure, bad algorithms etcnecoro4-176/+209 2006-10-02Corrected indention in commentnecoro1-8/+6 2006-10-010.3.3necoro1-0/+6 2006-10-01Implemented an internal db; removed unmerge-bugnecoro2-26/+43 2006-09-30Implemented some new backend functions which speed up the package-list-creati...necoro2-12/+37 2006-09-300.3.2 release; changed font in terminal; added new "masking"-dialognecoro3-11/+36 2006-09-29fixed bugsnecoro4-13/+23 2006-09-29Corrected setup.pynecoro1-1/+1