diff options
author | Marius Mauch <genone@gentoo.org> | 2008-09-28 22:55:35 +0000 |
---|---|---|
committer | Marius Mauch <genone@gentoo.org> | 2008-09-28 22:55:35 +0000 |
commit | efc0ada65572e6af7aebc4b2ccb1e29ebcd7232a (patch) | |
tree | f31f5b11d7a5086940d39becdc68a9c52022bcc7 | |
parent | 7f08347a7d5b322a0c0c023b6be78abb8b26203f (diff) | |
download | portage-efc0ada65572e6af7aebc4b2ccb1e29ebcd7232a.tar.gz portage-efc0ada65572e6af7aebc4b2ccb1e29ebcd7232a.tar.bz2 portage-efc0ada65572e6af7aebc4b2ccb1e29ebcd7232a.zip |
allow selection of metadata source for VariableSet
svn path=/main/trunk/; revision=11596
-rw-r--r-- | pym/portage/sets/dbapi.py | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/pym/portage/sets/dbapi.py b/pym/portage/sets/dbapi.py index 438c9e2ca..8e4d6983f 100644 --- a/pym/portage/sets/dbapi.py +++ b/pym/portage/sets/dbapi.py @@ -2,7 +2,7 @@ # Distributed under the terms of the GNU General Public License v2 # $Id$ -from portage.versions import catpkgsplit, catsplit, pkgcmp +from portage.versions import catpkgsplit, catsplit, pkgcmp, best from portage.dep import Atom from portage.sets.base import PackageSet from portage.sets import SetConfigError, get_boolean @@ -96,18 +96,18 @@ class VariableSet(EverythingSet): description = "Package set which contains all packages " + \ "that match specified values of a specified variable." - def __init__(self, vardb, portdb=None, variable=None, includes=None, excludes=None): + def __init__(self, vardb, metadatadb=None, variable=None, includes=None, excludes=None): super(VariableSet, self).__init__(vardb) - self._portdb = portdb + self._metadatadb = metadatadb self._variable = variable self._includes = includes self._excludes = excludes def _filter(self, atom): - ebuild = self._portdb.xmatch("bestmatch-visible", atom) + ebuild = best(self._metadatadb.match(atom)) if not ebuild: return False - values, = self._portdb.aux_get(ebuild, [self._variable]) + values, = self._metadatadb.aux_get(ebuild, [self._variable]) values = values.split() if self._includes and not self._includes.intersection(values): return False @@ -126,9 +126,13 @@ class VariableSet(EverythingSet): if not (includes or excludes): raise SetConfigError("no includes or excludes given") + + metadatadb = options.get("metadata-source", "vartree") + if not metadatadb in trees.keys(): + raise SetConfigError("invalid value '%s' for option metadata-source" % metadatadb) return cls(trees["vartree"].dbapi, - portdb=trees["porttree"].dbapi, + metadatadb=trees[metadatadb].dbapi, excludes=frozenset(excludes.split()), includes=frozenset(includes.split()), variable=variable) |