summaryrefslogtreecommitdiff
path: root/portato/dependency.py
diff options
context:
space:
mode:
authorRené 'Necoro' Neumann <necoro@necoro.net>2008-03-27 08:50:37 +0100
committerRené 'Necoro' Neumann <necoro@necoro.net>2008-03-27 08:50:37 +0100
commit5c7f8b376200e0a08ba298fa3faacacc97825a64 (patch)
tree06284e411b7359eb792ed4fcdd334d6ebedb9ee7 /portato/dependency.py
parentcc1340671b0c719e0393cdeae5f1813635b19aa0 (diff)
downloadportato-5c7f8b376200e0a08ba298fa3faacacc97825a64.tar.gz
portato-5c7f8b376200e0a08ba298fa3faacacc97825a64.tar.bz2
portato-5c7f8b376200e0a08ba298fa3faacacc97825a64.zip
Allowed AllOf-deps inside or
Diffstat (limited to 'portato/dependency.py')
-rw-r--r--portato/dependency.py39
1 files changed, 36 insertions, 3 deletions
diff --git a/portato/dependency.py b/portato/dependency.py
index a52a630..cefc6ad 100644
--- a/portato/dependency.py
+++ b/portato/dependency.py
@@ -77,8 +77,8 @@ class OrDependency (Dependency):
:IVariables:
- dep : tuple(string,...)
- The dependency strings. The tuple and the strings are immutable.
+ dep : tuple(`Dependency`,...)
+ The dependencies. The tuple and the dependencies are immutable.
"""
def __init__ (self, deps):
@@ -89,13 +89,46 @@ class OrDependency (Dependency):
:type deps: iter<string>
"""
- self._dep = tuple(Dependency(dep) for dep in deps)
+ _dep = []
+ for dep in deps:
+ if not hasattr(dep, "__iter__"):
+ _dep.append(Dependency(dep))
+ else:
+ _dep.append(AllOfDependency(dep))
+
+ self._dep = tuple(_dep)
def __str__ (self):
return "<|| %s>" % str(self.dep)
__repr__ = __str__
+class AllOfDependency (Dependency):
+ """
+ Dependency representing a set of packages inside "or".
+ If the or is: ``|| (a ( b c ) )`` the `AllOfDependency` would be the ``( b c )``.
+
+ :IVariables:
+
+ dep : tuple(`Dependency`,...)
+ The dependencies . The tuple and the deps are immutable.
+ """
+
+ def __init__ (self, deps):
+ """
+ Creates an or-dependency out of a list (or tuple) of deps.
+
+ :param deps: The dependencies.
+ :type deps: iter<string>
+ """
+
+ self._dep = tuple(Dependency(dep) for dep in deps)
+
+ def __str__ (self):
+ return "<ALL %s>" % str(self.dep)
+
+ __repr__ = __str__
+
class DependencyTree (object):
"""