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

svn path=/main/branches/2.1.2/; revision=10414

bin/emerge

index 47c095e8983ef124e875be2f8e63e9f3e52e652b..13cdb01c9bd741a7b3ca0d6aba3babdd1c5f455c 100755 (executable)
@@ -782,22 +782,30 @@ class SetConfig(object):
 class InternalPackageSet(object):
        def __init__(self, initial_atoms=None):
                self._atoms = {}
+               self._nonatoms = set()
                if initial_atoms:
                        self.update(initial_atoms)
        def clear(self):
                self._atoms.clear()
+               self._nonatoms.clear()
        def add(self, atom):
-               cp = portage.dep_getkey(atom)
-               cp_list = self._atoms.get(cp)
+               try:
+                       atom = portage_dep.Atom(atom)
+               except portage_dep.InvalidAtom:
+                       self._nonatoms.add(atom)
+                       return
+               cp_list = self._atoms.get(atom.cp)
                if cp_list is None:
                        cp_list = []
-                       self._atoms[cp] = cp_list
+                       self._atoms[atom.cp] = cp_list
                if atom not in cp_list:
                        cp_list.append(atom)
        def update(self, atoms):
                for atom in atoms:
                        self.add(atom)
        def __contains__(self, atom):
+               if atom in self._nonatoms:
+                       return True
                cp = portage.dep_getkey(atom)
                if cp in self._atoms and atom in self._atoms[cp]:
                        return True
@@ -1475,13 +1483,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):