1 |
commit: 9d4789c7871d2c52b67fc304b5795d0ee60d985c |
2 |
Author: Michał Górny <mgorny <AT> gentoo <DOT> org> |
3 |
AuthorDate: Thu Jul 28 16:24:54 2011 +0000 |
4 |
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org> |
5 |
CommitDate: Thu Jul 28 16:24:54 2011 +0000 |
6 |
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoopm.git;a=commit;h=9d4789c7 |
7 |
|
8 |
Fix matching blockers. |
9 |
|
10 |
--- |
11 |
gentoopm/basepm/atom.py | 7 +++++-- |
12 |
gentoopm/paludispm/atom.py | 5 ++++- |
13 |
gentoopm/pkgcorepm/atom.py | 2 +- |
14 |
gentoopm/portagepm/atom.py | 9 ++++++--- |
15 |
4 files changed, 16 insertions(+), 7 deletions(-) |
16 |
|
17 |
diff --git a/gentoopm/basepm/atom.py b/gentoopm/basepm/atom.py |
18 |
index e745a38..368b72a 100644 |
19 |
--- a/gentoopm/basepm/atom.py |
20 |
+++ b/gentoopm/basepm/atom.py |
21 |
@@ -115,8 +115,11 @@ class PMAtom(ABCObject, StringifiedComparisons): |
22 |
@abstractmethod |
23 |
def __contains__(self, pkg): |
24 |
""" |
25 |
- Check whether a package matches the atom (is contained in the set |
26 |
- of packages matched by atom). |
27 |
+ Check whether a package is contained in the set of packages matched |
28 |
+ by the atom. |
29 |
+ |
30 |
+ Please note that with blockers, this function returns C{True} for all |
31 |
+ atoms not blocked by the atom. |
32 |
|
33 |
@param pkg: a package to match |
34 |
@type pkg: L{PMPackage} |
35 |
|
36 |
diff --git a/gentoopm/paludispm/atom.py b/gentoopm/paludispm/atom.py |
37 |
index ec5b830..60b4b05 100644 |
38 |
--- a/gentoopm/paludispm/atom.py |
39 |
+++ b/gentoopm/paludispm/atom.py |
40 |
@@ -83,7 +83,7 @@ class PaludisAtom(PMAtom): |
41 |
self._incomplete = True |
42 |
self._env = env |
43 |
|
44 |
- def __contains__(self, pkg): |
45 |
+ def _match(self, pkg): |
46 |
# we have to implementing matching by hand, boo |
47 |
other = pkg.atom |
48 |
# 1) category, our may be unset |
49 |
@@ -112,6 +112,9 @@ class PaludisAtom(PMAtom): |
50 |
return False |
51 |
return True |
52 |
|
53 |
+ def __contains__(self, pkg): |
54 |
+ return self._match(pkg) != self.blocking |
55 |
+ |
56 |
def __str__(self): |
57 |
if self._incomplete: |
58 |
raise ValueError('Unable to stringify incomplete atom') |
59 |
|
60 |
diff --git a/gentoopm/pkgcorepm/atom.py b/gentoopm/pkgcorepm/atom.py |
61 |
index ac0a350..5eced44 100644 |
62 |
--- a/gentoopm/pkgcorepm/atom.py |
63 |
+++ b/gentoopm/pkgcorepm/atom.py |
64 |
@@ -104,7 +104,7 @@ class PkgCoreAtom(PMAtom): |
65 |
raise InvalidAtomStringError('Incorrect atom: %s' % s) |
66 |
|
67 |
def __contains__(self, pkg): |
68 |
- return self._r.match(pkg._pkg) |
69 |
+ return self._r.match(pkg._pkg) != self.blocking |
70 |
|
71 |
def __str__(self): |
72 |
if self.complete: |
73 |
|
74 |
diff --git a/gentoopm/portagepm/atom.py b/gentoopm/portagepm/atom.py |
75 |
index 425fd1e..9130d6a 100644 |
76 |
--- a/gentoopm/portagepm/atom.py |
77 |
+++ b/gentoopm/portagepm/atom.py |
78 |
@@ -78,13 +78,16 @@ class CompletePortageAtom(PMAtom): |
79 |
def __init__(self, a): |
80 |
self._atom = a |
81 |
|
82 |
- def __contains__(self, pkg): |
83 |
+ def _match(self, pkg): |
84 |
# SLOT matching requires metadata so delay it. |
85 |
- if not match_from_list(self._atom, [pkg.id]): |
86 |
+ if not match_from_list(self._atom, [pkg._cpv]): |
87 |
return False |
88 |
return not self._atom.slot \ |
89 |
or self._atom.slot == pkg.metadata.SLOT |
90 |
|
91 |
+ def __contains__(self, pkg): |
92 |
+ return self._match(pkg) != self.blocking |
93 |
+ |
94 |
def __str__(self): |
95 |
return str(self._atom) |
96 |
|
97 |
@@ -94,7 +97,7 @@ class CompletePortageAtom(PMAtom): |
98 |
|
99 |
@property |
100 |
def blocking(self): |
101 |
- return self._atom.blocker |
102 |
+ return bool(self._atom.blocker) |
103 |
|
104 |
@property |
105 |
def key(self): |