include relative path to master file into each new lecture for vimtex
This commit is contained in:
parent
01230ea178
commit
a49f49a60b
1 changed files with 12 additions and 9 deletions
|
@ -1,5 +1,6 @@
|
||||||
#!/usr/bin/python3
|
#!/usr/bin/python3
|
||||||
|
from pathlib import Path, PurePath
|
||||||
|
import os
|
||||||
import locale
|
import locale
|
||||||
import re
|
import re
|
||||||
import subprocess
|
import subprocess
|
||||||
|
@ -55,18 +56,18 @@ class Lecture:
|
||||||
|
|
||||||
|
|
||||||
class Lectures(list):
|
class Lectures(list):
|
||||||
def __init__(self, script):
|
def __init__(self, notes):
|
||||||
self.course = script.course
|
self.course = notes.course
|
||||||
self.script = script
|
self.notes = notes
|
||||||
if 'lectures' in script.info:
|
if 'lectures' in notes.info:
|
||||||
self.info = script.info['lectures']
|
self.info = notes.info['lectures']
|
||||||
else:
|
else:
|
||||||
self.info = []
|
self.info = []
|
||||||
if 'path' in self.info:
|
if 'path' in self.info:
|
||||||
self.root = script.root / self.info['path']
|
self.root = notes.root / self.info['path']
|
||||||
self.root.mkdir(parents=True, exist_ok=True)
|
self.root.mkdir(parents=True, exist_ok=True)
|
||||||
else:
|
else:
|
||||||
self.root = script.root
|
self.root = notes.root
|
||||||
list.__init__(self, self.read_files())
|
list.__init__(self, self.read_files())
|
||||||
|
|
||||||
def read_files(self):
|
def read_files(self):
|
||||||
|
@ -110,8 +111,10 @@ class Lectures(list):
|
||||||
today = datetime.today()
|
today = datetime.today()
|
||||||
date = today.strftime(DATE_FORMAT)
|
date = today.strftime(DATE_FORMAT)
|
||||||
|
|
||||||
|
vimtex_root_str = f"%! TEX root = {str(os.path.relpath(self.notes.master_file, self.root))}\n"
|
||||||
|
header_str = DEFAULT_NEW_LECTURE_HEADER.format(number=new_lecture_number, date=date)
|
||||||
new_lecture_path.touch()
|
new_lecture_path.touch()
|
||||||
new_lecture_path.write_text(DEFAULT_NEW_LECTURE_HEADER.format(number=new_lecture_number, date=date))
|
new_lecture_path.write_text(vimtex_root_str + header_str)
|
||||||
|
|
||||||
self.read_files()
|
self.read_files()
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue