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

63 lines
1.1 KiB
Python
Raw Normal View History

2020-04-22 18:56:05 +02:00
#! /usr/bin/python3 -B
import os
2020-04-27 04:25:41 +02:00
import shutil
2020-04-22 18:56:05 +02:00
import subprocess
DOCUMENTS = [
'document',
'présentation',
]
2020-04-27 04:25:41 +02:00
TMP = 'tmp'
2020-04-22 18:56:05 +02:00
2020-04-27 04:25:41 +02:00
def run(args):
2020-04-27 00:39:49 +02:00
subprocess.call(args)
2020-04-27 04:25:41 +02:00
def build():
2020-04-22 18:56:05 +02:00
for document in DOCUMENTS:
2020-04-27 04:25:41 +02:00
command = ['xelatex',
'-output-directory', TMP,
document,
]
run(command)
run(['makeglossaries',
'-d', TMP,
document,
])
2020-04-27 22:52:32 +02:00
run(['biber',
'--input-directory', TMP,
'--output-directory', TMP,
document,
])
2020-04-27 04:25:41 +02:00
run(command)
2020-04-28 01:39:51 +02:00
run(command)
2020-04-27 04:25:41 +02:00
pdf = f'{document}.pdf'
2020-05-01 16:40:56 +02:00
run(['gpg',
'--armor',
2020-05-01 17:02:46 +02:00
'--detach-sign',
os.path.join(TMP, pdf),
2020-05-01 16:40:56 +02:00
])
2020-05-01 16:55:42 +02:00
signature = f'{pdf}.asc'
for f in [pdf, signature]:
os.rename(os.path.join(TMP, f), f)
2020-04-22 18:56:05 +02:00
2020-04-27 04:25:41 +02:00
def clean():
shutil.rmtree(TMP, ignore_errors=True)
2020-04-22 18:56:05 +02:00
def main():
file = os.path.realpath(__file__)
directory = os.path.dirname(file)
2020-04-27 04:25:41 +02:00
os.chdir(directory)
clean()
os.makedirs(TMP)
build()
clean()
2020-04-22 18:56:05 +02:00
if __name__ == '__main__':
main()