-
Notifications
You must be signed in to change notification settings - Fork 163
/
Copy pathngword_check.py
77 lines (69 loc) · 2.24 KB
/
ngword_check.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
import glob
import os
import sys
import re
NGWORD_LIST = [
("", "<br>", "<br/>"),
("", "</br>", "<br/>"),
("", "acccess", "access"),
("", "ALING", "ALIGN"),
("", "alloacte", "allocate"),
("", "asssert", "assert"),
("", "asssume", "assume"),
("", "algined", "aligned"),
("", "concpet", "concept"),
("", "condtion", "condition"),
("", "Dimentional", "Dimensional"),
("", "eror", "error"),
("", "enumrate", "enumerate"),
("", "expceted", "expected"),
("", "exposion", "exposition"),
("", "functon", "function"),
("", "generetor", "generator"),
("", "greator", "greater"),
("", "namespase", "namespace"),
("", "noexpcet", "noexcept"),
("", "oeprator", "operator"),
("", "opreator", "operator"),
("", "opton", "option"),
("", "Ohter", "Other"),
("", "protmise_type", "promise_type"),
("", "pvalue", "prvalue"),
("", "refernce", "reference"),
("", "repear", "repeat"),
("", "std::range::", "std::ranges::"),
("", "swtich", "switch"),
("", "voaltile", "volatile"),
("", "Updated upstream", ""),
("", "Stashed changes", ""),
("", "子ルーチン", "コルーチン"),
("", "移譲", "委譲"),
("", r'型]\((.*?)\)型', "型](link)"),
("", "括弧", "カッコ"),
("", "constepx", "constexpr"),
("", "wsting", "wstring"),
("reference/chrono", "dulation", "duration"),
("reference/random", "施行", "試行"),
("reference/random", "疑似", "擬似"),
]
def check_ngword(text: str, filename: str) -> bool:
found_error: bool = False
for target_dir, ngword, correct in NGWORD_LIST:
if not filename.startswith(target_dir):
continue
m = re.search(ngword, text)
if m:
print("{}: the file includes ngword \"{}\". you should fix to \"{}\".".format(filename, ngword, correct))
found_error = True
return not found_error
if __name__ == '__main__':
found_error = False
for p in sorted(list(glob.glob("**/*.md", recursive=True))):
if p.startswith("start_editing/"):
continue
with open(p) as f:
text = f.read()
if not check_ngword(text, p):
found_error = True
if found_error:
sys.exit(1)