-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathremove_solutions.py
More file actions
31 lines (24 loc) · 843 Bytes
/
Copy pathremove_solutions.py
File metadata and controls
31 lines (24 loc) · 843 Bytes
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
from glob import glob
"""
files = sorted(glob('intropy/_build/html/solutions/week_1/*.html'))
for f in files:
print("Removing solutions from %s ..." % f)
with open(f, 'r') as f_in:
lines = f_in.readlines()
new = []
skip = False
for line in lines:
if '### BEGIN SOLUTION' in line or '### BEGIN HIDDEN TESTS' in line:
skip = True
if not skip:
new.append(line)
if '### END SOLUTION' in line or '### END HIDDEN TESTS' in line:
skip = False
if '### END SOLUTION' in line:
new.append('<span class="c1"># YOUR SOLUTION HERE</span>')
else:
new.append('<span class="c1"># HIDDEN TESTS HERE</span>')
with open(f, 'w') as f_out:
for line in new:
f_out.write(line)
"""