Michał Górny avatar Michał Górny committed 9d4789c

Fix matching blockers.

Comments (0)

Files changed (4)

gentoopm/basepm/atom.py

 	@abstractmethod
 	def __contains__(self, pkg):
 		"""
-		Check whether a package matches the atom (is contained in the set
-		of packages matched by atom).
+		Check whether a package is contained in the set of packages matched
+		by the atom.
+
+		Please note that with blockers, this function returns C{True} for all
+		atoms not blocked by the atom.
 
 		@param pkg: a package to match
 		@type pkg: L{PMPackage}

gentoopm/paludispm/atom.py

 				self._incomplete = True
 		self._env = env
 
-	def __contains__(self, pkg):
+	def _match(self, pkg):
 		# we have to implementing matching by hand, boo
 		other = pkg.atom
 		# 1) category, our may be unset
 			return False
 		return True
 
+	def __contains__(self, pkg):
+		return self._match(pkg) != self.blocking
+
 	def __str__(self):
 		if self._incomplete:
 			raise ValueError('Unable to stringify incomplete atom')

gentoopm/pkgcorepm/atom.py

 				raise InvalidAtomStringError('Incorrect atom: %s' % s)
 
 	def __contains__(self, pkg):
-		return self._r.match(pkg._pkg)
+		return self._r.match(pkg._pkg) != self.blocking
 
 	def __str__(self):
 		if self.complete:

gentoopm/portagepm/atom.py

 	def __init__(self, a):
 		self._atom = a
 
-	def __contains__(self, pkg):
+	def _match(self, pkg):
 		# SLOT matching requires metadata so delay it.
-		if not match_from_list(self._atom, [pkg.id]):
+		if not match_from_list(self._atom, [pkg._cpv]):
 			return False
 		return not self._atom.slot \
 				or self._atom.slot == pkg.metadata.SLOT
 
+	def __contains__(self, pkg):
+		return self._match(pkg) != self.blocking
+
 	def __str__(self):
 		return str(self._atom)
 
 
 	@property
 	def blocking(self):
-		return self._atom.blocker
+		return bool(self._atom.blocker)
 
 	@property
 	def key(self):
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.