python-docx-template/tests/module_execute.py
Eric Lapouyade b0a5de05aa Codestyling
2021-10-01 08:31:19 +02:00

22 lines
567 B
Python

import os
from pathlib import Path
TEMPLATE_PATH = 'templates/module_execute_tpl.docx'
JSON_PATH = 'templates/module_execute.json'
OUTPUT_FILENAME = 'output/module_execute.docx'
OVERWRITE = '-o'
QUIET = '-q'
output_path = Path(OUTPUT_FILENAME)
if output_path.exists():
output_path.unlink()
os.chdir(Path(__file__).parent)
cmd = f'python -m docxtpl {TEMPLATE_PATH} {JSON_PATH} {OUTPUT_FILENAME} {OVERWRITE} {QUIET}'
print(f'Executing "{cmd}" ...')
os.system(cmd)
if output_path.exists():
print(f' --> File {output_path.resolve()} has been generated.')