From dbc01eb720e8fcddf5fb38cde54ca4fc41790a92 Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Sun, 25 May 2008 08:04:21 +0000 Subject: [PATCH] Facilitate creation of Atom instances in a few obvious places: * PackageSet._setAtoms() * AtomArg and PackageArg constructors. svn path=/main/trunk/; revision=10413 --- pym/_emerge/__init__.py | 4 +++- pym/portage/sets/base.py | 17 +++++++++-------- 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): -- 2.26.2