Commits

Michał Górny committed 7b1ac7e

Paludis/pkgcore: introduce initial support for REQUIRED_USE.

Comments (0)

Files changed (4)

gentoopm/paludispm/depend.py

 import paludis
 
 from gentoopm.basepm.depend import PMPackageDepSet, PMConditionalDep, \
-	PMAnyOfDep, PMAllOfDep, PMBaseDep
+	PMAnyOfDep, PMAllOfDep, PMExactlyOneOfDep, PMBaseDep
 from gentoopm.paludispm.atom import PaludisAtom
 
 class PaludisBaseDep(PMBaseDep):
 				yield PaludisAnyOfDep(d, self._pkg)
 			elif isinstance(d, paludis.AllDepSpec):
 				yield PaludisAllOfDep(d, self._pkg)
+			elif isinstance(d, paludis.ExactlyOneDepSpec):
+				yield PaludisExactlyOneOfDep(d, self._pkg)
 			elif isinstance(d, paludis.ConditionalDepSpec):
 				yield PaludisConditionalDep(d, self._pkg)
+			elif isinstance(d, paludis.PlainTextDepSpec):
+				# XXX: this is in REQUIRED_USE as well
+				yield str(d)
 			else:
 				raise NotImplementedError('Unable to parse %s' % repr(d))
 
 class PaludisAllOfDep(PMAllOfDep, PaludisBaseDep):
 	pass
 
+class PaludisExactlyOneOfDep(PMExactlyOneOfDep, PaludisBaseDep):
+	pass
+
 class PaludisConditionalDep(PMConditionalDep, PaludisBaseDep):
 	@property
 	def enabled(self):

gentoopm/paludispm/pkg.py

 				self)
 
 	@property
+	def required_use(self):
+		k = self._pkg.find_metadata('REQUIRED_USE')
+		if k is None:
+			return None
+		return PaludisPackageDepSet(k.parse_value(), self)
+
+	@property
 	def use(self):
 		iuse = self._pkg.find_metadata('IUSE').parse_value()
 		return SpaceSepFrozenSet([PaludisUseFlag(x) for x in iuse])

gentoopm/pkgcorepm/depend.py

 # Released under the terms of the 2-clause BSD license.
 
 from pkgcore.ebuild.atom import atom
-from pkgcore.restrictions.boolean import OrRestriction, AndRestriction
+from pkgcore.restrictions.boolean import OrRestriction, AndRestriction, \
+		JustOneRestriction
 from pkgcore.restrictions.packages import Conditional
+from pkgcore.restrictions.values import ContainmentMatch
 
 from gentoopm.basepm.depend import PMPackageDepSet, PMConditionalDep, \
-	PMAnyOfDep, PMAllOfDep, PMBaseDep
+	PMAnyOfDep, PMAllOfDep, PMExactlyOneOfDep, PMBaseDep
 from gentoopm.pkgcorepm.atom import PkgCoreAtom
 
 class PkgCoreBaseDep(PMBaseDep):
 		for d in self._deps:
 			if isinstance(d, atom):
 				yield PkgCoreAtom(d)
+			elif isinstance(d, ContainmentMatch): # REQUIRED_USE
+				assert(len(d.vals) == 1)
+				yield next(iter(d.vals))
 			elif isinstance(d, OrRestriction):
 				yield PkgCoreAnyOfDep(d, self._pkg)
 			elif isinstance(d, AndRestriction):
 				yield PkgCoreAllOfDep(d, self._pkg)
+			elif isinstance(d, JustOneRestriction):
+				yield PkgCoreExactlyOneOfDep(d, self._pkg)
 			elif isinstance(d, Conditional) and d.attr == 'use':
 				yield PkgCoreConditionalUseDep(d, self._pkg)
 			else:
 class PkgCoreAllOfDep(PMAllOfDep, PkgCoreBaseDep):
 	pass
 
+class PkgCoreExactlyOneOfDep(PMExactlyOneOfDep, PkgCoreBaseDep):
+	pass
+
 class PkgCoreConditionalUseDep(PMConditionalDep, PkgCoreBaseDep):
 	@property
 	def enabled(self):
 				yield PkgCoreUncondAnyOfDep(d)
 			elif isinstance(d, AndRestriction):
 				yield PkgCoreUncondAllOfDep(d, self._pkg)
+			elif isinstance(d, JustOneRestriction):
+				yield PkgCoreUncondExactlyOneOfDep(d, self._pkg)
 			else:
 				raise NotImplementedError('Parsing %s not implemented' \
 						% repr(d))
 
 class PkgCoreUncondAllOfDep(PMAllOfDep, PkgCoreUncondDep):
 	pass
+
+class PkgCoreUncondAllOfDep(PMExactlyOneOfDep, PkgCoreUncondDep):
+	pass

gentoopm/pkgcorepm/pkg.py

 		return PkgCorePackageDepSet(self._pkg._raw_pkg.post_rdepends,
 				self._pkg)
 
+	@property
+	def required_use(self):
+		return PkgCorePackageDepSet(self._pkg._raw_pkg.required_use,
+				self._pkg)
+
 	def __lt__(self, other):
 		if not isinstance(other, PkgCorePackage):
 			raise TypeError('Unable to compare %s against %s' % \
 				self._pkg)
 
 	@property
+	def required_use(self):
+		return PkgCorePackageDepSet(self._pkg.required_use,
+				self._pkg)
+
+	@property
 	def contents(self):
 		return PkgCorePackageContents(self._pkg.contents)
 
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.