-
Notifications
You must be signed in to change notification settings - Fork 4
/
build_previews.py
31 lines (22 loc) · 922 Bytes
/
build_previews.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
# -*- coding: utf-8 -*-
#!/usr/bin/env python
'''
Copyright (C) 2019 Nicolàs Palacio-Escat
Contact: [email protected]
The following script walks down the subdirectories of the current folder
and creates a README.md file inside each one of them containing a
preview of all the graphics in that subfolder.
This way I don't have to bother myself to do it manually every time I
add/remove/modify one or more of them. Neat right!?
'''
import os
for sdir, folders, files in os.walk('.'):
if (sdir == '.' or sdir == './.git'):
continue
else:
images = sorted([f for f in files if f.endswith('.svg')])
with open(os.path.join(sdir, 'README.md'), 'w') as rdm:
rdm.write('# %s\n\n' % sdir.split('/')[-1])
for i in images:
rdm.write('## %s\n' % i.split('.')[0])
rdm.write('<img src="%s" height="150"/>\n\n' % i)