aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Harring <ferringb@gentoo.org>2005-07-27 02:32:18 +0000
committerBrian Harring <ferringb@gentoo.org>2005-07-27 02:32:18 +0000
commit15201ac745ef98bb31440f8d62d0070fbc8ed4fe (patch)
tree5f22efd41acbbba63a1e997b306909c53dcd8ba2
parentchanged the visibility masker so it's proper (diff)
downloadportage-cvs-15201ac745ef98bb31440f8d62d0070fbc8ed4fe.tar.gz
portage-cvs-15201ac745ef98bb31440f8d62d0070fbc8ed4fe.tar.bz2
portage-cvs-15201ac745ef98bb31440f8d62d0070fbc8ed4fe.zip
touched up prototype.itermatch so that it now supports full range of package restrictions (including description + regex searching).
visibility got cleaned up so sentinelval was correctly used
-rw-r--r--portage/repository/prototype.py41
-rw-r--r--portage/repository/visibility.py10
2 files changed, 30 insertions, 21 deletions
diff --git a/portage/repository/prototype.py b/portage/repository/prototype.py
index ee96483..002546b 100644
--- a/portage/repository/prototype.py
+++ b/portage/repository/prototype.py
@@ -1,10 +1,11 @@
# 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/prototype.py,v 1.2 2005/07/13 05:51:35 ferringb Exp $
+# $Header: /local/data/ulm/cvs/history/var/cvsroot/gentoo-src/portage/portage/repository/prototype.py,v 1.3 2005/07/27 02:32:18 ferringb Exp $
from portage.util.dicts import IndexableSequence
from weakref import proxy
+from portage.package.atom import atom
def ix_cat_callable(*cat):
return "/".join(cat)
@@ -61,30 +62,32 @@ class tree(object):
return list(self.itermatch(atom))
- def itermatch(self, atom):
- if atom.category == None:
- candidates = self.packages
- else:
- if atom.package == None:
- try: candidates = self.packages[atom.category]
- except KeyError:
- # just stop now. no category matches == no yielded cpvs.
- return
+ def itermatch(self, restrict):
+ if isinstance(restrict, atom):
+ if restrict.category == None:
+ candidates = self.packages
else:
- try:
- if atom.package not in self.packages[atom.category]:
- # no matches possible
+ if restrict.package == None:
+ try: candidates = self.packages[restrict.category]
+ except KeyError:
+ # just stop now. no category matches == no yielded cpvs.
return
- candidates = [atom.key]
-
- except KeyError:
- # atom.category wasn't valid. no matches possible.
- return
+ else:
+ try:
+ if restrict.package not in self.packages[restrict.category]:
+ # no matches possible
+ return
+ candidates = [restrict.key]
+ except KeyError:
+ # restrict.category wasn't valid. no matches possible.
+ return
+ else:
+ candidates = self.packages
#actual matching.
for catpkg in candidates:
for ver in self.versions[catpkg]:
- if atom.match(self.package_class(catpkg+"-"+ver)):
+ if restrict.match(self.package_class(catpkg+"-"+ver)):
yield self[catpkg+"-"+ver]
return
diff --git a/portage/repository/visibility.py b/portage/repository/visibility.py
index 8e617fb..6fd3368 100644
--- a/portage/repository/visibility.py
+++ b/portage/repository/visibility.py
@@ -1,7 +1,7 @@
# 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.4 2005/07/21 19:50:17 ferringb Exp $
+# $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 $
# icky.
# ~harring
@@ -9,6 +9,7 @@ import prototype, errors
class filterTree(prototype.tree):
"""wrap an existing repository filtering results based upon passed in restrictions."""
+
def __init__(self, repo, restrictions, sentinel_val=False):
self.raw_repo = repo
self.sentinel_val = sentinel_val
@@ -18,8 +19,13 @@ class filterTree(prototype.tree):
restrictions = [restrictions]
self._restrictions = restrictions
+
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:
- yield cpv
+ ret = False
+ break
+ if ret:
+ yield cpv