-
Notifications
You must be signed in to change notification settings - Fork 4
/
compile_abstract_book.py
51 lines (37 loc) · 1.42 KB
/
compile_abstract_book.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
# -*- coding: utf-8 -*-
'''Compile CS20 abstract book
This script compiles the CS20 abstract book.
It uses Jinja2 templates. There is a general template in /templates
This script needs to be executed in the exact directory where it is now,
because it uses relative input paths.
'''
import argparse
import os
import shutil
import subprocess
from jinja2 import Environment, FileSystemLoader, select_autoescape
import pagepy.contributions
from script_helper import parser
args = parser.parse_args()
# Generate html
env = Environment(loader=FileSystemLoader(['templates']),
autoescape=select_autoescape(['html']))
if not os.path.exists(args.outpath):
os.makedirs(args.outpath)
data = pagepy.contributions.data(**vars(args))
tex_templates = ['abstractbook-long.tex']
images = ['print_images/Logoround-04.png']
for tempfile in tex_templates:
template = env.get_template(tempfile)
with open(os.path.join(args.outpath, tempfile), "w") as tex_out:
tex_out.write(template.render(**data))
for f in images:
shutil.copy(f, args.outpath)
for template in tex_templates:
out = 'Rerun'
while 'Rerun' in str(out):
latex = subprocess.Popen(['pdflatex', '-interaction=nonstopmode',
os.path.join(args.outpath, template)],
cwd=args.outpath,
stdout=subprocess.PIPE)
out, err = latex.communicate()