-
Notifications
You must be signed in to change notification settings - Fork 92
/
remake.py
31 lines (29 loc) · 1.26 KB
/
remake.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
import shutil
import subprocess
for i in range(8):
current = "session{}".format(i)
branch = "s{}".format(i)
output = subprocess.check_output(
["git", "ls-tree", "-r", "--name-only", current]
).decode("ascii")
for filename in output.split():
if filename.endswith(("py", "ipynb")) and filename != "redo.py":
if filename.endswith("ipynb") and not filename.startswith(current):
continue
with open("{}/{}".format(current, filename), "wb") as f:
contents = subprocess.check_output(
["git", "show", "{}:{}".format(branch, filename)]
)
f.write(contents)
output = subprocess.check_output(
["git", "ls-tree", "-r", "--name-only", "{}-c".format(branch)]
).decode("ascii")
for filename in output.split():
if filename.endswith(("py", "ipynb")) and filename != "redo.py":
if filename.endswith("ipynb") and not filename.startswith(current):
continue
with open("{}/complete/{}".format(current, filename), "wb") as f:
contents = subprocess.check_output(
["git", "show", "{}-c:{}".format(branch, filename)]
)
f.write(contents)