Michał Górny avatar Michał Górny committed c64cbf7

Stop splitting CP when filtering.

Comments (0)

Files changed (1)

smartliverebuild/filtering.py

 
 import fnmatch, re
 
-from portage.versions import catsplit
-
 wildcard_re = re.compile(r'^(!)?(?:([A-Za-z0-9_?*\[\]][A-Za-z0-9+_.?*\[\]-]*)/)?([A-Za-z0-9_?*\[\]][A-Za-z0-9+_?*\[\]-]*)$')
 
 class PackageFilter(object):
 	>>> pf = PackageFilter(['--pretend', '!*', 'app-foo/f*', 'smart-live-rebuild', '-avD'])
 	>>> [f for f in pf.nonmatched] # bang always matches
 	['--pretend', 'app-foo/f*', 'smart-live-rebuild', '-avD']
-	>>> pf('app-foo/foo-123')
+	>>> pf('app-foo/foo')
 	True
-	>>> pf('app-foo/bar-123')
+	>>> pf('app-foo/bar')
 	False
-	>>> pf('app-bar/foo-321')
+	>>> pf('app-bar/foo')
 	False
-	>>> pf('app-portage/smart-live-rebuild-9999')
+	>>> pf('app-portage/smart-live-rebuild')
 	True
 	>>> [f for f in pf.nonmatched]
 	['--pretend', '-avD']
 
 			if not self.broken:
 				self.exclusive = bool(m.group(1))
-				if m.group(2):
-					self.category = makere(m.group(2))
-				else:
-					self.category = re.compile('.')
-				self.pn = makere(m.group(3))
+				self.regexp = re.compile(r'^%s$' % fnmatch.translate(
+					'%s/%s' % (m.group(2) or '*', m.group(3))))
 				# .matched is used only on inclusive args
 				self.matched = self.exclusive
 
 			self.wildcard = wildcard
 
 		def __call__(self, cp):
-			cat, pkg = catsplit(cp)
-			m = bool(self.category.match(cat) and self.pn.match(pkg))
+			m = bool(self.regexp.match(cp))
 			self.matched |= m
 			return m ^ self.exclusive
 
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.