From d0b58a5a79865cb2c30cc093f471a97f946b9cea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20Ke=C3=9Fler?= Date: Thu, 16 Sep 2021 20:03:41 +0200 Subject: [PATCH] move lecture start / end markers and new lecture header to config file --- scripts/config.py | 3 +++ scripts/lectures.py | 5 ++--- scripts/notes.py | 4 ++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/scripts/config.py b/scripts/config.py index 2dcf9ee..d0e3019 100644 --- a/scripts/config.py +++ b/scripts/config.py @@ -23,3 +23,6 @@ COURSE_IGNORE_FILE = '.courseignore' COURSE_INFO_FILE = 'info.yaml' DEFAULT_MASTER_FILE_NAME = 'master.tex' MAX_LEN = 40 +LECTURE_START_MARKER = 'start lectures' +LECTURE_END_MARKER = 'end lectures' +DEFAULT_NEW_LECTURE_HEADER = r'\lecture{{{number}}}{{{date}}}{{}}' diff --git a/scripts/lectures.py b/scripts/lectures.py index 5c2ea83..03cc664 100755 --- a/scripts/lectures.py +++ b/scripts/lectures.py @@ -5,7 +5,7 @@ import re import subprocess from datetime import datetime -from config import get_week, DATE_FORMAT, LOCALE, DEFAULT_MASTER_FILE_NAME +from config import get_week, DATE_FORMAT, LOCALE, DEFAULT_MASTER_FILE_NAME, DEFAULT_NEW_LECTURE_HEADER # TODO locale.setlocale(locale.LC_TIME, LOCALE) @@ -110,11 +110,10 @@ class Lectures(list): date = today.strftime(DATE_FORMAT) new_lecture_path.touch() - new_lecture_path.write_text(f'\\lecture{{{new_lecture_number}}}{{{date}}}{{}}\n') + new_lecture_path.write_text(DEFAULT_NEW_LECTURE_HEADER.format(number=new_lecture_number, date=date)) self.read_files() lec = Lecture(new_lecture_path, self.course) return lec - diff --git a/scripts/notes.py b/scripts/notes.py index dbf24f0..1d83a03 100644 --- a/scripts/notes.py +++ b/scripts/notes.py @@ -35,7 +35,7 @@ class Notes: with filepath.open() as f: for line in f: # order of if-statements is important here! - if 'end lectures' in line: + if LECTURE_END_MARKER in line: part = 2 if part == 0: @@ -43,7 +43,7 @@ class Notes: if part == 2: footer += line - if 'start lectures' in line: + if LECTURE_START_MARKER in line: part = 1 return header, footer