-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmake.py
executable file
·80 lines (63 loc) · 2.47 KB
/
make.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#!/usr/bin/env python3
import io
import os
import time
import yaml
import shutil
from jinja2 import Environment, FileSystemLoader
import generate_submission_data
# make the live web directory if needed
# move old to a timestamp just in case
liveweb = './live'
if os.path.exists(liveweb):
timestamp = time.strftime('%c').replace(' ', '-').replace(':', '.')
shutil.move(liveweb, liveweb+'-'+timestamp)
os.makedirs(liveweb)
# parse, render each template here
env = Environment(loader=FileSystemLoader('./'))
files = ['_index.html', '_people.html', '_student.html', '_about.html',
'_lodging.html', '_registration.html', '_submit.html']
# remove blank entries from the yaml input
def prune_blank(somelist, key):
somelist = [c for c in somelist if c[key] is not None]
return somelist
# Load Data
with io.open("./data/info.yml", "r") as inf:
info = yaml.load(inf)
with io.open("./data/student-paper-winners.yml", "r") as inf:
student_paper_winners = yaml.load(inf)
with io.open("./data/previous-conferences.yml", "r") as inf:
previous_conferences = yaml.load(inf)
previous_conferences = prune_blank(previous_conferences, 'year')
# now order by years
previous_conferences = sorted(previous_conferences,
key=lambda k: k['year'],
reverse=True)
with io.open("./data/committee.yml", "r") as inf:
committee = yaml.load(inf)
committee = prune_blank(committee, 'name')
# order by last part of last name
committee = sorted(committee, key=lambda k: k['name'].split()[-1])
with io.open("./data/deadlines.yml", "r") as inf:
deadlines = yaml.load(inf)
# now render the pages
for f in files:
template_vars = {}
template_vars['info'] = info
template_vars['deadlines'] = deadlines
template_vars['previous_conferences'] = previous_conferences
template_vars['committee'] = committee
template_vars['student_paper_winners'] = student_paper_winners
html = env.get_template(f).render(template_vars)
with io.open(os.path.join('./live/', f[1:]), 'w', encoding='utf8') as fout:
fout.write(html)
# copy these directories as-is to the webdir
livedirs = ['font-awesome', 'bootstrap', 'css', 'images', 'program-static']
for d in livedirs:
if os.path.isdir(d):
shutil.copytree(d, os.path.join(liveweb, d))
# copy these files as-is to the webdir
# livefiles = ['robots.txt']
livefiles = []
for f in livefiles:
shutil.copyfile(f, os.path.join(liveweb, f))