equal
deleted
inserted
replaced
11 |
11 |
12 def repquote(m): |
12 def repquote(m): |
13 t = re.sub(r"\w", "x", m.group('text')) |
13 t = re.sub(r"\w", "x", m.group('text')) |
14 t = re.sub(r"[^\sx]", "o", t) |
14 t = re.sub(r"[^\sx]", "o", t) |
15 return m.group('quote') + t + m.group('quote') |
15 return m.group('quote') + t + m.group('quote') |
|
16 |
|
17 def reppython(m): |
|
18 comment = m.group('comment') |
|
19 if comment: |
|
20 return "#" * len(comment) |
|
21 return repquote(m) |
16 |
22 |
17 def repcomment(m): |
23 def repcomment(m): |
18 return m.group(1) + "#" * len(m.group(2)) |
24 return m.group(1) + "#" * len(m.group(2)) |
19 |
25 |
20 def repccomment(m): |
26 def repccomment(m): |
94 (r'raise Exception', "don't raise generic exceptions"), |
100 (r'raise Exception', "don't raise generic exceptions"), |
95 (r'ui\.(status|progress|write|note)\([\'\"]x', "unwrapped ui message"), |
101 (r'ui\.(status|progress|write|note)\([\'\"]x', "unwrapped ui message"), |
96 ] |
102 ] |
97 |
103 |
98 pyfilters = [ |
104 pyfilters = [ |
99 (r"""(?msx)(?P<quote>('''|\"\"\"|(?<!')'(?!')|(?<!")"(?!"))) |
105 (r"""(?msx)(?P<comment>\#.*?$)| |
100 (?P<text>(.*?)) |
106 ((?P<quote>('''|\"\"\"|(?<!')'(?!')|(?<!")"(?!"))) |
101 (?<!\\)(?P=quote)""", repquote), |
107 (?P<text>(([^\\]|\\.)*?)) |
102 (r"( *)(#([^\n]*\S)?)", repcomment), |
108 (?P=quote))""", reppython), |
103 ] |
109 ] |
104 |
110 |
105 cpats = [ |
111 cpats = [ |
106 (r'//', "don't use //-style comments"), |
112 (r'//', "don't use //-style comments"), |
107 (r'^ ', "don't use spaces to indent"), |
113 (r'^ ', "don't use spaces to indent"), |