-
Notifications
You must be signed in to change notification settings - Fork 0
/
update_readme.py
36 lines (26 loc) · 909 Bytes
/
update_readme.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
import glob
def get_filenames():
works_dict = {}
works_dirs = glob.glob("./works/*", recursive=False)
works_dirs.sort(reverse=True)
for dir in works_dirs:
work = dir.split("/")[-1]
imgs = glob.glob(dir + "/img/*")
works_dict[work] = imgs
return works_dict
def write_readme(works_dict):
path_w = 'README.md'
with open(path_w, mode='w', newline='\n') as f:
for work, imgs in works_dict.items():
f.write(f'<h2><a href="/works/{work}/README.md">{work}</a></h2>\n')
f.write('<table>')
f.write('<tr>')
for i in range(len(imgs)):
f.write(f'<td><img src="{imgs[i]}"></td>')
f.write('</tr>')
f.write('</table>')
f.write('\n')
if __name__ == "__main__":
works_dict = get_filenames()
print(works_dict)
write_readme(works_dict)