add edit file for central place of edit method. add methods to edit master file or full file
This commit is contained in:
parent
9f498a7c61
commit
12b1632f8e
5 changed files with 45 additions and 15 deletions
|
@ -1,10 +0,0 @@
|
||||||
#!/bin/python3
|
|
||||||
from courses import Courses
|
|
||||||
|
|
||||||
for course in Courses():
|
|
||||||
script = course.notes
|
|
||||||
lectures = script.lectures
|
|
||||||
|
|
||||||
r = lectures.parse_range_string('all')
|
|
||||||
script.update_lectures_in_master(r)
|
|
||||||
script.compile_master()
|
|
13
scripts/compile_all_full_versions.py
Executable file
13
scripts/compile_all_full_versions.py
Executable file
|
@ -0,0 +1,13 @@
|
||||||
|
#!/bin/python3
|
||||||
|
from courses import Courses
|
||||||
|
|
||||||
|
for course in Courses():
|
||||||
|
notes = course.notes
|
||||||
|
if notes.full_file:
|
||||||
|
notes.compile_full()
|
||||||
|
continue
|
||||||
|
else:
|
||||||
|
lectures = notes.lectures
|
||||||
|
r = lectures.parse_range_string('all')
|
||||||
|
notes.update_lectures_in_master(r)
|
||||||
|
notes.compile_master()
|
12
scripts/edit.py
Normal file
12
scripts/edit.py
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
#! /usr/bin/python3
|
||||||
|
|
||||||
|
import subprocess
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
|
||||||
|
def edit(filepath: Path):
|
||||||
|
subprocess.Popen([
|
||||||
|
"termite",
|
||||||
|
"-e",
|
||||||
|
f"vim --servername tex-vorlesung --remote-silent {str(filepath)}"
|
||||||
|
])
|
|
@ -7,6 +7,7 @@ from datetime import datetime
|
||||||
|
|
||||||
from config import DATE_FORMAT, LOCALE, DEFAULT_NEW_LECTURE_HEADER, DEFAULT_LECTURE_SEARCH_REGEX
|
from config import DATE_FORMAT, LOCALE, DEFAULT_NEW_LECTURE_HEADER, DEFAULT_LECTURE_SEARCH_REGEX
|
||||||
from utils import get_week
|
from utils import get_week
|
||||||
|
from edit import edit
|
||||||
|
|
||||||
# TODO
|
# TODO
|
||||||
locale.setlocale(locale.LC_TIME, LOCALE)
|
locale.setlocale(locale.LC_TIME, LOCALE)
|
||||||
|
@ -44,11 +45,7 @@ class Lecture:
|
||||||
self.course = course
|
self.course = course
|
||||||
|
|
||||||
def edit(self):
|
def edit(self):
|
||||||
subprocess.Popen([
|
edit(self.file_path)
|
||||||
"x-terminal-emulator",
|
|
||||||
"-e", "zsh", "-i", "-c",
|
|
||||||
f"\\vim --servername kulak --remote-silent {str(self.file_path)}"
|
|
||||||
])
|
|
||||||
|
|
||||||
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}">'
|
||||||
|
|
|
@ -5,6 +5,7 @@ from pathlib import Path
|
||||||
from lectures import Lectures, number2filename
|
from lectures import Lectures, number2filename
|
||||||
from config import DEFAULT_MASTER_FILE_NAME, LECTURE_START_MARKER, LECTURE_END_MARKER, DEFAULT_IMPORT_INDENTATION
|
from config import DEFAULT_MASTER_FILE_NAME, LECTURE_START_MARKER, LECTURE_END_MARKER, DEFAULT_IMPORT_INDENTATION
|
||||||
from parse_counters import parse_counters, dict2setcounters
|
from parse_counters import parse_counters, dict2setcounters
|
||||||
|
from edit import edit
|
||||||
|
|
||||||
|
|
||||||
class Notes:
|
class Notes:
|
||||||
|
@ -85,6 +86,12 @@ class Notes:
|
||||||
if self.full_file:
|
if self.full_file:
|
||||||
self.update_lectures_in_file(self.full_file, lecture_list)
|
self.update_lectures_in_file(self.full_file, lecture_list)
|
||||||
|
|
||||||
|
def edit_master(self):
|
||||||
|
edit(self.master_file)
|
||||||
|
|
||||||
|
def edit_full(self):
|
||||||
|
edit(self.full_file)
|
||||||
|
|
||||||
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', str(self.master_file)],
|
||||||
|
@ -94,6 +101,17 @@ class Notes:
|
||||||
)
|
)
|
||||||
return result.returncode
|
return result.returncode
|
||||||
|
|
||||||
|
def compile_full(self):
|
||||||
|
if not self.full_file:
|
||||||
|
return 0
|
||||||
|
result = subprocess.run(
|
||||||
|
['latexmk', '-f', '-interaction=nonstopmode', str(self.full_file)],
|
||||||
|
stdout=subprocess.DEVNULL,
|
||||||
|
stderr=subprocess.DEVNULL,
|
||||||
|
cwd=str(self.root)
|
||||||
|
)
|
||||||
|
return result.returncode
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def lectures(self):
|
def lectures(self):
|
||||||
if not self._lectures:
|
if not self._lectures:
|
||||||
|
|
Loading…
Reference in a new issue