From 1cb676e162521d622d1c60ec46332ef586795365 Mon Sep 17 00:00:00 2001 From: Christian Meesters Date: Fri, 19 Apr 2024 12:19:21 +0200 Subject: [PATCH] feat: render can skip rerun upcon request (will safe devel time) --- render | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/render b/render index 7c69002..dc4b52b 100755 --- a/render +++ b/render @@ -6,6 +6,7 @@ import logging import os from pathlib import Path import re +import shlex import shutil import subprocess import sys @@ -109,12 +110,11 @@ def get_pdf_name(filename): def run_pdflatex(fname="out.tex", path="."): outdir = os.path.realpath(os.path.join(os.getcwd(), "slides")) - - subprocess.call( - ["pdflatex", "-synctex=1", "-interaction=nonstopmode", fname], cwd=path - ) + cmd = shlex.split(f"pdflatex -synctex=1 -interaction=nonstopmode {fname}") + retcode = subprocess.call(cmd, cwd=path) pdfname = get_pdf_name(fname) shutil.copy(os.path.join(path, pdfname), os.path.join(outdir, pdfname)) + return retcode def parse_config(fname): @@ -201,6 +201,9 @@ if __name__ == "__main__": default="config/config.yaml", help="indicate the configuration YAML file - default: 'config/config.yaml'", ) + parser.add_argument( + "-n", "--no-rerun", default=False, action=argparse.BooleanOptionalAction + ) args = parser.parse_args() logger = logging.getLogger(__name__) @@ -233,8 +236,10 @@ if __name__ == "__main__": for section_estimate, fname in enumerate(file_list): to_adapt = os.path.join(tempdir, "slides", fname) + ".tex" find_and_replace_sections(boundaries, section_estimate, to_adapt) - # now the typesetting needs to be triggered run_pdflatex(fname=args.master_tex, path=os.path.join(tempdir, "slides")) # re-run might be required + if args.no_rerun: + print("no rerun as requested") + sys.exit() run_pdflatex(fname=args.master_tex, path=os.path.join(tempdir, "slides"))