-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgen.py
executable file
·65 lines (59 loc) · 1.88 KB
/
gen.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
#!/usr/bin/env -S python3 -B
import os
import sys
DEST = '$(DEST)'
DEST_HANDOUT = '$(DEST)/handout'
zips = []
pdfs = []
handouts = []
texs = []
def gen_pdf(kind):
print(f'{target}: $(PANDOC) $(TECTONIC) {cap}/{item}')
print(f'\t@echo {target}')
print(f'\t@mkdir -p {DEST}/handout')
print(f'\t@cd {cap} && ../$(PANDOC_{kind}_CMD) -o ../{target} {item}')
print()
for cap in sorted(os.listdir()):
if not os.path.isdir(cap) or cap[2:3] != '-':
continue
for item in os.listdir(cap):
if item == 'imagens':
continue
if os.path.isdir(f'{cap}/{item}'):
target = f'{DEST}/{cap}-{item}.zip'
zips.append(target)
print(f'{target}: {cap}/{item}/*')
print(f'\t@echo {target}')
print(f'\t@mkdir -p {DEST}')
print(f'\t@zip {target} -x *.swp -r {cap}/{item}')
print()
elif item == 'notas-de-aula.md':
base = os.path.splitext(item)[0]
# pdf
target = f'{DEST}/{cap}-{base}.pdf'
pdfs.append(target)
gen_pdf('NOTAS')
# handout
target = f'{DEST_HANDOUT}/{cap}-{base}.pdf'
pdfs.append(target)
gen_pdf('HANDOUT')
# tex
target = f'{DEST}/{cap}-{base}.tex'
texs.append(target)
gen_pdf('NOTAS')
elif item.endswith('md'):
base = os.path.splitext(item)[0]
# pdf
target = f'{DEST}/{cap}-{base}.pdf'
pdfs.append(target)
gen_pdf('GERAL')
# tex
target = f'{DEST}/{cap}-{base}.tex'
texs.append(target)
gen_pdf('GERAL')
else:
print(f'ignorando: {cap}/{item}', file=sys.stderr)
print('pdf:', ' '.join(pdfs))
print('handout:', ' '.join(handouts))
print('tex:', ' '.join(texs))
print('zip:', ' '.join(zips))