From ce5f914de66f8d6b658ad8585c482340b775a3db Mon Sep 17 00:00:00 2001 From: Sebastian Luther Date: Tue, 27 Jul 2010 10:55:46 +0200 Subject: [PATCH] portage.sets: Don't allow extended atoms unless explicitly told to --- pym/_emerge/depgraph.py | 2 +- pym/portage/sets/base.py | 16 ++++++++++++---- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/pym/_emerge/depgraph.py b/pym/_emerge/depgraph.py index 361a767c1..1c40088ae 100644 --- a/pym/_emerge/depgraph.py +++ b/pym/_emerge/depgraph.py @@ -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) diff --git a/pym/portage/sets/base.py b/pym/portage/sets/base.py index 33850574d..f54c5436f 100644 --- a/pym/portage/sets/base.py +++ b/pym/portage/sets/base.py @@ -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) -- 2.26.2