add method to generate lecture environment, adapt all edit methods to new editing

This commit is contained in:
Maximilian Keßler 2021-09-18 14:39:05 +02:00
parent 7728ec97ca
commit 6e9f6c0c06
2 changed files with 15 additions and 7 deletions

View file

@ -55,7 +55,7 @@ class Lecture:
self.notes = notes self.notes = notes
def edit(self): 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): def __str__(self):
return f'<Lecture {self.course.info["short"]} {self.number} "{self.title}">' return f'<Lecture {self.course.info["short"]} {self.number} "{self.title}">'

View file

@ -1,4 +1,5 @@
#!/usr/bin/python3 #!/usr/bin/python3
import os
import subprocess import subprocess
from pathlib import Path from pathlib import Path
from typing import Dict from typing import Dict
@ -81,10 +82,10 @@ class Notes:
self.update_lectures_in_file(self.full_file, lecture_list) self.update_lectures_in_file(self.full_file, lecture_list)
def edit_master(self): 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): def edit_full(self):
edit(self.full_file) edit(self.full_file, rootpath=self.root, env=self.environment())
def open_master(self): def open_master(self):
result = subprocess.run( result = subprocess.run(
@ -104,10 +105,11 @@ class Notes:
def compile_master(self): def compile_master(self):
result = subprocess.run( result = subprocess.run(
['latexmk', '-f', '-interaction=nonstopmode', str(self.master_file)], ['latexmk', '-f', '-interaction=nonstopmode', '-dvi-', '-pdf', str(self.master_file)],
stdout=subprocess.DEVNULL, stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL, stderr=subprocess.DEVNULL,
cwd=str(self.root) cwd=str(self.root),
env=self.environment()
) )
return result.returncode return result.returncode
@ -115,13 +117,19 @@ class Notes:
if not self.full_file: if not self.full_file:
return 0 return 0
result = subprocess.run( result = subprocess.run(
['latexmk', '-f', '-interaction=nonstopmode', str(self.full_file)], ['latexmk', '-f', '-interaction=nonstopmode', '-dvi-', '-pdf', str(self.full_file)],
stdout=subprocess.DEVNULL, stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL, stderr=subprocess.DEVNULL,
cwd=str(self.root) cwd=str(self.root),
env=self.environment()
) )
return result.returncode return result.returncode
def environment(self):
env = os.environ
env["TEXINPUTS"] = str(self.texinputs) + '//:'
return env
@property @property
def lectures(self): def lectures(self):
if not self._lectures: if not self._lectures: