diff options
author | Sebastian Luther <SebastianLuther@gmx.de> | 2010-09-21 08:41:39 +0200 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2010-09-20 23:51:29 -0700 |
commit | ab65fe02da2de2c619a66402e93e63043979d2c5 (patch) | |
tree | 44c78c1e5a1e641174164746ce6896a15e3bb188 | |
parent | Fix default() and default_src_install() definitions to account for (diff) | |
download | portage-ab65fe02da2de2c619a66402e93e63043979d2c5.tar.gz portage-ab65fe02da2de2c619a66402e93e63043979d2c5.tar.bz2 portage-ab65fe02da2de2c619a66402e93e63043979d2c5.zip |
reposyntax: Add support in _sets/base.py
-rw-r--r-- | pym/portage/_sets/base.py | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/pym/portage/_sets/base.py b/pym/portage/_sets/base.py index cd9c08d32..b3bb06b4c 100644 --- a/pym/portage/_sets/base.py +++ b/pym/portage/_sets/base.py @@ -19,7 +19,7 @@ class PackageSet(object): _operations = ["merge"] description = "generic package set" - def __init__(self): + def __init__(self, allow_wildcard=False, allow_repo=False): self._atoms = set() self._atommap = ExtendedAtomDict(set) self._loaded = False @@ -27,6 +27,8 @@ class PackageSet(object): self.errors = [] self._nonatoms = set() self.world_candidate = False + self._allow_wildcard = allow_wildcard + self._allow_repo = allow_repo def __contains__(self, atom): self._load() @@ -66,7 +68,7 @@ class PackageSet(object): self._load() return self._nonatoms.copy() - def _setAtoms(self, atoms, allow_wildcard=False): + def _setAtoms(self, atoms): self._atoms.clear() self._nonatoms.clear() for a in atoms: @@ -76,12 +78,14 @@ class PackageSet(object): if not a: continue try: - a = Atom(a, allow_wildcard=True) + a = Atom(a, allow_wildcard=True, allow_repo=True) except InvalidAtom: self._nonatoms.add(a) continue - if not allow_wildcard and a.extended_syntax: + if not self._allow_wildcard and a.extended_syntax: raise InvalidAtom("extended atom syntax not allowed here") + if not self._allow_repo and a.repo: + raise InvalidAtom("repository specification not allowed here") self._atoms.add(a) self._updateAtomMap() @@ -131,7 +135,7 @@ class PackageSet(object): if atom.cp == pkg.cp: rev_transform[atom] = atom else: - rev_transform[Atom(atom.replace(atom.cp, pkg.cp, 1), allow_wildcard=True)] = atom + rev_transform[Atom(atom.replace(atom.cp, pkg.cp, 1), allow_wildcard=True, allow_repo=True)] = atom best_match = best_match_to_list(pkg, iter(rev_transform)) if best_match: return rev_transform[best_match] @@ -170,9 +174,8 @@ class PackageSet(object): class EditablePackageSet(PackageSet): - def __init__(self, allow_wildcard=False): - super(EditablePackageSet, self).__init__() - self._allow_wildcard = allow_wildcard + def __init__(self, allow_wildcard=False, allow_repo=False): + super(EditablePackageSet, self).__init__(allow_wildcard=allow_wildcard, allow_repo=allow_repo) def update(self, atoms): self._load() @@ -181,13 +184,15 @@ class EditablePackageSet(PackageSet): for a in atoms: if not isinstance(a, Atom): try: - a = Atom(a, allow_wildcard=True) + a = Atom(a, allow_wildcard=True, allow_repo=True) except InvalidAtom: modified = True self._nonatoms.add(a) continue if not self._allow_wildcard and a.extended_syntax: raise InvalidAtom("extended atom syntax not allowed here") + if not self._allow_repo and a.repo: + raise InvalidAtom("repository specification not allowed here") normal_atoms.append(a) if normal_atoms: @@ -201,7 +206,7 @@ class EditablePackageSet(PackageSet): self.update([atom]) def replace(self, atoms): - self._setAtoms(atoms, allow_wildcard=self._allow_wildcard) + self._setAtoms(atoms) self.write() def remove(self, atom): @@ -223,8 +228,8 @@ class EditablePackageSet(PackageSet): raise NotImplementedError() class InternalPackageSet(EditablePackageSet): - def __init__(self, initial_atoms=None, allow_wildcard=False): - super(InternalPackageSet, self).__init__(allow_wildcard=allow_wildcard) + def __init__(self, initial_atoms=None, allow_wildcard=False, allow_repo=False): + super(InternalPackageSet, self).__init__(allow_wildcard=allow_wildcard, allow_repo=allow_repo) if initial_atoms != None: self.update(initial_atoms) |