build/sign
This commit is contained in:
parent
6e92d619fa
commit
d505187624
1 changed files with 27 additions and 25 deletions
|
@ -3,6 +3,7 @@
|
||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
import subprocess
|
import subprocess
|
||||||
|
import sys
|
||||||
|
|
||||||
DOCUMENTS = [
|
DOCUMENTS = [
|
||||||
('document', 'mémoire'),
|
('document', 'mémoire'),
|
||||||
|
@ -20,7 +21,7 @@ def errun(command):
|
||||||
command, stderr=subprocess.STDOUT)
|
command, stderr=subprocess.STDOUT)
|
||||||
|
|
||||||
|
|
||||||
def build():
|
def build(sign):
|
||||||
for en, fr in DOCUMENTS:
|
for en, fr in DOCUMENTS:
|
||||||
command = ['xelatex',
|
command = ['xelatex',
|
||||||
'-output-directory', TMP,
|
'-output-directory', TMP,
|
||||||
|
@ -40,29 +41,30 @@ def build():
|
||||||
run(command)
|
run(command)
|
||||||
os.rename(os.path.join(TMP, f'{en}.pdf'),
|
os.rename(os.path.join(TMP, f'{en}.pdf'),
|
||||||
os.path.join(TMP, f'{fr}.pdf'))
|
os.path.join(TMP, f'{fr}.pdf'))
|
||||||
pdf = f'{fr}.pdf'
|
if sign:
|
||||||
run(['gpg',
|
pdf = f'{fr}.pdf'
|
||||||
'--armor',
|
run(['gpg',
|
||||||
'--detach-sign',
|
'--armor',
|
||||||
os.path.join(TMP, pdf),
|
'--detach-sign',
|
||||||
])
|
os.path.join(TMP, pdf),
|
||||||
signature = f'{pdf}.asc'
|
])
|
||||||
for f in [pdf, signature]:
|
signature = f'{pdf}.asc'
|
||||||
os.rename(os.path.join(TMP, f), f)
|
for f in [pdf, signature]:
|
||||||
lines = errun(['gpg',
|
os.rename(os.path.join(TMP, f), f)
|
||||||
'--verify', signature, pdf,
|
lines = errun(['gpg',
|
||||||
]).decode('u8').splitlines()
|
'--verify', signature, pdf,
|
||||||
using = lines[1].index('using')
|
]).decode('u8').splitlines()
|
||||||
id = lines[2].index('"')
|
using = lines[1].index('using')
|
||||||
lines = [
|
id = lines[2].index('"')
|
||||||
lines[0][:using] + lines[1][using:],
|
lines = [
|
||||||
lines[2][:id] + lines[4][id:]
|
lines[0][:using] + lines[1][using:],
|
||||||
.replace('@', ' @ ')
|
lines[2][:id] + lines[4][id:]
|
||||||
.replace('.', ' ⋅ ')
|
.replace('@', ' @ ')
|
||||||
] + lines[5:]
|
.replace('.', ' ⋅ ')
|
||||||
buffer = os.linesep.join(lines).encode('u8')
|
] + lines[5:]
|
||||||
with open(f'{pdf}.vrf', 'bw') as f:
|
buffer = os.linesep.join(lines).encode('u8')
|
||||||
f.write(buffer)
|
with open(f'{pdf}.vrf', 'bw') as f:
|
||||||
|
f.write(buffer)
|
||||||
|
|
||||||
|
|
||||||
def clean():
|
def clean():
|
||||||
|
@ -75,7 +77,7 @@ def main():
|
||||||
os.chdir(directory)
|
os.chdir(directory)
|
||||||
clean()
|
clean()
|
||||||
os.makedirs(TMP)
|
os.makedirs(TMP)
|
||||||
build()
|
build(len(sys.argv) == 1)
|
||||||
clean()
|
clean()
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue