-
Notifications
You must be signed in to change notification settings - Fork 1
/
scores.py
51 lines (42 loc) · 958 Bytes
/
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
#!/bin/python3
import glob
stored = ""
indexes = {
}
for file in glob.glob("**/*.score.md", recursive=True):
with open(file) as f:
record = False
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
#print(stored)
#print(index)
sources = [
"",
""
]
with open("README.md") as f:
index = 0
ignore = False
for line in f:
if line.startswith("<!-- Start Scores -->"):
sources[index] += line
ignore = True
index = 1
elif line.startswith("<!-- End Scores -->"):
ignore = False
sources[index] += line
elif ignore is False:
sources[index] += line
indexes = "More details:\n"+ "\n".join([
f"- [{task}]({link})"
for task, link in indexes.items()
])+"\n\n\n"
with open("README.md", "w") as f:
f.write(sources[0]+indexes+stored+sources[1])