portage.sets: Don't allow extended atoms unless explicitly told to
authorSebastian Luther <SebastianLuther@gmx.de>
Tue, 27 Jul 2010 08:55:46 +0000 (10:55 +0200)
committerZac Medico <zmedico@gentoo.org>
Tue, 27 Jul 2010 19:01:23 +0000 (12:01 -0700)
pym/_emerge/depgraph.py
pym/portage/sets/base.py

index 361a767c1a1ebf5f856584e9fa55cb368f1ed1d4..1c40088ae163251a26efc2b479ef3963fca1855d 100644 (file)
@@ -94,7 +94,7 @@ class _frozen_depgraph_config(object):
 
                self._required_set_names = set(["world"])
 
-               self.excluded_pkgs = InternalPackageSet()
+               self.excluded_pkgs = InternalPackageSet(allow_wildcard=True)
                for x in ' '.join(myopts.get("--exclude", [])).split():
                        try:
                                x = Atom(x, allow_wildcard=True)
index 33850574d4751711da9bf413bf29035417a69a71..f54c5436f5d775521d6cac70a360a7bd44de192c 100644 (file)
@@ -66,7 +66,7 @@ class PackageSet(object):
                self._load()
                return self._nonatoms.copy()
 
-       def _setAtoms(self, atoms):
+       def _setAtoms(self, atoms, allow_wildcard=False):
                self._atoms.clear()
                self._nonatoms.clear()
                for a in atoms:
@@ -80,6 +80,8 @@ class PackageSet(object):
                                except InvalidAtom:
                                        self._nonatoms.add(a)
                                        continue
+                       if not allow_wildcard and a.extended_syntax:
+                               raise InvalidAtom("extended atom syntax not allowed here")
                        self._atoms.add(a)
 
                self._updateAtomMap()
@@ -164,6 +166,10 @@ class PackageSet(object):
 
 class EditablePackageSet(PackageSet):
 
+       def __init__(self, allow_wildcard=False):
+               super(EditablePackageSet, self).__init__()
+               self._allow_wildcard = allow_wildcard
+               
        def update(self, atoms):
                self._load()
                modified = False
@@ -176,6 +182,8 @@ class EditablePackageSet(PackageSet):
                                        modified = True
                                        self._nonatoms.add(a)
                                        continue
+                       if not self._allow_wildcard and a.extended_syntax:
+                               raise InvalidAtom("extended atom syntax not allowed here")
                        normal_atoms.append(a)
 
                if normal_atoms:
@@ -189,7 +197,7 @@ class EditablePackageSet(PackageSet):
                self.update([atom])
 
        def replace(self, atoms):
-               self._setAtoms(atoms)
+               self._setAtoms(atoms, allow_wildcard=self._allow_wildcard)
                self.write()
 
        def remove(self, atom):
@@ -211,8 +219,8 @@ class EditablePackageSet(PackageSet):
                raise NotImplementedError()
 
 class InternalPackageSet(EditablePackageSet):
-       def __init__(self, initial_atoms=None):
-               super(InternalPackageSet, self).__init__()
+       def __init__(self, initial_atoms=None, allow_wildcard=False):
+               super(InternalPackageSet, self).__init__(allow_wildcard=allow_wildcard)
                if initial_atoms != None:
                        self.update(initial_atoms)