From 641fc45fe00d640aba0a673aff4de818ecfedc26 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Wed, 7 Oct 2020 13:50:11 +0200 Subject: [PATCH] en,fr --- cnam/travaux/mémoire/build.py | 87 ++++++++++--------- .../mémoire/{document.tex => thesis.tex} | 2 +- .../mémoire/{document => thesis}/settings.tex | 0 3 files changed, 46 insertions(+), 43 deletions(-) rename cnam/travaux/mémoire/{document.tex => thesis.tex} (56%) rename cnam/travaux/mémoire/{document => thesis}/settings.tex (100%) diff --git a/cnam/travaux/mémoire/build.py b/cnam/travaux/mémoire/build.py index c3a8422..b11e0b1 100755 --- a/cnam/travaux/mémoire/build.py +++ b/cnam/travaux/mémoire/build.py @@ -5,10 +5,12 @@ import shutil import subprocess import sys +ENGLISH='en' +FRENCH='fr' +LANGUAGES = [ENGLISH, FRENCH] DOCUMENTS = [ - # ('topic', 'sujet'), - ('document', 'mémoire'), - # ('presentation', 'présentation'), + {ENGLISH: 'thesis', FRENCH: 'mémoire'}, + # {ENGLISH: 'presentation', FRENCH: 'présentation'}, ] TMP = 'tmp' @@ -23,46 +25,47 @@ def errun(command): def build(sign): - for en, fr in DOCUMENTS: - command = ['xelatex', '-output-directory', TMP, en] - if en == 'document': + for language in LANGUAGES: + for document in DOCUMENTS: + command = ['xelatex', '-output-directory', TMP, document[ENGLISH]] + if document['en'] == 'thesis': + run(command) + run(['makeglossaries', '-d', TMP, document[ENGLISH]]) + run(['biber', + '--input-directory', TMP, + '--output-directory', TMP, + document['en'], + ]) + run(command) run(command) - run(['makeglossaries', '-d', TMP, en]) - run(['biber', - '--input-directory', TMP, - '--output-directory', TMP, - en, - ]) - run(command) - run(command) - pdf = f'{fr}.pdf' - os.rename(os.path.join(TMP, f'{en}.pdf'), - os.path.join(TMP, pdf)) - if not sign: - os.rename(os.path.join(TMP, pdf), pdf) - else: - run(['gpg', - '--armor', - '--detach-sign', - os.path.join(TMP, pdf), - ]) - signature = f'{pdf}.asc' - for f in [pdf, signature]: - os.rename(os.path.join(TMP, f), f) - lines = errun(['gpg', - '--verify', signature, pdf, - ]).decode('u8').splitlines() - id = lines[2].index('"') - lines = [ - lines[0], - lines[1], - lines[2][:id] + lines[4][id:] - .replace('@', ' @ ') - .replace('.', ' ⋅ ') - ] + lines[5:] - buffer = os.linesep.join(lines).encode('u8') - with open(f'{pdf}.vrf', 'bw') as f: - f.write(buffer) + pdf = f'{document[FRENCH]}.pdf' + os.rename(os.path.join(TMP, f'{document[ENGLISH]}.pdf'), + os.path.join(TMP, pdf)) + if not sign: + os.rename(os.path.join(TMP, pdf), pdf) + else: + run(['gpg', + '--armor', + '--detach-sign', + os.path.join(TMP, pdf), + ]) + signature = f'{pdf}.asc' + for f in [pdf, signature]: + os.rename(os.path.join(TMP, f), f) + lines = errun(['gpg', + '--verify', signature, pdf, + ]).decode('u8').splitlines() + id = lines[2].index('"') + lines = [ + lines[0], + lines[1], + lines[2][:id] + lines[4][id:] + .replace('@', ' @ ') + .replace('.', ' ⋅ ') + ] + lines[5:] + buffer = os.linesep.join(lines).encode('u8') + with open(f'{pdf}.vrf', 'bw') as f: + f.write(buffer) def clean(): diff --git a/cnam/travaux/mémoire/document.tex b/cnam/travaux/mémoire/thesis.tex similarity index 56% rename from cnam/travaux/mémoire/document.tex rename to cnam/travaux/mémoire/thesis.tex index ed632f0..69075b7 100644 --- a/cnam/travaux/mémoire/document.tex +++ b/cnam/travaux/mémoire/thesis.tex @@ -1,4 +1,4 @@ -\newcommand{\import}[1]{\input{document/#1}} +\newcommand{\import}[1]{\input{thesis/#1}} \import{settings} diff --git a/cnam/travaux/mémoire/document/settings.tex b/cnam/travaux/mémoire/thesis/settings.tex similarity index 100% rename from cnam/travaux/mémoire/document/settings.tex rename to cnam/travaux/mémoire/thesis/settings.tex