-
Notifications
You must be signed in to change notification settings - Fork 18
/
find_clones.py
executable file
·28 lines (22 loc) · 908 Bytes
/
find_clones.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
#!/usr/bin/env python3
import sys
import os
LANG=sys.argv[1]
REPORTS_DIR="_reports"
REPORT_FILE="jscpd_report.txt"
def good_dir(d):
return os.path.isdir(os.path.join(".", d)) and not d.startswith('.') and d != LANG and d != REPORTS_DIR
if not os.path.exists("_reports"):
os.mkdir("_reports")
os.system("find . -iname _build -exec rm -fr {} \;")
for x in [x for x in os.listdir(".") if good_dir(x)]:
cmd = f"jscpd --pattern '{LANG}/**/*.ml*' --pattern '{x}/**/*.ml*' -b -r consoleFull --skipLocal > _reports/vs_{x}.txt"
print(cmd)
os.system(cmd)
if 1:
print("Looking for clones in itself");
cmd = f"jscpd --pattern '{LANG}/**/*.ml*' -b -r consoleFull > _reports/vs_{LANG}.txt"
os.system(cmd)
os.system(f"echo '#### Результат поиска клонов\n```\n' > {REPORT_FILE}")
os.system(f"cat {REPORTS_DIR}/*.txt >> {REPORT_FILE}")
os.system(f"echo '\n```\n' >> {REPORT_FILE}")