1. Michał Górny
  2. gentoopm


Michał Górny  committed 35ccdf9

Paludis: support passing more args to depspecs.

  • Participants
  • Parent commits 9d4789c
  • Branches master

Comments (0)

Files changed (1)

File gentoopm/paludispm/depend.py

View file
  • Ignore whitespace
 # Released under the terms of the 2-clause BSD license.
 import paludis, re
+from collections import namedtuple
 from gentoopm.basepm.depend import PMPackageDepSet, PMConditionalDep, \
 	PMAnyOfDep, PMAllOfDep, PMExactlyOneOfDep, PMBaseDep
 _block_re = re.compile('^!*')
 class PaludisBaseDep(PMBaseDep):
-	def __init__(self, deps, pkg):
+	def __init__(self, deps, args):
 		self._deps = deps
-		self._pkg = pkg
+		self._args = args
 	def __iter__(self):
 		for d in self._deps:
 			if isinstance(d, paludis.PackageDepSpec):
-				yield PaludisAtom(d, self._pkg._env)
+				yield PaludisAtom(d, self._args.env)
 			elif isinstance(d, paludis.BlockDepSpec):
-				yield PaludisAtom(d.blocking, self._pkg._env,
+				yield PaludisAtom(d.blocking, self._args.env,
 						block = _block_re.match(d.text).group(0))
 			elif isinstance(d, paludis.AnyDepSpec):
-				yield PaludisAnyOfDep(d, self._pkg)
+				yield PaludisAnyOfDep(d, self._args)
 			elif isinstance(d, paludis.AllDepSpec):
-				yield PaludisAllOfDep(d, self._pkg)
+				yield PaludisAllOfDep(d, self._args)
 			elif isinstance(d, paludis.ExactlyOneDepSpec):
-				yield PaludisExactlyOneOfDep(d, self._pkg)
+				yield PaludisExactlyOneOfDep(d, self._args)
 			elif isinstance(d, paludis.ConditionalDepSpec):
-				yield PaludisConditionalDep(d, self._pkg)
+				yield PaludisConditionalDep(d, self._args)
 			elif isinstance(d, paludis.PlainTextDepSpec):
 				# XXX: this is in REQUIRED_USE as well
 				yield str(d)
 class PaludisConditionalDep(PMConditionalDep, PaludisBaseDep):
 	def enabled(self):
-		return self._deps.condition_met(self._pkg._env, self._pkg._pkg)
+		return self._deps.condition_met(self._args.env, self._args.pkg)
+_argtuple = namedtuple('PaludisDepArgTuple', ('env', 'pkg', 'cls'))
 class PaludisPackageDepSet(PMPackageDepSet, PaludisAllOfDep):
-	pass
+	def __init__(self, deps, pkg, cls = None):
+		PaludisAllOfDep.__init__(self, deps, _argtuple(pkg._env, pkg._pkg, cls))