-
Notifications
You must be signed in to change notification settings - Fork 0
/
compile.py
61 lines (44 loc) · 1.41 KB
/
compile.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
import os, sys, glob, re, subprocess
# import clean
def make(filename):
os.system('pdflatex '+filename)
print('.')
bib = []
bf = glob.glob('*.aux')
for i in bf:
os.popen('bibtex '+i)
os.popen('bibtex '+i)
bib.append(os.popen('bibtex '+i).read())
print('.')
os.system('pdflatex '+filename)
print('.')
#err = os.popen('pdflatex '+filename) # .read()
p = subprocess.Popen(['pdflatex',filename], stdout=subprocess.PIPE)
err = p.communicate()[0].decode('utf-8',errors='ignore')
print('.')
print(re.findall(r'[Ww]arning:.*line\s\d+\.',str(err)) )
with open('warnings.txt','w') as f:
f.write('\n'.join(re.findall(r'[Ww]arning:.*line\s\d+\.',str(err))))
for i in range(2):f.write('------------\n')
for i,b in enumerate(bib):
print ('-'*10,'\n',bf[i],'\n','-'*10)
for j in re.split(r'\n',b):
print(j)
f.write(j+'\n')
print('Finished')
def autorun(globstr,filename):
import ipyReload as ipr
#conda install -c wolfiex ipyreload
files = glob.glob(globstr)
def callback():
make(filename)
for i in files:
print('watching ',i)
ipr.watch(i,callback)
if __name__ == '__main__':
try:
if sys.argv[1]=='True':
autorun('*/*.tex','thesis.tex')
except:
make('thesis.tex')
#import clean