From: Zac Medico Date: Thu, 19 Jun 2008 05:26:49 +0000 (-0000) Subject: Pass a Package instance into LineCheck.new(), and use this to avoid X-Git-Tag: v2.2_rc1~6 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=b8f2743e6eb7377c410d2a36dec2f9fc908e1e9e;p=portage.git Pass a Package instance into LineCheck.new(), and use this to avoid passing the ebuild mtime into the EbuildHeader constructor (the mtime is given when the new() method is called). svn path=/main/trunk/; revision=10725 --- diff --git a/pym/repoman/checks.py b/pym/repoman/checks.py index afe5c8658..4b002568f 100644 --- a/pym/repoman/checks.py +++ b/pym/repoman/checks.py @@ -16,7 +16,7 @@ class LineCheck(object): """A regular expression to determine whether to ignore the line""" ignore_line = False - def new(self): + def new(self, pkg): pass def check(self, num, line): @@ -45,9 +45,10 @@ class EbuildHeader(LineCheck): gentoo_license = r'# Distributed under the terms of the GNU General Public License v2' cvs_header = re.compile(r'^#\s*\$Header.*\$$') - def __init__(self, st_mtime): - self.modification_year = str(time.gmtime(st_mtime)[0]) - self.gentoo_copyright_re = re.compile(self.gentoo_copyright % self.modification_year) + def new(self, pkg): + self.modification_year = str(time.gmtime(pkg.mtime)[0]) + self.gentoo_copyright_re = re.compile( + self.gentoo_copyright % self.modification_year) def check(self, num, line): if num > 2: @@ -232,7 +233,7 @@ class InheritAutotools(LineCheck): _autotools_func_re = re.compile(r'(^|\s)(' + \ "|".join(_autotools_funcs) + ')(\s|$)') - def new(self): + def new(self, pkg): self._inherit_autotools = None self._autotools_func_call = None @@ -256,7 +257,7 @@ class IUseUndefined(LineCheck): repoman_check_name = 'IUSE.undefined' _iuse_def_re = re.compile(r'^IUSE=.*') - def new(self): + def new(self, pkg): self._iuse_def = None def check(self, num, line): @@ -268,18 +269,17 @@ class IUseUndefined(LineCheck): yield 'IUSE is not defined' _constant_checks = tuple((c() for c in ( - EbuildWhitespace, EbuildQuote, + EbuildHeader, EbuildWhitespace, EbuildQuote, EbuildAssignment, EbuildUselessDodoc, EbuildUselessCdS, EbuildNestedDie, EbuildPatches, EbuildQuotedA, IUseUndefined, InheritAutotools))) def run_checks(contents, pkg): - checks = list(_constant_checks) - checks.append(EbuildHeader(pkg.mtime)) + checks = _constant_checks for lc in checks: - lc.new() + lc.new(pkg) for num, line in enumerate(contents): for lc in checks: ignore = lc.ignore_line