8 # GNU General Public License version 2 or any later version. |
8 # GNU General Public License version 2 or any later version. |
9 |
9 |
10 import sys, re, glob |
10 import sys, re, glob |
11 |
11 |
12 def repquote(m): |
12 def repquote(m): |
13 t = re.sub(r"\S", "x", m.group(2)) |
13 t = re.sub(r"\w", "x", m.group(2)) |
|
14 t = re.sub(r"[^\sx]", "o", t) |
14 return m.group(1) + t + m.group(1) |
15 return m.group(1) + t + m.group(1) |
15 |
16 |
16 def repcomment(m): |
17 def repcomment(m): |
17 return m.group(1) + "#" * len(m.group(2)) |
18 return m.group(1) + "#" * len(m.group(2)) |
18 |
19 |
86 # (r'\s\s=', "gratuitous whitespace before ="), |
87 # (r'\s\s=', "gratuitous whitespace before ="), |
87 (r'[^>< ](\+=|-=|!=|<>|<=|>=|<<=|>>=)\S', "missing whitespace around operator"), |
88 (r'[^>< ](\+=|-=|!=|<>|<=|>=|<<=|>>=)\S', "missing whitespace around operator"), |
88 (r'[^>< ](\+=|-=|!=|<>|<=|>=|<<=|>>=)\s', "missing whitespace around operator"), |
89 (r'[^>< ](\+=|-=|!=|<>|<=|>=|<<=|>>=)\s', "missing whitespace around operator"), |
89 (r'\s(\+=|-=|!=|<>|<=|>=|<<=|>>=)\S', "missing whitespace around operator"), |
90 (r'\s(\+=|-=|!=|<>|<=|>=|<<=|>>=)\S', "missing whitespace around operator"), |
90 (r'[^+=*!<>&| -](\s=|=\s)[^= ]', "wrong whitespace around ="), |
91 (r'[^+=*!<>&| -](\s=|=\s)[^= ]', "wrong whitespace around ="), |
|
92 (r'raise Exception', "don't raise generic exceptions"), |
|
93 (r'ui\.(status|progress|write|note)\([\'\"]x', "unwrapped ui message"), |
91 ] |
94 ] |
92 |
95 |
93 pyfilters = [ |
96 pyfilters = [ |
94 (r"""(''')(([^']|\\'|'{1,2}(?!'))*)'''""", repquote), |
97 (r"""(''')(([^']|\\'|'{1,2}(?!'))*)'''""", repquote), |
95 (r'''(""")(([^"]|\\"|"{1,2}(?!"))*)"""''', repquote), |
98 (r'''(""")(([^"]|\\"|"{1,2}(?!"))*)"""''', repquote), |