37 lines
859 B
Python
37 lines
859 B
Python
MSVG = 'template.svg'
|
|
TEMPL = '0xNN'
|
|
NREG = 4
|
|
N = 30
|
|
|
|
|
|
import sys
|
|
import subprocess
|
|
|
|
if N > 255:
|
|
print('cannot do it!')
|
|
sys.exit()
|
|
|
|
addresses = [hex(i).replace("0x", "0x0") for i in range(N//2+1)] + \
|
|
[hex(i) for i in range(N//2+1,N)] + \
|
|
[f'REG{i}' for i in range(NREG)]
|
|
|
|
msvg = open(MSVG).read()
|
|
delete = []
|
|
to_join = []
|
|
for a in addresses:
|
|
print(f'Processing {a}...')
|
|
new_svg = a+MSVG
|
|
new_svg_pdf = new_svg.replace('.svg', '.pdf')
|
|
with open(new_svg, 'wt') as svg:
|
|
svg.write(msvg.replace(TEMPL,a))
|
|
delete.extend([new_svg, new_svg_pdf])
|
|
subprocess.run(['inkscape', '--export-filename='+new_svg_pdf, new_svg], capture_output=True)
|
|
to_join.append(new_svg_pdf)
|
|
|
|
subprocess.run(['pdftk'] + to_join + ['output', 'materials.pdf'], capture_output=True)
|
|
subprocess.check_call(['rm'] + delete)
|
|
|
|
|
|
|
|
|
|
|