24 lines
529 B
Python
24 lines
529 B
Python
import json
|
|
import os
|
|
import sys
|
|
|
|
from docxtpl import DocxTemplate
|
|
|
|
from tools.parsexlsx import run
|
|
|
|
|
|
def main(path):
|
|
resjson = run(path)
|
|
res = json.loads(resjson)
|
|
barcode = res['c']['barcode']
|
|
tplpath = os.path.join(os.path.dirname(__file__), 'template', 'nreport.docx')
|
|
tpl = DocxTemplate(tplpath)
|
|
tpl.render(res)
|
|
path = os.path.join(os.path.dirname(__file__), 'result', f'{barcode}.docx')
|
|
tpl.save(path)
|
|
return path
|
|
|
|
|
|
if __name__ == '__main__':
|
|
main(sys.argv[1])
|