-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild_weeks.py
More file actions
48 lines (38 loc) · 1.26 KB
/
Copy pathbuild_weeks.py
File metadata and controls
48 lines (38 loc) · 1.26 KB
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
#!/usr/bin/env python
"""
script to build the framework for all the class presentations
"""
import os
import datetime
def make_date_string(week_num):
if week_num > 2: # skipping July 4th
week_num += 1
if week_num > 8: # skipping Aug 22nd
week_num += 1
start = datetime.date(2012, 6, 20)
delta = datetime.timedelta(days=7*(week_num-1))
date = start + delta
return date.strftime("%B %d, %Y")
def create_dir(week_num):
dir_name = "week-%02i"%week_num
try:
os.mkdir(dir_name)
except OSError:
pass # directory already exists
# create a code dir
try:
os.mkdir(os.path.join(dir_name, 'code'))
except OSError:
pass # dir already there
# load the template
template = file(os.path.join("week-03", "presentation-template.tex"), 'rU' ).read()
#insert the week number
template = template.replace("the_week_number", `week_num`)
#insert the date
template = template.replace("the_date_string", make_date_string(week_num))
# write it out:
file_name = "presentation-week%02i.tex"%week_num
file(os.path.join(dir_name, file_name),'w').write(template)
if __name__ == "__main__":
for week_num in range(4,11):
create_dir(week_num)