-
-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Expand file tree
/
Copy pathmake.py
More file actions
executable file
·71 lines (48 loc) · 1.5 KB
/
make.py
File metadata and controls
executable file
·71 lines (48 loc) · 1.5 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
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/usr/bin/env python
import os, sys, glob
def check_png():
if not len(glob.glob('figures/*.png')):
raise SystemExit('No PNG files in figures dir; please run make.py in the figures directory first')
def check_rst2latex():
sin, sout = os.popen2('which rst2latex')
if not sout.read():
raise SystemExit('Build requires rst2latex')
def check_pdflatex():
sin, sout = os.popen2('which pdflatex')
if not sout.read():
raise SystemExit('Build requires pdflatex')
def artist_tut():
check_png()
check_rst2latex()
check_pdflatex()
os.system('rst2latex artist_api_tut.txt > artist_api_tut.tex')
os.system('pdflatex artist_api_tut.tex')
def event_tut():
check_png()
check_rst2latex()
check_pdflatex()
os.system('rst2latex event_handling_tut.txt > event_handling_tut.tex')
os.system('pdflatex event_handling_tut.tex')
def clean():
patterns = ['#*', '*~', '*.tex', '*.log', '*.out', '*.aux', '*.pdf']
for pattern in patterns:
for fname in glob.glob(pattern):
os.remove(fname)
print 'all clean'
def all():
artist_tut()
event_tut()
funcd = {'artist_tut': artist_tut,
'event_tut': event_tut,
'clean': clean,
'all': all,
}
if len(sys.argv)>1:
for arg in sys.argv[1:]:
func = funcd.get(arg)
if func is None:
raise SystemExit('Do not know how to handle %s; valid args are'%(
arg, funcd.keys()))
func()
else:
all()