-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrun.py
36 lines (29 loc) · 986 Bytes
/
run.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
"""
Create main.pdf.
"""
import os
import subprocess
from pathlib import Path
from sys import platform
from typing import List
from generator.generate import Generator
INKSCAPE: str = "inkscape"
if platform == "darwin":
INKSCAPE = "/Applications/Inkscape.app/Contents/Resources/bin/inkscape"
MAIN_ID: str = "main"
if __name__ == "__main__":
generator = Generator("image")
generator.generate()
os.makedirs("pdf", exist_ok=True)
for file_name in os.listdir("image"): # type: str
id_: str = file_name[:-4]
command: List[str] = [
INKSCAPE, "-z", "-A",
str((Path(".") / "pdf" / f"{id_}.pdf").absolute()),
str((Path(".") / "image" / f"{id_}.svg").absolute())]
print(f"Converting {id_}...")
subprocess.run(command)
print("Creating PDF...")
subprocess.run(["makeindex", MAIN_ID])
subprocess.run(["bibtex", MAIN_ID])
subprocess.run(["pdflatex", "-interaction=nonstopmode", MAIN_ID])