build/tmp

This commit is contained in:
Marc Beninca 2020-04-27 04:25:41 +02:00
parent b7a82eff89
commit 6fbb6acc2a
2 changed files with 23 additions and 23 deletions

View file

@ -1,47 +1,48 @@
#! /usr/bin/python3 -B #! /usr/bin/python3 -B
import os import os
import shutil
import subprocess import subprocess
DOCUMENTS = [ DOCUMENTS = [
'document', 'document',
'présentation', 'présentation',
] ]
PURGE = [ TMP = 'tmp'
'.aux', '.log', '.toc',
'.acn', '.acr', '.alg',
'.glg', '.glo', '.gls',
'.glsdefs', '.ist',
]
def run(*args): def run(args):
subprocess.call(args) subprocess.call(args)
def build(directory): def build():
os.chdir(directory)
for document in DOCUMENTS: for document in DOCUMENTS:
run('xelatex', f'{document}.tex') command = ['xelatex',
run('makeglossaries', f'{document}') '-output-directory', TMP,
run('xelatex', f'{document}.tex') document,
]
run(command)
run(['makeglossaries',
'-d', TMP,
document,
])
run(command)
pdf = f'{document}.pdf'
os.rename(os.path.join(TMP, pdf), pdf)
def clean(directory): def clean():
os.chdir(directory) shutil.rmtree(TMP, ignore_errors=True)
_, _, files = next(os.walk(directory))
for file in files:
name, ext = os.path.splitext(file)
if ext in PURGE:
os.remove(file)
def main(): def main():
file = os.path.realpath(__file__) file = os.path.realpath(__file__)
directory = os.path.dirname(file) directory = os.path.dirname(file)
clean(directory) os.chdir(directory)
build(directory) clean()
clean(directory) os.makedirs(TMP)
build()
clean()
if __name__ == '__main__': if __name__ == '__main__':

View file

@ -1,4 +1,3 @@
% TODO répertoire metafiles
% TODO bibliographie % TODO bibliographie
% TODO décaler la numérotation des pages % TODO décaler la numérotation des pages
\documentclass[12pt]{extarticle} \documentclass[12pt]{extarticle}