comparison contrib/check-code.py @ 19999:169cb9e47f8e stable

check-code: more replacement characters for finding '.. note::' (even) more exact by using more characters: replace '.' with 'p' and ':' with 'q'
author Simon Heimberg <simohe@besonet.ch>
date Tue, 05 Nov 2013 09:00:31 +0100
parents 289bbb294e82
children 22154ec6fb8b
comparison
equal deleted inserted replaced
19998:289bbb294e82 19999:169cb9e47f8e
24 except re2.error: 24 except re2.error:
25 pass 25 pass
26 return re.compile(pat) 26 return re.compile(pat)
27 27
28 def repquote(m): 28 def repquote(m):
29 t = re.sub(r"\w", "x", m.group('text')) 29 fromc = '.:'
30 t = re.sub(r"[^\s\nx]", "o", t) 30 tochr = 'pq'
31 def encodechr(i):
32 if i > 255:
33 return 'u'
34 c = chr(i)
35 if c in ' \n':
36 return c
37 if c.isalpha():
38 return 'x'
39 if c.isdigit():
40 return 'n'
41 try:
42 return tochr[fromc.find(c)]
43 except (ValueError, IndexError):
44 return 'o'
45 t = m.group('text')
46 tt = ''.join(encodechr(i) for i in xrange(256))
47 t = t.translate(tt)
31 return m.group('quote') + t + m.group('quote') 48 return m.group('quote') + t + m.group('quote')
32 49
33 def reppython(m): 50 def reppython(m):
34 comment = m.group('comment') 51 comment = m.group('comment')
35 if comment: 52 if comment:
261 "missing _() in ui message (use () to hide false-positives)"), 278 "missing _() in ui message (use () to hide false-positives)"),
262 (r'release\(.*wlock, .*lock\)', "wrong lock release order"), 279 (r'release\(.*wlock, .*lock\)', "wrong lock release order"),
263 ], 280 ],
264 # warnings 281 # warnings
265 [ 282 [
266 (r'(^| )oo +xxxxoo[ \n][^\n]', "add two newlines after '.. note::'"), 283 (r'(^| )pp +xxxxqq[ \n][^\n]', "add two newlines after '.. note::'"),
267 ] 284 ]
268 ] 285 ]
269 286
270 pyfilters = [ 287 pyfilters = [
271 (r"""(?msx)(?P<comment>\#.*?$)| 288 (r"""(?msx)(?P<comment>\#.*?$)|