예제 #1
0
    def _setAtoms(self, atoms):
        self._atoms.clear()
        self._nonatoms.clear()
        for a in atoms:
            if not isinstance(a, Atom):
                if isinstance(a, basestring):
                    a = a.strip()
                if not a:
                    continue
                try:
                    a = Atom(a, allow_wildcard=True, allow_repo=True)
                except InvalidAtom:
                    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")
            self._atoms.add(a)

        self._updateAtomMap()
예제 #2
0
    def update(self, atoms):
        self._load()
        modified = False
        normal_atoms = []
        for a in atoms:
            if not isinstance(a, Atom):
                try:
                    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:
            modified = True
            self._atoms.update(normal_atoms)
            self._updateAtomMap(atoms=normal_atoms)
        if modified:
            self.write()
예제 #3
0
def parse_actions(args,
                  dbapi,
                  cache,
                  quiet=False,
                  strict=False,
                  cleanupact=[],
                  dataout=sys.stdout,
                  output=sys.stderr):
    out = []
    actset = ActionSet(cache=cache)

    for i, a in enumerate(args):
        if not a:
            continue
        try:
            try:
                act = Action(a, output=dataout)
            except NotAnAction:
                try:
                    atom = dep_expand(a, mydb=dbapi, settings=dbapi.settings)
                    if atom.startswith('null/'):
                        raise InvalidAtom(atom)
                except AmbiguousPackageName as e:
                    raise ParserError('ambiguous package name, matching: %s' %
                                      e)
                except InvalidAtom as e:
                    try:
                        try:
                            atom = Atom(a, allow_wildcard=True)
                        except TypeError:
                            atom = Atom(a)
                    except InvalidAtom as e:
                        raise ParserError('invalid package atom: %s' % e)
                actset.append(atom)
            except ParserWarning as w:
                actset.append(act)
                raise
            else:
                actset.append(act)
        except ParserError as e:
            output.write('At argv[%d]=\'%s\': %s\n' % (i + 1, a, e))
            output.write('Aborting.\n')
            return None
        except ParserWarning as e:
            if not quiet or strict:
                output.write('At argv[%d]=\'%s\': %s\n' % (i + 1, a, e))
            if strict:
                output.write('Strict mode, aborting.\n')
                return None

    if actset:
        out.append(actset)

    if cleanupact:
        raise NotImplementedError(
            'Cleanup actions are currently disabled due to missing wildcard support'
        )

        actset = ActionSet(cache=cache)
        for a in cleanupact:
            actset.append(a(dbapi))
        out.append(actset)

    return out