Added --convert argument
This commit is contained in:
parent
c405650c3a
commit
c38d87379a
21
main.py
21
main.py
@ -1,18 +1,24 @@
|
|||||||
|
from argparse import ArgumentParser
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from locale import LC_ALL, setlocale
|
from locale import LC_ALL, setlocale
|
||||||
from os import makedirs, path
|
from os import makedirs, path
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
|
from docx2pdf import convert
|
||||||
from docxtpl import DocxTemplate
|
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
|
from modules.utils import data_read, json_read
|
||||||
|
|
||||||
|
|
||||||
def local_if_available(data: dict, data_local: dict, *args: str) -> Any:
|
|
||||||
return
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
for lang in config["languages"]:
|
for lang in config["languages"]:
|
||||||
# data = json_read(Path("data", "default.json"))
|
# data = json_read(Path("data", "default.json"))
|
||||||
@ -151,6 +157,7 @@ def main():
|
|||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
args = parser.parse_args()
|
||||||
config = json_read(Path("config.json"))
|
config = json_read(Path("config.json"))
|
||||||
makedirs(Path(".cache"), exist_ok=True)
|
makedirs(Path(".cache"), exist_ok=True)
|
||||||
if not path.exists(Path(".cache", "location")):
|
if not path.exists(Path(".cache", "location")):
|
||||||
@ -167,3 +174,9 @@ if __name__ == "__main__":
|
|||||||
cached_location if signature_location == "" else signature_location
|
cached_location if signature_location == "" else signature_location
|
||||||
)
|
)
|
||||||
main()
|
main()
|
||||||
|
if args.convert_output:
|
||||||
|
print(
|
||||||
|
f"Converting everything to PDF...",
|
||||||
|
flush=True,
|
||||||
|
)
|
||||||
|
convert(Path("output").absolute())
|
||||||
|
@ -1 +1,3 @@
|
|||||||
|
argparse==1.4.0
|
||||||
|
docx2pdf==0.1.8
|
||||||
docxtpl==0.16.6
|
docxtpl==0.16.6
|
Loading…
Reference in New Issue
Block a user