diff options
author | 2005-08-03 00:19:18 +0000 | |
---|---|---|
committer | 2005-08-03 00:19:18 +0000 | |
commit | db83844efaa65ccf38ed30216cdcb9f74d6ec06e (patch) | |
tree | 9f514c199b483cfc081bcfa5105dddc64172c8de | |
parent | bit 'o' cleanup. added cleanse_keys class attribute, serves as an indication... (diff) | |
download | portage-cvs-db83844efaa65ccf38ed30216cdcb9f74d6ec06e.tar.gz portage-cvs-db83844efaa65ccf38ed30216cdcb9f74d6ec06e.tar.bz2 portage-cvs-db83844efaa65ccf38ed30216cdcb9f74d6ec06e.zip |
reworked the visibility filter, now it accepts only one instance of a restriction derivative.
Why? Cause that way you can control if it's and, or, xor, etc, or if just a simple check. Previously it enforced or (effectively)
-rw-r--r-- | portage/repository/visibility.py | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/portage/repository/visibility.py b/portage/repository/visibility.py index 6fd3368..37876d4 100644 --- a/portage/repository/visibility.py +++ b/portage/repository/visibility.py @@ -1,31 +1,27 @@ # Copyright: 2005 Gentoo Foundation # Author(s): Brian Harring (ferringb@gentoo.org) # License: GPL2 -# $Header: /local/data/ulm/cvs/history/var/cvsroot/gentoo-src/portage/portage/repository/visibility.py,v 1.5 2005/07/27 02:32:18 ferringb Exp $ +# $Header: /local/data/ulm/cvs/history/var/cvsroot/gentoo-src/portage/portage/repository/visibility.py,v 1.6 2005/08/03 00:19:18 ferringb Exp $ # icky. # ~harring import prototype, errors +from portage.restrictions.restriction import base class filterTree(prototype.tree): """wrap an existing repository filtering results based upon passed in restrictions.""" - def __init__(self, repo, restrictions, sentinel_val=False): + def __init__(self, repo, restriction, sentinel_val=False): self.raw_repo = repo self.sentinel_val = sentinel_val if not isinstance(self.raw_repo, prototype.tree): raise errors.InitializationError("%s is not a repository tree derivative" % str(self.raw_repo)) - if not isinstance(restrictions, list): - restrictions = [restrictions] - self._restrictions = restrictions + if not isinstance(restriction, base): + raise errors.InitializationError("%s is not a restriction" % str(restriction)) + self.restriction = restriction def itermatch(self, atom): for cpv in self.raw_repo.itermatch(atom): - ret = True - for r in self._restrictions: - if r.match(cpv) == self.sentinel_val: - ret = False - break - if ret: + if self.restriction.match(cpv) == self.sentinel_val: yield cpv |