Feat: pdflatex argument can be a str

This commit is contained in:
Bertrand Benjamin 2019-12-28 09:42:38 +01:00
parent 737d64e0a8
commit e311deeb6b

View File

@ -79,13 +79,14 @@ def feed(template, data, output="", force=0):
return output_p return output_p
def pdflatex(latex_file, output_dir=""): def pdflatex(tex_filename, output_dir=""):
""" Compile a latex file with pdflatex """ Compile a latex file with pdflatex
If output_dir is not set, it produce it next to the latex file. If output_dir is not set, it produce it next to the latex file.
""" """
latex_file = Path(tex_filename)
if not output_dir: if not output_dir:
output_dir = Path(latex_file).parent.resolve() output_dir = latex_file.parent.resolve()
logger.debug(f"output_dir for pdflatex is {output_dir}") logger.debug(f"output_dir for pdflatex is {output_dir}")
prev_cwd = Path.cwd() prev_cwd = Path.cwd()
@ -97,7 +98,7 @@ def pdflatex(latex_file, output_dir=""):
# "-halt-on-error", # "-halt-on-error",
"-interaction=nonstopmode", "-interaction=nonstopmode",
"-shell-escape", "-shell-escape",
str(Path(latex_file).name), str(latex_file.name),
], ],
stdout=subprocess.PIPE, stdout=subprocess.PIPE,
stderr=subprocess.PIPE, stderr=subprocess.PIPE,