Commits

Michał Górny committed d9df312

Paludis: fix PackageSet inheritance/filtering.

Comments (0)

Files changed (3)

gentoopm/basepm/pkgset.py

 		for el in self._src:
 			if el._matches(*self._args, **self._kwargs):
 				yield el
-
-

gentoopm/paludispm/pkgset.py

 
 from gentoopm.basepm.pkgset import PMPackageSet, PMFilteredPackageSet
 from gentoopm.exceptions import EmptyPackageSetError, AmbiguousPackageSetError
+from gentoopm.paludispm.atom import PaludisAtom
 
-class PaludisPackageSet(PMPackageSet):
-	_sorted = False
+class PaludisPackageSet(object):
+	def __init__(self, env, issorted = False):
+		self._env = env
+		self._sorted = issorted
 
 	def filter(self, *args, **kwargs):
-		return PaludisFilteredPackageSet(self, args, kwargs)
+		newargs = [(a if not isinstance(a, str)
+			else PaludisAtom(a)) for a in args]
+
+		return PaludisFilteredPackageSet(self, newargs, kwargs)
 
 	@property
 	def best(self):
 		else:
 			return PMPackageSet.best.fget(self)
 
-class PaludisFilteredPackageSet(PMFilteredPackageSet, PaludisPackageSet):
+class PaludisFilteredPackageSet(PaludisPackageSet, PMFilteredPackageSet):
 	def __init__(self, pset, args, kwargs):
-		self._sorted = pset._sorted
+		PaludisPackageSet.__init__(self, pset._env, pset._sorted)
 		PMFilteredPackageSet.__init__(self, pset, args, kwargs)

gentoopm/paludispm/repo.py

 
 class PaludisRepository(PMRepository, PaludisPackageSet):
 	def __init__(self, env):
-		self._env = env
-		self._sorted = True
+		PaludisPackageSet.__init__(self, env, True)
 
 	@property
 	def _gen(self):
 				newargs.append(f)
 
 		if id(pset) == id(self):
-			return PaludisPackageSet.filter(self, args, kwargs)
+			return PaludisPackageSet.filter(self, *args, **kwargs)
 		elif newargs or kwargs:
-			return pset.filter(self, newargs, kwargs)
+			return pset.filter(*newargs, **kwargs)
 		else:
 			return pset
 
 
 class PaludisInstalledRepo(PaludisRepository):
 	def __init__(self, env):
-		self._env = env
+		PaludisRepository.__init__(self, env)
 		for r in env.repositories:
 			if str(r.name) == 'installed': # XXX
 				self._repo = r