Make the Atom class add 'EAPI.incompatible' category attributes to
authorZac Medico <zmedico@gentoo.org>
Thu, 26 Aug 2010 21:29:34 +0000 (14:29 -0700)
committerZac Medico <zmedico@gentoo.org>
Thu, 26 Aug 2010 21:29:34 +0000 (14:29 -0700)
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
pym/_emerge/Package.py
pym/portage/dep/__init__.py
pym/portage/exception.py

index 1ad5b28b2b099140e8a17676293869842eae2535..708ef707907c47a2bc2578c1ed1dbc091549db38 100755 (executable)
@@ -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":
index e361c28be812563bede7ec7f74a754978c5c2788..b6f2d585a21407d35a7e116491b49ece025d6f93 100644 (file)
@@ -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)
index 8a31b3f6d48e7baa8b021d5774a7d8406216a261..55dd822c196014d34b53a50a82e924668e154a60 100644 (file)
@@ -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",
index f8388e2b6056350e918e7b5e26b43eeffeea80c6..b289b6285dc2a23199d0943452f1e388d3618704 100644 (file)
@@ -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"""