diff options
author | Zac Medico <zmedico@gentoo.org> | 2007-11-10 03:12:09 +0000 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2007-11-10 03:12:09 +0000 |
commit | 219ea251208f4ffa1e7eca9fd815c8c66c3499f5 (patch) | |
tree | e47bd5204162d816180548825d294b8285d96b7a /bin | |
parent | 1a1aaa3afc700631237067da68bc41e257013cd7 (diff) | |
download | portage-219ea251208f4ffa1e7eca9fd815c8c66c3499f5.tar.gz portage-219ea251208f4ffa1e7eca9fd815c8c66c3499f5.tar.bz2 portage-219ea251208f4ffa1e7eca9fd815c8c66c3499f5.zip |
Convert all the checks in repoman.checks to use a new LineCheck
interface that takes a single line as an argument. This has at
least a few of benefits:
* Eliminates lots of redundant code
* Error messages are ordered by line number across all checks
The performance is slightly worse due to the increased number
of method calls, but it's not really noticeable in comparison
to the time consumed by dependency checks.
Thanks to Petteri Räty <betelgeuse@gentoo.org> for the initial
patch which I only made a few minor modifications to.
svn path=/main/trunk/; revision=8483
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/repoman | 39 |
1 files changed, 9 insertions, 30 deletions
diff --git a/bin/repoman b/bin/repoman index 85d27d20a..ca7530b9f 100755 --- a/bin/repoman +++ b/bin/repoman @@ -24,7 +24,7 @@ from commands import getstatusoutput from fileinput import input from grp import getgrnam from itertools import izip -from stat import S_ISDIR, ST_CTIME, ST_GID, ST_MTIME +from stat import S_ISDIR, ST_CTIME try: import cPickle as pickle @@ -44,13 +44,11 @@ except ImportError: del os.environ["PORTAGE_LEGACY_GLOBALS"] try: - from repoman.checks import EbuildWhitespace, EbuildHeader, EbuildQuote, \ - EbuildAssignment, EbuildNestedDie, EbuildUselessDodoc, EbuildUselessCdS + from repoman.checks import run_checks except ImportError: from os import path as osp sys.path.insert(0, osp.join(osp.dirname(osp.dirname(osp.realpath(__file__))), 'pym')) - from repoman.checks import EbuildWhitespace, EbuildHeader, EbuildQuote, \ - EbuildAssignment, EbuildNestedDie, EbuildUselessDodoc, EbuildUselessCdS + from repoman.checks import run_checks import portage.checksum import portage.const @@ -1364,35 +1362,16 @@ for x in scanlist: for mybad in mybadrestrict: fails["RESTRICT.invalid"].append(x+"/"+y+".ebuild: %s" % mybad) # Syntax Checks - path = checkdir + '/' + y + '.ebuild' - myear = time.gmtime(os.stat(path)[ST_MTIME])[0] - f = open(path, 'rb') + relative_path = os.path.join(x, y + ".ebuild") + full_path = os.path.join(repodir, relative_path) + f = open(full_path, 'rb') try: - contents = f.readlines() + for check_name, e in run_checks(f, os.stat(full_path).st_mtime): + stats[check_name] += 1 + fails[check_name].append(relative_path + ': %s' % e) finally: f.close() del f - for check in (EbuildWhitespace, EbuildQuote, - EbuildAssignment, EbuildUselessDodoc, EbuildUselessCdS): - c = check(contents) - errors = c.Run() - for e in errors: - stats[c.repoman_check_name] += 1 - fails[c.repoman_check_name].append(x + '/' + y + '.ebuild: %s' % e[1] % e[0]) - del check - check = EbuildHeader(contents, str(myear)) - errors = check.Run() - for e in errors: - stats[check.repoman_check_name] += 1 - fails[check.repoman_check_name].append(x + '/' + y + '.ebuild: %s' % e[1] % e[0]) - del check - check = EbuildNestedDie(contents) - errors = check.Run() - for e in errors: - stats[check.repoman_check_name] += 1 - fails[check.repoman_check_name].append( - x + '/' + y + '.ebuild: %s' % e[1] % e[0]) - del check, errors, path, contents, myear if options.force: # The dep_check() calls are the most expensive QA test. If --force |