Added --convert argument

This commit is contained in:
Profitroll 2023-04-27 13:53:41 +02:00
parent c405650c3a
commit c38d87379a
2 changed files with 19 additions and 4 deletions

21
main.py
View File

@ -1,18 +1,24 @@
from argparse import ArgumentParser
from datetime import datetime
from locale import LC_ALL, setlocale
from os import makedirs, path
from pathlib import Path
from typing import Any
from docx2pdf import convert
from docxtpl import DocxTemplate
parser = ArgumentParser(description="Ping script")
parser.add_argument(
"--convert",
dest="convert_output",
action="store_true",
help="convert output .docx files to .pdf",
)
from modules.utils import data_read, json_read
def local_if_available(data: dict, data_local: dict, *args: str) -> Any:
return
def main():
for lang in config["languages"]:
# data = json_read(Path("data", "default.json"))
@ -151,6 +157,7 @@ def main():
if __name__ == "__main__":
args = parser.parse_args()
config = json_read(Path("config.json"))
makedirs(Path(".cache"), exist_ok=True)
if not path.exists(Path(".cache", "location")):
@ -167,3 +174,9 @@ if __name__ == "__main__":
cached_location if signature_location == "" else signature_location
)
main()
if args.convert_output:
print(
f"Converting everything to PDF...",
flush=True,
)
convert(Path("output").absolute())

View File

@ -1 +1,3 @@
argparse==1.4.0
docx2pdf==0.1.8
docxtpl==0.16.6