en,fr
This commit is contained in:
parent
0a2f3cae99
commit
641fc45fe0
3 changed files with 46 additions and 43 deletions
|
@ -5,10 +5,12 @@ import shutil
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
ENGLISH='en'
|
||||||
|
FRENCH='fr'
|
||||||
|
LANGUAGES = [ENGLISH, FRENCH]
|
||||||
DOCUMENTS = [
|
DOCUMENTS = [
|
||||||
# ('topic', 'sujet'),
|
{ENGLISH: 'thesis', FRENCH: 'mémoire'},
|
||||||
('document', 'mémoire'),
|
# {ENGLISH: 'presentation', FRENCH: 'présentation'},
|
||||||
# ('presentation', 'présentation'),
|
|
||||||
]
|
]
|
||||||
TMP = 'tmp'
|
TMP = 'tmp'
|
||||||
|
|
||||||
|
@ -23,46 +25,47 @@ def errun(command):
|
||||||
|
|
||||||
|
|
||||||
def build(sign):
|
def build(sign):
|
||||||
for en, fr in DOCUMENTS:
|
for language in LANGUAGES:
|
||||||
command = ['xelatex', '-output-directory', TMP, en]
|
for document in DOCUMENTS:
|
||||||
if en == 'document':
|
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(command)
|
||||||
run(['makeglossaries', '-d', TMP, en])
|
pdf = f'{document[FRENCH]}.pdf'
|
||||||
run(['biber',
|
os.rename(os.path.join(TMP, f'{document[ENGLISH]}.pdf'),
|
||||||
'--input-directory', TMP,
|
os.path.join(TMP, pdf))
|
||||||
'--output-directory', TMP,
|
if not sign:
|
||||||
en,
|
os.rename(os.path.join(TMP, pdf), pdf)
|
||||||
])
|
else:
|
||||||
run(command)
|
run(['gpg',
|
||||||
run(command)
|
'--armor',
|
||||||
pdf = f'{fr}.pdf'
|
'--detach-sign',
|
||||||
os.rename(os.path.join(TMP, f'{en}.pdf'),
|
os.path.join(TMP, pdf),
|
||||||
os.path.join(TMP, pdf))
|
])
|
||||||
if not sign:
|
signature = f'{pdf}.asc'
|
||||||
os.rename(os.path.join(TMP, pdf), pdf)
|
for f in [pdf, signature]:
|
||||||
else:
|
os.rename(os.path.join(TMP, f), f)
|
||||||
run(['gpg',
|
lines = errun(['gpg',
|
||||||
'--armor',
|
'--verify', signature, pdf,
|
||||||
'--detach-sign',
|
]).decode('u8').splitlines()
|
||||||
os.path.join(TMP, pdf),
|
id = lines[2].index('"')
|
||||||
])
|
lines = [
|
||||||
signature = f'{pdf}.asc'
|
lines[0],
|
||||||
for f in [pdf, signature]:
|
lines[1],
|
||||||
os.rename(os.path.join(TMP, f), f)
|
lines[2][:id] + lines[4][id:]
|
||||||
lines = errun(['gpg',
|
.replace('@', ' @ ')
|
||||||
'--verify', signature, pdf,
|
.replace('.', ' ⋅ ')
|
||||||
]).decode('u8').splitlines()
|
] + lines[5:]
|
||||||
id = lines[2].index('"')
|
buffer = os.linesep.join(lines).encode('u8')
|
||||||
lines = [
|
with open(f'{pdf}.vrf', 'bw') as f:
|
||||||
lines[0],
|
f.write(buffer)
|
||||||
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():
|
def clean():
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
\newcommand{\import}[1]{\input{document/#1}}
|
\newcommand{\import}[1]{\input{thesis/#1}}
|
||||||
|
|
||||||
\import{settings}
|
\import{settings}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue