1 |
Author: genone |
2 |
Date: 2008-09-28 22:55:35 +0000 (Sun, 28 Sep 2008) |
3 |
New Revision: 11596 |
4 |
|
5 |
Modified: |
6 |
main/trunk/pym/portage/sets/dbapi.py |
7 |
Log: |
8 |
allow selection of metadata source for VariableSet |
9 |
|
10 |
Modified: main/trunk/pym/portage/sets/dbapi.py |
11 |
=================================================================== |
12 |
--- main/trunk/pym/portage/sets/dbapi.py 2008-09-28 22:36:42 UTC (rev 11595) |
13 |
+++ main/trunk/pym/portage/sets/dbapi.py 2008-09-28 22:55:35 UTC (rev 11596) |
14 |
@@ -2,7 +2,7 @@ |
15 |
# Distributed under the terms of the GNU General Public License v2 |
16 |
# $Id$ |
17 |
|
18 |
-from portage.versions import catpkgsplit, catsplit, pkgcmp |
19 |
+from portage.versions import catpkgsplit, catsplit, pkgcmp, best |
20 |
from portage.dep import Atom |
21 |
from portage.sets.base import PackageSet |
22 |
from portage.sets import SetConfigError, get_boolean |
23 |
@@ -96,18 +96,18 @@ |
24 |
description = "Package set which contains all packages " + \ |
25 |
"that match specified values of a specified variable." |
26 |
|
27 |
- def __init__(self, vardb, portdb=None, variable=None, includes=None, excludes=None): |
28 |
+ def __init__(self, vardb, metadatadb=None, variable=None, includes=None, excludes=None): |
29 |
super(VariableSet, self).__init__(vardb) |
30 |
- self._portdb = portdb |
31 |
+ self._metadatadb = metadatadb |
32 |
self._variable = variable |
33 |
self._includes = includes |
34 |
self._excludes = excludes |
35 |
|
36 |
def _filter(self, atom): |
37 |
- ebuild = self._portdb.xmatch("bestmatch-visible", atom) |
38 |
+ ebuild = best(self._metadatadb.match(atom)) |
39 |
if not ebuild: |
40 |
return False |
41 |
- values, = self._portdb.aux_get(ebuild, [self._variable]) |
42 |
+ values, = self._metadatadb.aux_get(ebuild, [self._variable]) |
43 |
values = values.split() |
44 |
if self._includes and not self._includes.intersection(values): |
45 |
return False |
46 |
@@ -126,9 +126,13 @@ |
47 |
|
48 |
if not (includes or excludes): |
49 |
raise SetConfigError("no includes or excludes given") |
50 |
+ |
51 |
+ metadatadb = options.get("metadata-source", "vartree") |
52 |
+ if not metadatadb in trees.keys(): |
53 |
+ raise SetConfigError("invalid value '%s' for option metadata-source" % metadatadb) |
54 |
|
55 |
return cls(trees["vartree"].dbapi, |
56 |
- portdb=trees["porttree"].dbapi, |
57 |
+ metadatadb=trees[metadatadb].dbapi, |
58 |
excludes=frozenset(excludes.split()), |
59 |
includes=frozenset(includes.split()), |
60 |
variable=variable) |