summaryrefslogtreecommitdiff
path: root/portato/backend
diff options
context:
space:
mode:
authorRené 'Necoro' Neumann <necoro@necoro.net>2008-03-12 09:24:06 +0100
committerRené 'Necoro' Neumann <necoro@necoro.net>2008-03-12 09:24:06 +0100
commit6ac3ab0f0e625e8cad02ab6291635e6f2180fe50 (patch)
treec187c7a738fdac6ae2f30841c0c1175cb991ccae /portato/backend
parentce3998575855189e4fb87a8c9777397fac1ffa23 (diff)
downloadportato-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/catapult/package.py7
-rw-r--r--portato/backend/package.py49
-rw-r--r--portato/backend/portage/package.py34
3 files changed, 40 insertions, 50 deletions
diff --git a/portato/backend/catapult/package.py b/portato/backend/catapult/package.py
index 5ab8743..e2dd54e 100644
--- a/portato/backend/catapult/package.py
+++ b/portato/backend/catapult/package.py
@@ -147,12 +147,6 @@ class CatapultPackage(Package):
def get_files (self):
return self.proxy.get_files(self.get_cpv())
- def get_dependencies (self):
- from ...dependency import DependencyTree
- d = DependencyTree()
- d.add("Dependency calculation not supported for Catapult Backend")
- return d
-
def get_name(self):
return str(self.proxy.get_name(self.get_cpv()))
@@ -161,4 +155,3 @@ class CatapultPackage(Package):
def get_category(self):
return str(self.proxy.get_category(self.get_cpv()))
-
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 ...
diff --git a/portato/backend/portage/package.py b/portato/backend/portage/package.py
index 16f00a4..767df5b 100644
--- a/portato/backend/portage/package.py
+++ b/portato/backend/portage/package.py
@@ -17,7 +17,6 @@ from .. import flags
from .. import system
from ..exceptions import BlockedException, PackageNotFoundException, DependencyCalcError
from ...helper import debug, error, unique_array
-from ...dependency import DependencyTree
import portage, portage_dep
@@ -318,35 +317,4 @@ class PortagePackage (Package):
return portage.pkgcmp(v1[1:],v2[1:])
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)
-
- 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
+ return system.cpv_matches(self.get_cpv(), criterion)