forked from insertinterestingnamehere/numerical_computing
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmake_util.py
More file actions
Latest commit
38 lines (30 loc) · 1.06 KB
/
Copy pathmake_util.py
File metadata and controls
38 lines (30 loc) · 1.06 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
importos
importsubprocess
defsubstlab(template, lab_path, lab_file):
"""Read template and substitute labs"""
withopen(template, 'r') astemp:
t=temp.readlines()
i=t.index('%TEMPLATE_INSERT\n')
t.insert(i+1, '\\subimport{{{0}/}}{{{1}}}\n'.format(lab_path.replace('\\', '/'), lab_file))
returnt
defgetDirs(root):
returnset([xforxinos.listdir(root) ifos.path.isdir(x)])
defrun_latex(template, msg=True):
ifmsg:
print"Running XeLaTeX on {}".format(template)
ret=subprocess.Popen(['xelatex', '-halt-on-error', template],
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT)
stdout=ret.communicate()[0]
returnret
defrun_biber(template, msg=True):
ifmsg:
print"Running Biber on {}".format(template)
_t=os.path.splitext(template)[0]
ret=subprocess.Popen(['biber', _t])
stdout=ret.communicate()[0]
returnret
run_seq= [run_latex,
run_biber,
run_latex,
run_latex]