1 |
commit: 510300cdf687df85ed1ab5f049f8502e1e3e3814 |
2 |
Author: Michał Górny <mgorny <AT> gentoo <DOT> org> |
3 |
AuthorDate: Fri Jul 29 06:39:27 2011 +0000 |
4 |
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org> |
5 |
CommitDate: Fri Jul 29 06:39:27 2011 +0000 |
6 |
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoopm.git;a=commit;h=510300cd |
7 |
|
8 |
Paludis: start using choices_key(). |
9 |
|
10 |
This will allow getting USE values in the future. |
11 |
|
12 |
--- |
13 |
gentoopm/paludispm/pkg.py | 32 ++++++++++++++++++++++++++++---- |
14 |
1 files changed, 28 insertions(+), 4 deletions(-) |
15 |
|
16 |
diff --git a/gentoopm/paludispm/pkg.py b/gentoopm/paludispm/pkg.py |
17 |
index 368344c..fe680ee 100644 |
18 |
--- a/gentoopm/paludispm/pkg.py |
19 |
+++ b/gentoopm/paludispm/pkg.py |
20 |
@@ -40,8 +40,31 @@ class PaludisPackageDescription(PMPackageDescription): |
21 |
k = self._pkg.long_description_key() |
22 |
return k.parse_value() if k is not None else None |
23 |
|
24 |
-class PaludisUseFlag(PMUseFlag): |
25 |
- pass |
26 |
+class PaludisChoice(PMUseFlag): |
27 |
+ def __init__(self, choice, default = None): |
28 |
+ self._c = choice |
29 |
+ self._default = default |
30 |
+ |
31 |
+ @property |
32 |
+ def default(self): |
33 |
+ return self._default |
34 |
+ |
35 |
+ @property |
36 |
+ def name(self): |
37 |
+ return str(self._c.name_with_prefix) |
38 |
+ |
39 |
+class PaludisChoiceSet(SpaceSepFrozenSet): |
40 |
+ def __new__(self, choices, iuse): |
41 |
+ iuse = SpaceSepFrozenSet([PMUseFlag(x) for x in iuse]) |
42 |
+ l = [] |
43 |
+ for group in choices: |
44 |
+ if group.raw_name == 'build_options': # paludis specific |
45 |
+ continue |
46 |
+ for c in group: |
47 |
+ if c.explicitly_listed: |
48 |
+ miuse = iuse[str(c.name_with_prefix)] |
49 |
+ l.append(PaludisChoice(c, miuse.default)) |
50 |
+ return SpaceSepFrozenSet.__new__(self, l) |
51 |
|
52 |
class PaludisID(PMPackage, PaludisAtom): |
53 |
def __init__(self, pkg, env): |
54 |
@@ -149,8 +172,9 @@ class PaludisID(PMPackage, PaludisAtom): |
55 |
|
56 |
@property |
57 |
def use(self): |
58 |
- iuse = self._get_meta('IUSE') |
59 |
- return SpaceSepFrozenSet([PaludisUseFlag(x) for x in iuse]) |
60 |
+ return PaludisChoiceSet( |
61 |
+ self._get_meta(self._pkg.choices_key()), |
62 |
+ self._get_meta('IUSE')) |
63 |
|
64 |
@property |
65 |
def _atom(self): |