comparison contrib/check-code.py @ 19308:84faaacbd3fa

check-code: compile all patterns on initialisation They where compiled once for every checked file (when calling finditer).
author Simon Heimberg <simohe@besonet.ch>
date Sat, 08 Jun 2013 20:20:14 +0200
parents 5443d40d524b
children 7d77fa1cd537
comparison
equal deleted inserted replaced
19307:5443d40d524b 19308:84faaacbd3fa
328 p = re.sub(r'(?<!\\)\\s', r'[ \\t]', p) 328 p = re.sub(r'(?<!\\)\\s', r'[ \\t]', p)
329 # [^...] doesn't match newline 329 # [^...] doesn't match newline
330 p = re.sub(r'(?<!\\)\[\^', r'[^\\n', p) 330 p = re.sub(r'(?<!\\)\[\^', r'[^\\n', p)
331 331
332 #print po, '=>', p 332 #print po, '=>', p
333 pats[i] = (p,) + pseq[1:] 333 pats[i] = (re.compile(p, re.MULTILINE),) + pseq[1:]
334 _preparepats() 334 _preparepats()
335 335
336 class norepeatlogger(object): 336 class norepeatlogger(object):
337 def __init__(self): 337 def __init__(self):
338 self._lastseen = None 338 self._lastseen = None
419 p, msg = pat 419 p, msg = pat
420 ignore = None 420 ignore = None
421 421
422 pos = 0 422 pos = 0
423 n = 0 423 n = 0
424 for m in re.finditer(p, post, re.MULTILINE): 424 for m in p.finditer(post):
425 if prelines is None: 425 if prelines is None:
426 prelines = pre.splitlines() 426 prelines = pre.splitlines()
427 postlines = post.splitlines(True) 427 postlines = post.splitlines(True)
428 428
429 start = m.start() 429 start = m.start()