cnam.marc/cnam/travaux/blanc/build.py

50 lines
798 B
Python
Raw Normal View History

2020-04-22 18:56:05 +02:00
#! /usr/bin/python3 -B
import os
2020-04-27 04:25:41 +02:00
import shutil
2020-04-22 18:56:05 +02:00
import subprocess
DOCUMENTS = [
'document',
'présentation',
]
2020-04-27 04:25:41 +02:00
TMP = 'tmp'
2020-04-22 18:56:05 +02:00
2020-04-27 04:25:41 +02:00
def run(args):
2020-04-27 00:39:49 +02:00
subprocess.call(args)
2020-04-27 04:25:41 +02:00
def build():
2020-04-22 18:56:05 +02:00
for document in DOCUMENTS:
2020-04-27 04:25:41 +02:00
command = ['xelatex',
'-output-directory', TMP,
document,
]
run(command)
run(['makeglossaries',
'-d', TMP,
document,
])
run(command)
pdf = f'{document}.pdf'
os.rename(os.path.join(TMP, pdf), pdf)
2020-04-22 18:56:05 +02:00
2020-04-27 04:25:41 +02:00
def clean():
shutil.rmtree(TMP, ignore_errors=True)
2020-04-22 18:56:05 +02:00
def main():
file = os.path.realpath(__file__)
directory = os.path.dirname(file)
2020-04-27 04:25:41 +02:00
os.chdir(directory)
clean()
os.makedirs(TMP)
build()
clean()
2020-04-22 18:56:05 +02:00
if __name__ == '__main__':
main()