summaryrefslogtreecommitdiff
path: root/portato/dependency.py
diff options
context:
space:
mode:
authorRené 'Necoro' Neumann <necoro@necoro.net>2008-03-05 14:45:56 +0100
committerRené 'Necoro' Neumann <necoro@necoro.net>2008-03-05 14:45:56 +0100
commit782f83257a0dbe85511199c6a5628be34c4fb553 (patch)
tree4c3c0bc934af7eab4a7a45608be2d1d409a33593 /portato/dependency.py
parent3bb7552e35c43d2475e0016bb4c6d3e69f2a39c9 (diff)
downloadportato-782f83257a0dbe85511199c6a5628be34c4fb553.tar.gz
portato-782f83257a0dbe85511199c6a5628be34c4fb553.tar.bz2
portato-782f83257a0dbe85511199c6a5628be34c4fb553.zip
Added dependency list
Diffstat (limited to 'portato/dependency.py')
-rw-r--r--portato/dependency.py24
1 files changed, 18 insertions, 6 deletions
diff --git a/portato/dependency.py b/portato/dependency.py
index 91e4fb5..a52a630 100644
--- a/portato/dependency.py
+++ b/portato/dependency.py
@@ -19,6 +19,7 @@ __docformat__ = "restructuredtext"
from .helper import debug
+from .backend import system
class Dependency (object):
@@ -29,6 +30,9 @@ class Dependency (object):
dep : string
The dependency string. It is immutable.
+
+ satisfied : boolean
+ Is this dependency satisfied?
"""
def __init__ (self, dep):
@@ -38,7 +42,15 @@ class Dependency (object):
:param dep: dependency string
:type dep: string
"""
- self.__dep = dep
+ self._dep = dep
+
+ def is_satisfied (self):
+ """
+ Checks if this dependency is satisfied.
+
+ :rtype: boolean
+ """
+ return system.find_best_match(self.dep, only_cpv = True, only_installed = True) is not None
def __cmp__ (self, b):
return cmp(self.dep, b.dep)
@@ -51,13 +63,13 @@ class Dependency (object):
__repr__ = __str__
- def __get_dep (self):
- return self.__dep
+ def _get_dep (self):
+ return self._dep
- dep = property(__get_dep)
+ dep = property(_get_dep)
+ satisfied = property(is_satisfied)
class OrDependency (Dependency):
-
"""
Dependency representing an "or".
@@ -77,7 +89,7 @@ class OrDependency (Dependency):
:type deps: iter<string>
"""
- self.__dep = tuple(Dependency(dep) for dep in deps)
+ self._dep = tuple(Dependency(dep) for dep in deps)
def __str__ (self):
return "<|| %s>" % str(self.dep)