From: Zac Medico Date: Sun, 22 Aug 2010 19:43:09 +0000 (-0700) Subject: Make InheritDeprecated check for direct inherits, and give line numbers X-Git-Tag: v2.2_rc68~20 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=c810b639133301f605eabb1c9644d05cc0ff515a;p=portage.git Make InheritDeprecated check for direct inherits, and give line numbers in error messages. --- 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): """