summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2010-08-22 12:43:09 -0700
committerZac Medico <zmedico@gentoo.org>2010-08-22 12:43:09 -0700
commitc810b639133301f605eabb1c9644d05cc0ff515a (patch)
tree628a3831761514990d983df6fe84fcab4478bc0e
parent6bfbbbefc91069cb4244cf5a5462e6cef3cef3e6 (diff)
downloadportage-c810b639133301f605eabb1c9644d05cc0ff515a.tar.gz
portage-c810b639133301f605eabb1c9644d05cc0ff515a.tar.bz2
portage-c810b639133301f605eabb1c9644d05cc0ff515a.zip
Make InheritDeprecated check for direct inherits, and give line numbers
in error messages.
-rw-r--r--pym/repoman/checks.py42
1 files changed, 31 insertions, 11 deletions
diff --git a/pym/repoman/checks.py b/pym/repoman/checks.py
index f3ab6e4c2..41235c5fa 100644
--- a/pym/repoman/checks.py
+++ b/pym/repoman/checks.py
@@ -361,33 +361,53 @@ class ImplicitRuntimeDeps(LineCheck):
yield 'RDEPEND is not explicitly assigned'
class InheritDeprecated(LineCheck):
- """Check if ebuild inherits a deprecated eclass"""
+ """Check if ebuild directly inherits a deprecated eclass"""
repoman_check_name = 'inherit.deprecated'
- # deprecated eclass : new eclass (0 if no new eclass)
+ # deprecated eclass : new eclass (False if no new eclass)
deprecated_classes = {
"gems": "ruby-fakegem",
"php-pear": "php-pear-r1",
- "qt3": 0,
+ "qt3": False,
"qt4": "qt4-r2",
"ruby": "ruby-ng",
"ruby-gnome2": "ruby-ng-gnome2"
}
+ _inherit_re = re.compile(r'^\s*inherit\s(.*)$')
+
def new(self, pkg):
- self.matched_eclasses = frozenset(self.deprecated_classes.keys()).intersection(pkg.inherited)
+ self._errors = []
def check(self, num, line):
- pass
- def end(self):
- for i in self.matched_eclasses:
- if self.deprecated_classes[i] == 0:
- yield i + ": deprecated eclass"
+ direct_inherits = None
+ m = self._inherit_re.match(line)
+ if m is not None:
+ direct_inherits = m.group(1)
+ if direct_inherits:
+ direct_inherits = direct_inherits.split()
+
+ if not direct_inherits:
+ return
+
+ for eclass in direct_inherits:
+ replacement = self.deprecated_classes.get(eclass)
+ if replacement is None:
+ pass
+ elif replacement is False:
+ self._errors.append("please migrate from " + \
+ "'%s' (no replacement) on line: %d" % (eclass, num + 1))
else:
- yield "uses deprecated eclass '"+ i +"'. please migrate to '"+ \
- self.deprecated_classes[i] +"'"
+ self._errors.append("please migrate from " + \
+ "'%s' to '%s' on line: %d" % \
+ (eclass, replacement, num + 1))
+
+ def end(self):
+ for error in self._errors:
+ yield error
+ del self._errors
class InheritAutotools(LineCheck):
"""