1 |
commit: 00be1d0f47dbb2ea5e97f753b0356f0755ff2464 |
2 |
Author: Michał Górny <mgorny <AT> gentoo <DOT> org> |
3 |
AuthorDate: Wed Jul 27 16:05:28 2011 +0000 |
4 |
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org> |
5 |
CommitDate: Wed Jul 27 16:05:28 2011 +0000 |
6 |
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoopm.git;a=commit;h=00be1d0f |
7 |
|
8 |
Portage: support dropping conditionals using use_reduce(). |
9 |
|
10 |
--- |
11 |
gentoopm/portagepm/depend.py | 42 ++++++++++++++++++++++++++++++++++++++++-- |
12 |
1 files changed, 40 insertions(+), 2 deletions(-) |
13 |
|
14 |
diff --git a/gentoopm/portagepm/depend.py b/gentoopm/portagepm/depend.py |
15 |
index 9421099..dd96664 100644 |
16 |
--- a/gentoopm/portagepm/depend.py |
17 |
+++ b/gentoopm/portagepm/depend.py |
18 |
@@ -3,7 +3,7 @@ |
19 |
# (c) 2011 Michał Górny <mgorny@g.o> |
20 |
# Released under the terms of the 2-clause BSD license. |
21 |
|
22 |
-from portage.dep import paren_reduce |
23 |
+from portage.dep import paren_reduce, use_reduce |
24 |
|
25 |
from gentoopm.basepm.depend import PMPackageDepSet, PMConditionalDep, \ |
26 |
PMOneOfDep, PMAllOfDep, PMBaseDep |
27 |
@@ -44,4 +44,42 @@ class PortageConditionalUseDep(PMConditionalDep, PortageBaseDep): |
28 |
|
29 |
class PortagePackageDepSet(PMPackageDepSet, PortageBaseDep): |
30 |
def __init__(self, s, puse): |
31 |
- PortageBaseDep.__init__(self, paren_reduce(s), puse) |
32 |
+ self._depstr = s |
33 |
+ PortageBaseDep.__init__(self, None, puse) |
34 |
+ |
35 |
+ def __iter__(self): |
36 |
+ if self._deps is None: |
37 |
+ self._deps = paren_reduce(self._depstr) |
38 |
+ return PortageBaseDep.__iter__(self) |
39 |
+ |
40 |
+ @property |
41 |
+ def without_conditionals(self): |
42 |
+ return PortageUncondPackageDepSet( |
43 |
+ use_reduce(self._depstr, self._puse)) |
44 |
+ |
45 |
+class PortageUncondDep(PortageBaseDep): |
46 |
+ def __init__(self, deps): |
47 |
+ self._deps = deps |
48 |
+ |
49 |
+ @property |
50 |
+ def without_conditionals(self): |
51 |
+ return self |
52 |
+ |
53 |
+ def __iter__(self): |
54 |
+ it = iter(self._deps) |
55 |
+ for d in it: |
56 |
+ if d == '||': |
57 |
+ yield PortageUncondOneOfDep(next(it)) |
58 |
+ elif d == '&&': |
59 |
+ yield PortageUncondAllOfDep(next(it)) |
60 |
+ else: |
61 |
+ yield PortageAtom(d) |
62 |
+ |
63 |
+class PortageUncondOneOfDep(PMOneOfDep, PortageUncondDep): |
64 |
+ pass |
65 |
+ |
66 |
+class PortageUncondAllOfDep(PMAllOfDep, PortageUncondDep): |
67 |
+ pass |
68 |
+ |
69 |
+class PortageUncondPackageDepSet(PortageUncondDep): |
70 |
+ pass |