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 = [
|
|
|
|
'.acn',
|
|
|
|
'.aux',
|
|
|
|
'.glo',
|
|
|
|
'.glsdefs',
|
|
|
|
'.ist',
|
|
|
|
'.log',
|
|
|
|
'.toc',
|
|
|
|
]
|
2020-04-22 18:56:05 +02:00
|
|
|
|
|
|
|
|
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:
|
|
|
|
command = ['xelatex', f'{document}.tex']
|
|
|
|
for _ in range(2):
|
|
|
|
subprocess.call(command)
|
|
|
|
|
|
|
|
|
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-22 19:22:57 +02:00
|
|
|
build(directory)
|
|
|
|
clean(directory)
|
2020-04-22 18:56:05 +02:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
main()
|