Commits

Michał Górny  committed 61f6250

Portage: support '^^' in depstrings (using a hack).

  • Participants
  • Parent commits 7b1ac7e

Comments (0)

Files changed (2)

File gentoopm/portagepm/depend.py

 from portage.dep import paren_reduce, use_reduce
 
 from gentoopm.basepm.depend import PMPackageDepSet, PMConditionalDep, \
-	PMAnyOfDep, PMAllOfDep, PMBaseDep
+	PMAnyOfDep, PMAllOfDep, PMExactlyOneOfDep, PMBaseDep
 from gentoopm.portagepm.atom import PortageAtom
 
 class PortageBaseDep(PMBaseDep):
 				yield PortageAnyOfDep(next(it), self._puse)
 			elif d == '&&':
 				yield PortageAllOfDep(next(it), self._puse)
+			elif d == '__xor__?':
+				yield PortageExactlyOneOfDep(next(it), self._puse)
 			elif d.endswith('?'):
 				yield PortageConditionalUseDep(next(it),
 						self._puse, d.rstrip('?'))
 class PortageAllOfDep(PMAllOfDep, PortageBaseDep):
 	pass
 
+class PortageExactlyOneOfDep(PMExactlyOneOfDep, PortageBaseDep):
+	pass
+
 class PortageConditionalUseDep(PMConditionalDep, PortageBaseDep):
 	def __init__(self, deps, puse, flag):
 		PortageBaseDep.__init__(self, deps, puse)
 
 class PortagePackageDepSet(PMPackageDepSet, PortageBaseDep):
 	def __init__(self, s, puse):
-		self._depstr = s
+		self._use_reducable = not '^^' in s
+		if not self._use_reducable:
+			# ARGV, paren_reduce() doesn't handle ^^
+			# so we hack it to a __xor__?, UGLY!
+			self._depstr = s.replace('^^', '__xor__?')
 		PortageBaseDep.__init__(self, None, puse)
 
 	def __iter__(self):
 
 	@property
 	def without_conditionals(self):
-		return PortageUncondAllOfDep(
-				use_reduce(self._depstr, self._puse))
+		if self._use_reducable:
+			return PortageUncondAllOfDep(
+					use_reduce(self._depstr, self._puse))
+		return PMPackageDepSet.without_conditionals.fget(self)
 
 class PortageUncondDep(PortageBaseDep):
 	def __init__(self, deps):
 
 class PortageUncondAllOfDep(PMAllOfDep, PortageUncondDep):
 	pass
+
+class PortageUncondExactlyOneOfDep(PMExactlyOneOfDep, PortageUncondDep):
+	pass

File gentoopm/portagepm/pkg.py

 		return PortagePackageDepSet(self._aux_get('PDEPEND'),
 				self._applied_use)
 
+	@property
+	def required_use(self):
+		return PortagePackageDepSet(self._aux_get('REQUIRED_USE'),
+				self._applied_use)
+
 	def __str__(self):
 		return '=%s' % self._cpv