# HG changeset patch # User Pierre-Yves David # Date 2010-03-17 09:51:26 # Node ID fbcccf9ec58fb448cb3806b31d22379a4dc6fac0 # Parent 3be9ae49b62884ce8a91bae951f1ef55d679a554 check-code: add a return value to checkfile function The checkfile function returns True if the file is correct, False otherwise. diff --git a/contrib/check-code.py b/contrib/check-code.py --- a/contrib/check-code.py +++ b/contrib/check-code.py @@ -166,7 +166,10 @@ def checkfile(f, logfunc=_defaultlogger. logfunc(filename, linenumber, linecontent, errormessage) :maxerr: number of error to display before arborting. Set to None (default) to report all errors + + return True if no error is found, False otherwise. """ + result = True for name, match, filters, pats in checks: fc = 0 if not re.match(match, f): @@ -185,10 +188,12 @@ def checkfile(f, logfunc=_defaultlogger. if re.search(p, l[1]): logfunc(f, n+1, l[0], msg) fc += 1 + result = False if maxerr is not None and fc >= maxerr: print " (too many errors, giving up)" break break + return result if __name__ == "__main__":