From bf9b3e70758454afa53972340abc98a248195e45 Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Thu, 26 Aug 2010 14:29:34 -0700 Subject: Make the Atom class add 'EAPI.incompatible' category attributes to InvalidAtom exceptions, make use_reduce() raise InvalidDependString exceptions that encapsulate InvalidAtom exceptions, and make Package._validate_deps() use the InvalidAtom categories when recording the invalid metadata for use by repoman. Also, remove the EAPI.incompatible code from repoman that's no longer used. --- bin/repoman | 27 --------------------------- pym/_emerge/Package.py | 13 ++++++++++++- pym/portage/dep/__init__.py | 21 ++++++++++++++++----- pym/portage/exception.py | 6 ++++++ 4 files changed, 34 insertions(+), 33 deletions(-) diff --git a/bin/repoman b/bin/repoman index 1ad5b28b2..708ef7079 100755 --- a/bin/repoman +++ b/bin/repoman @@ -1652,33 +1652,6 @@ for x in scanlist: stats[mytype + '.suspect'] += 1 fails[mytype + '.suspect'].append( relative_path + ": '%s'" % atom) - if not eapi_has_slot_deps(eapi): - if portage.dep.dep_getslot(atom): - stats['EAPI.incompatible'] += 1 - fails['EAPI.incompatible'].append( - (relative_path + ": %s slot dependency" + \ - " not supported with EAPI='%s':" + \ - " '%s'") % (mytype, eapi, atom)) - if atom.use and not eapi_has_use_deps(eapi): - stats['EAPI.incompatible'] += 1 - fails['EAPI.incompatible'].append( - (relative_path + ": %s use dependency" + \ - " not supported with EAPI='%s':" + \ - " '%s'") % (mytype, eapi, atom)) - if atom.use and (atom.use.missing_enabled or atom.use.missing_disabled) and \ - not eapi_has_use_dep_defaults(eapi): - stats['EAPI.incompatible'] += 1 - fails['EAPI.incompatible'].append( - (relative_path + ": %s use dependency" + \ - " not supported with EAPI='%s':" + \ - " '%s'") % (mytype, eapi, atom)) - if atom.blocker and atom.blocker.overlap.forbid \ - and not eapi_has_strong_blocks(eapi): - stats['EAPI.incompatible'] += 1 - fails['EAPI.incompatible'].append( - (relative_path + ": %s new blocker syntax" + \ - " not supported with EAPI='%s':" + \ - " '%s'") % (mytype, eapi, atom)) if atom.operator == "~" and \ portage.versions.catpkgsplit(atom.cpv)[3] != "r0": diff --git a/pym/_emerge/Package.py b/pym/_emerge/Package.py index e361c28be..b6f2d585a 100644 --- a/pym/_emerge/Package.py +++ b/pym/_emerge/Package.py @@ -76,7 +76,18 @@ class Package(Task): use_reduce(v, eapi=eapi, is_valid_flag=self.iuse.is_valid_flag, token_class=Atom) except portage.exception.InvalidDependString as e: - self._invalid_metadata(k + ".syntax", "%s: %s" % (k, e)) + categorized_error = False + if e.errors: + for error in e.errors: + if getattr(error, 'category', None) is None: + continue + categorized_error = True + self._invalid_metadata(error.category, + "%s: %s" % (k, error)) + + if not categorized_error: + self._invalid_metadata(k + ".syntax", + "%s: %s" % (k, e)) k = 'REQUIRED_USE' v = self.metadata.get(k) diff --git a/pym/portage/dep/__init__.py b/pym/portage/dep/__init__.py index 8a31b3f6d..55dd822c1 100644 --- a/pym/portage/dep/__init__.py +++ b/pym/portage/dep/__init__.py @@ -481,7 +481,10 @@ def use_reduce(depstr, uselist=[], masklist=[], matchall=False, excludeall=[], i token = token_class(token, eapi=eapi) except InvalidAtom as e: raise portage.exception.InvalidDependString( - _("Invalid atom (%s) in '%s', token %s") % (e, depstr, pos+1)) + _("Invalid atom (%s) in '%s', token %s") \ + % (e, depstr, pos+1), errors=(e,)) + except SystemExit: + raise except Exception as e: raise portage.exception.InvalidDependString( _("Invalid token '%s' in '%s', token %s") % (token, depstr, pos+1)) @@ -1049,15 +1052,23 @@ class Atom(_atom_base): if eapi is not None: if self.slot and not eapi_has_slot_deps(eapi): - raise InvalidAtom("Slot deps are not allowed in EAPI %s: '%s'" % (eapi, self)) + raise InvalidAtom( + _("Slot deps are not allowed in EAPI %s: '%s'") \ + % (eapi, self), category='EAPI.incompatible') if self.use: if not eapi_has_use_deps(eapi): - raise InvalidAtom("Use deps are not allowed in EAPI %s: '%s'" % (eapi, self)) + raise InvalidAtom( + _("Use deps are not allowed in EAPI %s: '%s'") \ + % (eapi, self), category='EAPI.incompatible') elif not eapi_has_use_dep_defaults(eapi) and \ (self.use.missing_enabled or self.use.missing_disabled): - raise InvalidAtom("Use dep defaults are not allowed in EAPI %s: '%s'" % (eapi, self)) + raise InvalidAtom( + _("Use dep defaults are not allowed in EAPI %s: '%s'") \ + % (eapi, self), category='EAPI.incompatible') if self.blocker and self.blocker.overlap.forbid and not eapi_has_strong_blocks(eapi): - raise InvalidAtom("Strong blocks are not allowed in EAPI %s: '%s'" % (eapi, self)) + raise InvalidAtom( + _("Strong blocks are not allowed in EAPI %s: '%s'") \ + % (eapi, self), category='EAPI.incompatible') def __setattr__(self, name, value): raise AttributeError("Atom instances are immutable", diff --git a/pym/portage/exception.py b/pym/portage/exception.py index f8388e2b6..b289b6285 100644 --- a/pym/portage/exception.py +++ b/pym/portage/exception.py @@ -31,6 +31,9 @@ class CorruptionError(PortageException): class InvalidDependString(PortageException): """An invalid depend string has been encountered""" + def __init__(self, value, errors=None): + PortageException.__init__(self, value) + self.errors = errors class InvalidVersionString(PortageException): """An invalid version string has been encountered""" @@ -102,6 +105,9 @@ class InvalidPackageName(PortagePackageException): class InvalidAtom(PortagePackageException): """Malformed atom spec""" + def __init__(self, value, category=None): + PortagePackageException.__init__(self, value) + self.category = category class UnsupportedAPIException(PortagePackageException): """Unsupported API""" -- cgit v1.2.3-1-g7c22