summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2008-05-25 08:04:21 +0000
committerZac Medico <zmedico@gentoo.org>2008-05-25 08:04:21 +0000
commitdbc01eb720e8fcddf5fb38cde54ca4fc41790a92 (patch)
treee4f92b94cfc8a5cc5fb1ac3421f2f2092d4821d4
parentb855427f21b002435b486327577d512cadd402d5 (diff)
downloadportage-dbc01eb720e8fcddf5fb38cde54ca4fc41790a92.tar.gz
portage-dbc01eb720e8fcddf5fb38cde54ca4fc41790a92.tar.bz2
portage-dbc01eb720e8fcddf5fb38cde54ca4fc41790a92.zip
Facilitate creation of Atom instances in a few obvious places:
* PackageSet._setAtoms() * AtomArg and PackageArg constructors. svn path=/main/trunk/; revision=10413
-rw-r--r--pym/_emerge/__init__.py4
-rw-r--r--pym/portage/sets/base.py17
2 files changed, 12 insertions, 9 deletions
diff --git a/pym/_emerge/__init__.py b/pym/_emerge/__init__.py
index c9ab97722..155f5ea6d 100644
--- a/pym/_emerge/__init__.py
+++ b/pym/_emerge/__init__.py
@@ -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):
diff --git a/pym/portage/sets/base.py b/pym/portage/sets/base.py
index 71547813e..e88aca26e 100644
--- a/pym/portage/sets/base.py
+++ b/pym/portage/sets/base.py
@@ -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):