summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--portato/backend/package.py5
-rw-r--r--portato/dependency.py39
-rw-r--r--portato/gui/windows/main.py7
3 files changed, 45 insertions, 6 deletions
diff --git a/portato/backend/package.py b/portato/backend/package.py
index 4d3803f..78a4b1f 100644
--- a/portato/backend/package.py
+++ b/portato/backend/package.py
@@ -177,6 +177,7 @@ class Package (_Package):
"""
deps = " ".join(map(self.get_package_settings, ("RDEPEND", "PDEPEND", "DEPEND")))
deps = paren_reduce(deps)
+ debug("Dependencies: %s", deps)
tree = DependencyTree()
@@ -193,9 +194,9 @@ class Package (_Package):
elif dep == "||":
n = iter.next() # skip
if not hasattr(n, "__iter__"):
- n = tuple(n,)
+ n = [n]
else:
- n = tuple(n)
+ n = list(n)
tree.add_or(n)
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):
"""
diff --git a/portato/gui/windows/main.py b/portato/gui/windows/main.py
index 1e28a3c..4405512 100644
--- a/portato/gui/windows/main.py
+++ b/portato/gui/windows/main.py
@@ -256,7 +256,12 @@ class PackageTable:
orit = store.append(it, [self.icons["or"], _("One of the following")])
for dep in ordep.dep:
- store.append(orit, [get_icon(dep), dep.dep])
+ if isinstance(dep, dependency.AllOfDependency): # a list inside or
+ allit = store.append(orit, [None, _("All of the following")])
+ for adep in dep.dep:
+ store.append(allit, [get_icon(adep), adep.dep])
+ else:
+ store.append(orit, [get_icon(dep), dep.dep])
# normal
def sort_key (x):