-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathcheck_copies.py
42 lines (32 loc) · 942 Bytes
/
check_copies.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
# check copies of utils.py up-to-date or not
from pathlib import Path
def check(fname):
red = "\033[31m"
green = "\033[32m"
reset = "\033[0m"
with open(f"./src/templates/template-common/{fname}", "r") as f:
common = f.readlines()
path = Path("./src/templates/")
for file in path.rglob(f"**/{fname}"):
if str(file).find("common") > -1:
continue
else:
template = file.read_text("utf-8")
match = []
for c in common:
match.append(template.find(c) > -1)
if all(match):
print(green, "Matched", file, reset)
else:
print(red, "Unmatched", file, reset)
exit(1)
if __name__ == "__main__":
check("config.yaml")
print()
check("main.py")
print()
check("README.md")
print()
check("requirements.txt")
print()
check("utils.py")