Facilitate creation of Atom instances in a few obvious places:
authorZac Medico <zmedico@gentoo.org>
Sun, 25 May 2008 08:04:21 +0000 (08:04 -0000)
committerZac Medico <zmedico@gentoo.org>
Sun, 25 May 2008 08:04:21 +0000 (08:04 -0000)
 * PackageSet._setAtoms()
 * AtomArg and PackageArg constructors.

svn path=/main/trunk/; revision=10413

pym/_emerge/__init__.py
pym/portage/sets/base.py

index c9ab97722eb6aac6439840228dc0fdf1fc756103..155f5ea6d1e135388fff62a0c82f37e2c4d878b0 100644 (file)
@@ -1333,13 +1333,15 @@ class AtomArg(DependencyArg):
        def __init__(self, atom=None, **kwargs):
                DependencyArg.__init__(self, **kwargs)
                self.atom = atom
+               if not isinstance(self.atom, portage.dep.Atom):
+                       self.atom = portage.dep.Atom(self.atom)
                self.set = (self.atom, )
 
 class PackageArg(DependencyArg):
        def __init__(self, package=None, **kwargs):
                DependencyArg.__init__(self, **kwargs)
                self.package = package
-               self.atom = "=" + package.cpv
+               self.atom = portage.dep.Atom("=" + package.cpv)
                self.set = (self.atom, )
 
 class SetArg(DependencyArg):
index 71547813e37bb135a3d19cb11fdc0d3d7b87764a..e88aca26e2781e03d9d5817e53f0c0352800c1ce 100644 (file)
@@ -3,7 +3,7 @@
 # $Id$
 
 from portage import cpv_getkey, flatten
-from portage.dep import isvalidatom, match_from_list, \
+from portage.dep import Atom, isvalidatom, match_from_list, \
      best_match_to_list, dep_getkey, use_reduce, paren_reduce
 from portage.exception import InvalidAtom
 
@@ -58,15 +58,16 @@ class PackageSet(object):
                return self._nonatoms.copy()
 
        def _setAtoms(self, atoms):
-               atoms = map(str.strip, atoms)
+               self._atoms.clear()
                self._nonatoms.clear()
-               for a in atoms[:]:
-                       if a == "":
-                               atoms.remove(a)
-                       elif not isvalidatom(a):
-                               atoms.remove(a)
+               for a in atoms:
+                       a = a.strip()
+                       if not a:
+                               continue
+                       try:
+                               self._atoms.add(Atom(a))
+                       except InvalidAtom:
                                self._nonatoms.add(a)
-               self._atoms = set(atoms)
                self._updateAtomMap()
 
        def load(self):