summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2010-01-29 18:52:04 +0000
committerZac Medico <zmedico@gentoo.org>2010-01-29 18:52:04 +0000
commita613a634821cdd2bf9f4846c3ebf42b5158f27d0 (patch)
treecd7d3a6d6a3f7ee729760b1f0fbb1f87961a307d
parent3dec70f6e1c7dcf1b345ea6faffc26e12b0daac6 (diff)
downloadportage-a613a634821cdd2bf9f4846c3ebf42b5158f27d0.tar.gz
portage-a613a634821cdd2bf9f4846c3ebf42b5158f27d0.tar.bz2
portage-a613a634821cdd2bf9f4846c3ebf42b5158f27d0.zip
Add an Atom.evaluate_conditionals() method and use where appropriate.
(trunk r15212) svn path=/main/branches/2.1.7/; revision=15263
-rwxr-xr-xbin/portageq6
-rw-r--r--pym/portage/__init__.py6
-rw-r--r--pym/portage/dep.py16
3 files changed, 18 insertions, 10 deletions
diff --git a/bin/portageq b/bin/portageq
index 9fbf3c9bc..909876cc8 100755
--- a/bin/portageq
+++ b/bin/portageq
@@ -49,11 +49,7 @@ from portage.util import writemsg, writemsg_stdout
def eval_atom_use(atom):
if atom.use.conditional and 'USE' in os.environ:
use = os.environ['USE'].split()
- evaluated_atom = portage.dep.remove_slot(atom)
- if atom.slot:
- evaluated_atom += ":%s" % atom.slot
- evaluated_atom += str(atom.use.evaluate_conditionals(use))
- atom = portage.dep.Atom(evaluated_atom)
+ atom = atom.evaluate_conditionals(use)
return atom
#-----------------------------------------------------------------------------
diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py
index d9a82bc83..8ee7fb3a2 100644
--- a/pym/portage/__init__.py
+++ b/pym/portage/__init__.py
@@ -7812,11 +7812,7 @@ def _expand_new_virtuals(mysplit, edebug, mydbapi, mysettings, myroot="/",
if not repoman and \
myuse is not None and isinstance(x, portage.dep.Atom) and x.use:
if x.use.conditional:
- evaluated_atom = portage.dep.remove_slot(x)
- if x.slot:
- evaluated_atom += ":%s" % x.slot
- evaluated_atom += str(x.use.evaluate_conditionals(myuse))
- x = portage.dep.Atom(evaluated_atom)
+ x = x.evaluate_conditionals(myuse)
mykey = x.cp
if not mykey.startswith("virtual/"):
diff --git a/pym/portage/dep.py b/pym/portage/dep.py
index 70d95e484..409bc93de 100644
--- a/pym/portage/dep.py
+++ b/pym/portage/dep.py
@@ -612,6 +612,22 @@ class Atom(_atom_base):
return False
+ def evaluate_conditionals(self, use):
+ """
+ Create an atom instance with any USE conditionals evaluated.
+ @param use: The set of enabled USE flags
+ @type other: set
+ @rtype: Atom
+ @return: an atom instance with any USE conditionals evaluated
+ """
+ if not self.use.conditional:
+ return self
+ atom = remove_slot(self)
+ if self.slot:
+ atom += ":%s" % self.slot
+ atom += str(self.use.evaluate_conditionals(use))
+ return Atom(atom)
+
def __copy__(self):
"""Immutable, so returns self."""
return self