Add an Atom.evaluate_conditionals() method and use where appropriate.
authorZac Medico <zmedico@gentoo.org>
Thu, 28 Jan 2010 05:37:57 +0000 (05:37 -0000)
committerZac Medico <zmedico@gentoo.org>
Thu, 28 Jan 2010 05:37:57 +0000 (05:37 -0000)
svn path=/main/trunk/; revision=15212

bin/portageq
pym/portage/__init__.py
pym/portage/dep.py

index 342e19fd242449abf551eed6396fcce2976360f5..e02a9ddbb3a78027d0a18ec577f87304dd4755a3 100755 (executable)
@@ -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
 
 #-----------------------------------------------------------------------------
index 23e69cabfb65b90df6d5f29661ebb51b6a80d1f8..5f62fd7aee74fc5cd09f2b0eed01eabc531ab2c4 100644 (file)
@@ -7815,11 +7815,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/"):
index 70d95e4849d4bf049b39a933bd266cf61409d2a5..409bc93de6cbf043eb4a5e4f9d9543c3d09e37bc 100644 (file)
@@ -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