1. Michał Górny
  2. gentoopm

Commits

Michał Górny  committed 79f2892

Support getting IUSE in all PMs.

  • Participants
  • Parent commits 7632806
  • Branches master

Comments (0)

Files changed (3)

File gentoopm/paludispm/pkg.py

View file
 from gentoopm.basepm.metadata import PMPackageMetadata
 from gentoopm.basepm.pkg import PMPackage, PMPackageDescription, \
 		PMInstallablePackage, PMInstalledPackage, PMBoundPackageKey, \
-		PMPackageState
+		PMPackageState, PMUseFlag
 from gentoopm.paludispm.atom import PaludisAtom, \
 		PaludisPackageKey, PaludisPackageVersion
 from gentoopm.paludispm.contents import PaludisPackageContents
 		k = self._pkg.long_description_key()
 		return k.parse_value() if k is not None else None
 
+class PaludisUseFlag(PMUseFlag):
+	pass
+
 class PaludisID(PMPackage, PaludisAtom):
 	def __init__(self, pkg, env):
 		self._pkg = pkg
 				self)
 
 	@property
+	def use(self):
+		iuse = self._pkg.find_metadata('IUSE').parse_value()
+		return SpaceSepTuple([PaludisUseFlag(x) for x in iuse])
+
+	@property
 	def _atom(self):
 		return self._pkg.uniquely_identifying_spec()
 

File gentoopm/pkgcorepm/pkg.py

View file
 from gentoopm.basepm.metadata import PMPackageMetadata
 from gentoopm.basepm.pkg import PMPackage, PMPackageDescription, \
 		PMInstalledPackage, PMInstallablePackage, PMBoundPackageKey, \
-		PMPackageState
+		PMPackageState, PMUseFlag
 from gentoopm.basepm.pkgset import PMPackageSet, PMFilteredPackageSet
 from gentoopm.pkgcorepm.atom import PkgCoreAtom, PkgCorePackageKey
 from gentoopm.pkgcorepm.contents import PkgCorePackageContents
 		else: # vdb, for example
 			return None
 
+class PkgCoreUseFlag(PMUseFlag):
+	pass
+
 class PkgCorePackage(PMPackage, PkgCoreAtom):
 	def __init__(self, pkg, repo_index = 0):
 		self._pkg = pkg
 		return SpaceSepTuple(self._pkg.homepage)
 
 	@property
+	def use(self):
+		return SpaceSepTuple([PkgCoreUseFlag(x) for x in self._pkg.iuse])
+
+	@property
 	def slotted(self):
 		return PkgCoreAtom(self._pkg.slotted_atom)
 

File gentoopm/portagepm/pkg.py

View file
 from gentoopm.basepm.metadata import PMPackageMetadata
 from gentoopm.basepm.pkg import PMPackage, PMPackageDescription, \
 		PMInstalledPackage, PMInstallablePackage, PMBoundPackageKey, \
-		PMPackageState
+		PMPackageState, PMUseFlag
 from gentoopm.basepm.pkgset import PMPackageSet, PMFilteredPackageSet
 from gentoopm.portagepm.atom import PortageAtom, CompletePortageAtom, \
 		PortagePackageKey, PortagePackageVersion, _get_atom
 		"""
 		return None # XXX
 
+class PortageUseFlag(PMUseFlag):
+	pass
+
 class PortageDBCPV(PMPackage, CompletePortageAtom):
 	def __init__(self, cpv, dbapi):
 		self._cpv = cpv
 		raise None
 
 	@property
+	def use(self):
+		return SpaceSepTuple([PortageUseFlag(x) for x \
+				in self._aux_get('IUSE').split()])
+
+	@property
 	def slotted(self):
 		cp = str(self.key)
 		slot = self.slot