hints: allow more properties to be used for filtering the hint list

Signed-off-by: Adam D. Barratt <adam@adam-barratt.org.uk>
debian
Adam D. Barratt 14 years ago
parent 5a7a0cbe0a
commit 7700e229cd

@ -18,14 +18,19 @@ class HintCollection:
def __init__(self):
self._hints = []
def __getitem__(self, type=None, onlyactive=True):
return self.hints(type, onlyactive)
def hints(self, type=None, onlyactive=True):
if type:
return [ hint for hint in self._hints if hint.type == type and (hint.active or onlyactive)]
else:
return self._hints[:]
def __getitem__(self, type=None):
return self.hints(type)
def hints(self, type=None, onlyactive=True, package=None, \
version=None, days=None, removal=None):
return [ hint for hint in self._hints if
(type is None or type == hint.type) and
(onlyactive or hint.active) and
(package is None or package == hint.packages[0].package) and
(version is None or version == hint.packages[0].version) and
(removal is None or removal == hint.packages[0].is_removal)
]
def add_hint(self, hint, user):
self._hints.append(Hint(hint, user))

Loading…
Cancel
Save