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

49 lines
881 B
Python
Raw Normal View History

2020-04-22 18:56:05 +02:00
#! /usr/bin/python3 -B
import os
import subprocess
DOCUMENTS = [
'document',
'présentation',
]
2020-04-26 23:36:40 +02:00
PURGE = [
2020-04-27 00:39:49 +02:00
'.aux', '.log', '.toc',
'.acn', '.acr', '.alg',
'.glg', '.glo', '.gls',
'.glsdefs', '.ist',
2020-04-26 23:36:40 +02:00
]
2020-04-22 18:56:05 +02:00
2020-04-27 00:39:49 +02:00
def run(*args):
subprocess.call(args)
2020-04-22 19:22:57 +02:00
def build(directory):
os.chdir(directory)
2020-04-22 18:56:05 +02:00
for document in DOCUMENTS:
2020-04-27 00:39:49 +02:00
run('xelatex', f'{document}.tex')
run('makeglossaries', f'{document}')
run('xelatex', f'{document}.tex')
2020-04-22 18:56:05 +02:00
2020-04-22 19:22:57 +02:00
def clean(directory):
os.chdir(directory)
2020-04-22 18:56:05 +02:00
_, _, files = next(os.walk(directory))
for file in files:
name, ext = os.path.splitext(file)
2020-04-26 23:36:40 +02:00
if ext in PURGE:
2020-04-22 18:56:05 +02:00
os.remove(file)
def main():
file = os.path.realpath(__file__)
directory = os.path.dirname(file)
2020-04-27 00:39:49 +02:00
clean(directory)
2020-04-22 19:22:57 +02:00
build(directory)
clean(directory)
2020-04-22 18:56:05 +02:00
if __name__ == '__main__':
main()