From 6e9f6c0c06c5444e1560e100acfd65c762b7a663 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20Ke=C3=9Fler?= Date: Sat, 18 Sep 2021 14:39:05 +0200 Subject: [PATCH] add method to generate lecture environment, adapt all edit methods to new editing --- scripts/lectures.py | 2 +- scripts/notes.py | 20 ++++++++++++++------ 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/scripts/lectures.py b/scripts/lectures.py index 6ce296e..fc80f49 100644 --- a/scripts/lectures.py +++ b/scripts/lectures.py @@ -55,7 +55,7 @@ class Lecture: self.notes = notes def edit(self): - edit(self.file_path, rootpath=self.notes.root, texinputs=self.notes.texinputs) + edit(self.file_path, rootpath=self.notes.root, env=self.notes.environment()) def __str__(self): return f'' diff --git a/scripts/notes.py b/scripts/notes.py index 1902a63..25da47c 100644 --- a/scripts/notes.py +++ b/scripts/notes.py @@ -1,4 +1,5 @@ #!/usr/bin/python3 +import os import subprocess from pathlib import Path from typing import Dict @@ -81,10 +82,10 @@ class Notes: self.update_lectures_in_file(self.full_file, lecture_list) def edit_master(self): - edit(self.master_file, rootpath=self.root, texinputs=self.texinputs) + edit(self.master_file, rootpath=self.root, env=self.environment()) def edit_full(self): - edit(self.full_file) + edit(self.full_file, rootpath=self.root, env=self.environment()) def open_master(self): result = subprocess.run( @@ -104,10 +105,11 @@ class Notes: def compile_master(self): result = subprocess.run( - ['latexmk', '-f', '-interaction=nonstopmode', str(self.master_file)], + ['latexmk', '-f', '-interaction=nonstopmode', '-dvi-', '-pdf', str(self.master_file)], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, - cwd=str(self.root) + cwd=str(self.root), + env=self.environment() ) return result.returncode @@ -115,13 +117,19 @@ class Notes: if not self.full_file: return 0 result = subprocess.run( - ['latexmk', '-f', '-interaction=nonstopmode', str(self.full_file)], + ['latexmk', '-f', '-interaction=nonstopmode', '-dvi-', '-pdf', str(self.full_file)], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, - cwd=str(self.root) + cwd=str(self.root), + env=self.environment() ) return result.returncode + def environment(self): + env = os.environ + env["TEXINPUTS"] = str(self.texinputs) + '//:' + return env + @property def lectures(self): if not self._lectures: