-
Notifications
You must be signed in to change notification settings - Fork 0
/
extract-scores.py
80 lines (68 loc) · 1.58 KB
/
extract-scores.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
78
79
80
#!/bin/python3
import glob
import os
indexes = {
}
reports = {
}
for file in glob.glob("reports/*.md", recursive=True):
with open(file) as f:
record = False
stored = ""
for line in f:
if line.startswith("## "):
record = True
stored += line.replace("## ", "#### ")
indexes[line[3:].strip()] = file
elif line.startswith("### "):
record = False
elif record is True:
stored += line
reports[os.path.basename(file)] = stored
#print(stored)
#print(index)
sources = {
"header": "",
"between-lasla": "",
"footer": ""
}
with open("README.md") as f:
index = "header"
ignore = False
for line in f:
if line.startswith("<!-- Start Scores LASLA+ -->"):
sources[index] += line
ignore = True
elif line.startswith("<!-- End Scores LASLA+ -->"):
ignore = False
index = "footer"
sources[index] += line
elif line.startswith("<!-- Start Scores LASLA -->"):
sources[index] += line
ignore = True
elif line.startswith("<!-- End Scores LASLA -->"):
ignore = False
index = "between-lasla"
sources[index] += line
elif ignore is False:
sources[index] += line
from pprint import pprint
indexes1 = "More details:\n"+ "\n".join([
f"- [{task}]({link}#{task})"
for task, link in indexes.items()
])+"\n\n\n"
indexes2 = "More details:\n"+ "\n".join([
f"- [{task}]({link}#{task})"
for task, link in indexes.items()
])+"\n\n\n"
print(indexes)
with open("README.md", "w") as f:
f.write("\n\n".join([
sources["header"],
indexes1,
reports["lasla.md"],
sources["between-lasla"],
indexes2,
reports["lasla-plus.md"],
sources["footer"],
]))