Commits

Michał Górny  committed 72df8c4

Introduce PMInstallablePackage, to clearly distinguish.

This way, one kind of packages won't subclass another one, and we're
clear to use isinstance().

  • Participants
  • Parent commits caf8863

Comments (0)

Files changed (6)

File gentoopm/basepm/pkg.py

 	def associated(self):
 		return True
 
+class PMInstallablePackage(PMPackage):
+	"""
+	An abstract class for a package which can be installed.
+	"""
+	pass
+
 class PMInstalledPackage(PMPackage):
 	"""
 	An abstract class for a installed package.

File gentoopm/paludispm/pkg.py

 
 from gentoopm.basepm.metadata import PMPackageMetadata
 from gentoopm.basepm.pkg import PMPackage, PMPackageDescription, \
-		PMInstalledPackage
+		PMInstallablePackage, PMInstalledPackage
 from gentoopm.paludispm.atom import PaludisAtom, \
 		PaludisPackageKey, PaludisPackageVersion
 from gentoopm.util import SpaceSepTuple
 			raise TypeError('Unable to compare results of two enumerations')
 		return self._num < other._num
 
+class PaludisInstallableID(PaludisID, PMInstallablePackage):
+	pass
+
 class PaludisInstalledID(PaludisID, PMInstalledPackage):
 	pass
 

File gentoopm/paludispm/repo.py

 from gentoopm.basepm.repo import PMRepository, PMRepositoryDict, \
 		PMEbuildRepository
 from gentoopm.paludispm.atom import PaludisAtom
-from gentoopm.paludispm.pkg import PaludisID, PaludisInstalledID
+from gentoopm.paludispm.pkg import PaludisInstallableID, PaludisInstalledID
 from gentoopm.paludispm.pkgset import PaludisPackageSet
 
 class PaludisRepoDict(PMRepositoryDict):
 		self._mypkg_class = repo._pkg_class
 
 class PaludisStackRepo(PaludisBaseRepo):
-	_pkg_class = PaludisID
+	_pkg_class = PaludisInstallableID
 
 	@property
 	def _filt(self):
 		return paludis.Filter.SupportsInstallAction()
 
 class PaludisLivefsRepository(PaludisBaseRepo, PMEbuildRepository):
-	_pkg_class = PaludisID
+	_pkg_class = PaludisInstallableID
 
 	def __init__(self, repo_obj, env):
 		PaludisBaseRepo.__init__(self, env)

File gentoopm/pkgcorepm/pkg.py

 
 from gentoopm.basepm.metadata import PMPackageMetadata
 from gentoopm.basepm.pkg import PMPackage, PMPackageDescription, \
-		PMInstalledPackage
+		PMInstalledPackage, PMInstallablePackage
 from gentoopm.basepm.pkgset import PMPackageSet, PMFilteredPackageSet
 from gentoopm.pkgcorepm.atom import PkgCoreAtom
 from gentoopm.util import SpaceSepTuple
 		return PkgCorePackageDescription(self._pkg)
 
 	@property
-	def inherits(self):
-		try:
-			l = self._pkg.data['_eclasses_']
-		except KeyError:
-			l = ()
-
-		return SpaceSepTuple(l)
-
-	@property
 	def homepages(self):
 		return SpaceSepTuple(self._pkg.homepage)
 
 			s = self._pkg.cpvstr
 		return '=%s' % s
 
+class PkgCoreInstallablePackage(PkgCorePackage, PMInstallablePackage):
+	@property
+	def inherits(self):
+		try:
+			l = self._pkg.data['_eclasses_']
+		except KeyError:
+			l = ()
+
+		return SpaceSepTuple(l)
+
 	def __lt__(self, other):
 		if not isinstance(other, PkgCorePackage):
 			raise TypeError('Unable to compare %s against %s' % \

File gentoopm/pkgcorepm/repo.py

 
 from gentoopm.basepm.repo import PMRepository, PMRepositoryDict, \
 		PMEbuildRepository
-from gentoopm.pkgcorepm.pkg import PkgCorePackage, PkgCorePackageSet, \
-		PkgCoreFilteredPackageSet, PkgCoreInstalledPackage
+from gentoopm.pkgcorepm.pkg import PkgCorePackageSet, PkgCoreFilteredPackageSet, \
+		PkgCoreInstallablePackage, PkgCoreInstalledPackage
 from gentoopm.pkgcorepm.filter import transform_filters
 from gentoopm.util import FillMissingComparisons
 
 class PkgCoreEbuildRepo(PkgCoreRepository, PMEbuildRepository,
 		FillMissingComparisons):
 
-	_pkg_class = PkgCorePackage
+	_pkg_class = PkgCoreInstallablePackage
 
 	def __init__(self, repo_obj, index):
 		PkgCoreRepository.__init__(self, repo_obj)

File gentoopm/portagepm/pkg.py

 
 from gentoopm.basepm.metadata import PMPackageMetadata
 from gentoopm.basepm.pkg import PMPackage, PMPackageDescription, \
-		PMInstalledPackage
+		PMInstalledPackage, PMInstallablePackage
 from gentoopm.basepm.pkgset import PMPackageSet, PMFilteredPackageSet
 from gentoopm.portagepm.atom import PortageAtom, CompletePortageAtom, \
 		PortagePackageKey, PortagePackageVersion, _get_atom
 		return cpv_getkey(self._cpv) < cpv_getkey(other._cpv) \
 				or vercmp(cpv_getversion(self._cpv), cpv_getversion(other._cpv)) < 0
 
-class PortageCPV(PortageDBCPV):
+class PortageCPV(PortageDBCPV, PMInstallablePackage):
 	def __init__(self, cpv, dbapi, tree, repo_prio):
 		PortageDBCPV.__init__(self, cpv, dbapi)
 		self._tree = tree