comparison contrib/check-code.py @ 10718:f18c37fd624f

check-code: Add a ``maxerr`` argument to the ``checkfile`` function check-code.py used to halt after 15 errors. This changeset adds a new argument to the checkfile function to control this limit.
author Pierre-Yves David <pierre-yves.david@logilab.fr>
date Tue, 16 Mar 2010 19:52:58 +0100
parents b1f4fcef99b3
children 3be9ae49b628
comparison
equal deleted inserted replaced
10717:b1f4fcef99b3 10718:f18c37fd624f
131 checks = [ 131 checks = [
132 ('python', r'.*\.(py|cgi)$', pyfilters, pypats), 132 ('python', r'.*\.(py|cgi)$', pyfilters, pypats),
133 ('test script', r'(.*/)?test-[^.~]*$', testfilters, testpats), 133 ('test script', r'(.*/)?test-[^.~]*$', testfilters, testpats),
134 ('c', r'.*\.c$', cfilters, cpats), 134 ('c', r'.*\.c$', cfilters, cpats),
135 ] 135 ]
136 def checkfile(f): 136 def checkfile(f, maxerr=None):
137 """checks style and portability of a given file""" 137 """checks style and portability of a given file"""
138 for name, match, filters, pats in checks: 138 for name, match, filters, pats in checks:
139 fc = 0 139 fc = 0
140 if not re.match(match, f): 140 if not re.match(match, f):
141 continue 141 continue
156 print "%s:%d:" % (f, n + 1) 156 print "%s:%d:" % (f, n + 1)
157 print " > %s" % l[0] 157 print " > %s" % l[0]
158 print " %s" % msg 158 print " %s" % msg
159 lc += 1 159 lc += 1
160 fc += 1 160 fc += 1
161 if fc == 15: 161 if maxerr is not None and fc >= maxerr:
162 print " (too many errors, giving up)" 162 print " (too many errors, giving up)"
163 break 163 break
164 break 164 break
165 165
166 166
169 check = glob.glob("*") 169 check = glob.glob("*")
170 else: 170 else:
171 check = sys.argv[1:] 171 check = sys.argv[1:]
172 172
173 for f in check: 173 for f in check:
174 checkfile(f) 174 checkfile(f, maxerr=15)