1. Michał Górny
  2. smart-live-rebuild

Commits

Michał Górny  committed 403f850

Keep all matches on a single list to not mangle order.

As matchers can contain PM CLI arguments, keep them on a single list.
This way, we won't shift args between non-matched filters and non-filter
args.

  • Participants
  • Parent commits 0d0005c
  • Branches master

Comments (0)

Files changed (1)

File smartliverebuild/filtering.py

View file
  • Ignore whitespace
 	def __init__(self, wlist):
 		""" Init filters from pattern list. """
 		if wlist:
-			pmatchers = [self.PackageMatcher(w) for w in wlist]
-			self._broken = filter(lambda f: f.broken, pmatchers)
-			self._pmatchers = filter(lambda f: not f.broken, pmatchers)
+			self._pmatchers = [self.PackageMatcher(w) for w in wlist]
 			for f in self._pmatchers:
-				self._default_pass = f.exclusive
-				break
+				if not f.broken:
+					self._default_pass = f.exclusive
+					return
 		else:
 			self._pmatchers = ()
-			self._default_pass = True
+		self._default_pass = True
 
 	def __call__(self, cpv):
 		""" Execute filtering on CPV. """
 		r = self._default_pass
 		for m in self._pmatchers:
-			if m.exclusive:
+			if m.broken:
+				pass
+			elif m.exclusive:
 				r &= m(cpv)
 			else:
 				r |= m(cpv)
 		""" Iterate over non-matched args. """
 
 		for m in self._pmatchers:
-			if not m.matched:
+			if m.broken or not m.matched:
 				yield m.wildcard
-		for m in self._broken:
-			yield m.wildcard