Show More
@@ -14,41 +14,41 b' hg_backtick = re.compile(r""":hg:`[^`]*\'' | |||
|
14 | 14 | hg_cramped = re.compile(r'\w:hg:`') |
|
15 | 15 | |
|
16 | 16 | def check(line): |
|
17 | if hg_backtick.search(line): | |
|
18 | print(line) | |
|
19 | print("""warning: please avoid nesting ' in :hg:`...`""") | |
|
20 | if hg_cramped.search(line): | |
|
21 | print(line) | |
|
22 | print('warning: please have a space before :hg:') | |
|
17 | if hg_backtick.search(line): | |
|
18 | print(line) | |
|
19 | print("""warning: please avoid nesting ' in :hg:`...`""") | |
|
20 | if hg_cramped.search(line): | |
|
21 | print(line) | |
|
22 | print('warning: please have a space before :hg:') | |
|
23 | 23 | |
|
24 | 24 | def work(file): |
|
25 | (llead, lline) = ('', '') | |
|
25 | (llead, lline) = ('', '') | |
|
26 | 26 | |
|
27 | for line in file: | |
|
28 | # this section unwraps lines | |
|
29 | match = leadingline.match(line) | |
|
30 | if not match: | |
|
31 | check(lline) | |
|
32 | (llead, lline) = ('', '') | |
|
33 | continue | |
|
27 | for line in file: | |
|
28 | # this section unwraps lines | |
|
29 | match = leadingline.match(line) | |
|
30 | if not match: | |
|
31 | check(lline) | |
|
32 | (llead, lline) = ('', '') | |
|
33 | continue | |
|
34 | 34 | |
|
35 | lead, line = match.group(1), match.group(2) | |
|
36 | if (lead == llead): | |
|
37 | if (lline != ''): | |
|
38 | lline += ' ' + line | |
|
39 | else: | |
|
40 | lline = line | |
|
41 | else: | |
|
42 | check(lline) | |
|
43 | (llead, lline) = (lead, line) | |
|
44 | check(lline) | |
|
35 | lead, line = match.group(1), match.group(2) | |
|
36 | if (lead == llead): | |
|
37 | if (lline != ''): | |
|
38 | lline += ' ' + line | |
|
39 | else: | |
|
40 | lline = line | |
|
41 | else: | |
|
42 | check(lline) | |
|
43 | (llead, lline) = (lead, line) | |
|
44 | check(lline) | |
|
45 | 45 | |
|
46 | 46 | def main(): |
|
47 | for f in sys.argv[1:]: | |
|
48 | try: | |
|
49 | with open(f) as file: | |
|
50 | work(file) | |
|
51 | except BaseException as e: | |
|
52 | print("failed to process %s: %s" % (f, e)) | |
|
47 | for f in sys.argv[1:]: | |
|
48 | try: | |
|
49 | with open(f) as file: | |
|
50 | work(file) | |
|
51 | except BaseException as e: | |
|
52 | print("failed to process %s: %s" % (f, e)) | |
|
53 | 53 | |
|
54 | 54 | main() |
General Comments 0
You need to be logged in to leave comments.
Login now