-
Notifications
You must be signed in to change notification settings - Fork 0
/
diff.py
75 lines (49 loc) · 1.7 KB
/
diff.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
'''
A script to generate the corrections diff
vim example.txt -c "hardcopy > example.ps | q"; ps2pdf example.ps
pip install grip
npm install -g markdown-pdf
'''
import os,glob,re
diff_folder = './diff/'
# os.system('rm %s*.html'%diff_folder)
files = ['thesis.tex']
title = ['Thesis.tex']
chs = list(glob.glob('*_*.tex'))
chs.sort()
for f in chs:
loc = re.findall('subimport{(.+)/}{combigned.tex}',open(f).read())[0]
title.append(f)
files.append(loc+'/combigned.tex')
title.extend(['Glossary'])#,'Bibliography'])
files.extend(['glossary.tex'])#,'bibtex.bib'])
changes = ['# DanEllisThesis - Change Log','-------------------------']
for i,f in enumerate(files):
changes.append('## ' + title[i])
# submit corrections thesis.tex
cmd = 'git diff --ignore-space-at-eol -b -w --ignore-blank-lines submit corrections %s '%f #> %s%s'%(f,diff_folder,outname)
data = os.popen(cmd).readlines()
print(f,len(data))
edit = []
previous = ''
for i in data:
i = i.strip('\\n')
if len(i)<10: continue
# if previous[1:10] == i[1:10]:
# edit.append('_a a_')##joint edit
if i[0]=='-':
edit.append('###### '+i)
elif i[0]=='+':
edit.append('##### '+i)
elif i[0]=='@':
i = i.split('@@')
edit.append('### '+i[1])
#edit.append('#### '+i[-1])
## part description not useful
else:
edit.append('#### '+i)
previous = i
changes.extend(edit)
with open(diff_folder+'changes.md' ,'w') as f:
f.write('\n'.join(changes))
os.system('cd diff && markdown-pdf --css-path my.css changes.md')