From 602f6e43230afc2b25b13a7335bd5c4ac92f0e23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20Ke=C3=9Fler?= Date: Fri, 17 Sep 2021 10:37:47 +0200 Subject: [PATCH] add fallback.yaml to git. Get rid of nasty error handling in Notes class since now we have a fallback file --- scripts/config.py | 2 +- scripts/fallback.yaml | 20 ++++++++++++++++++++ scripts/notes.py | 22 +++++----------------- 3 files changed, 26 insertions(+), 18 deletions(-) create mode 100644 scripts/fallback.yaml diff --git a/scripts/config.py b/scripts/config.py index ac44415..950b694 100644 --- a/scripts/config.py +++ b/scripts/config.py @@ -22,4 +22,4 @@ LECTURE_END_MARKER = 'end lectures' DEFAULT_NEW_LECTURE_HEADER = r'\lecture[]{{{date}}}{{{title}}}' DEFAULT_LECTURE_SEARCH_REGEX = r'lecture.*({\d*})?{(.*?)}{(.*)}' DEFAULT_IMPORT_INDENTATION = 4 -FALLBACK_COURSE_INFO_FILE = Path('info.yaml').resolve() \ No newline at end of file +FALLBACK_COURSE_INFO_FILE = Path('fallback.yaml').resolve() diff --git a/scripts/fallback.yaml b/scripts/fallback.yaml new file mode 100644 index 0000000..5610ff5 --- /dev/null +++ b/scripts/fallback.yaml @@ -0,0 +1,20 @@ +title: 'Unnamed course' +short: 'unnamed' +language: 'english' +links: + url: '' + ecampus: '' + sciebo: '' + basis: '' + github: '' +exercises: + path: 'ub' + name: 'Maximilian Keßler' +literature: + path: 'doc' +notes: + path: '.' + master_file: 'master.tex' + full_file: 'full.tex' + lectures: + path: '.' diff --git a/scripts/notes.py b/scripts/notes.py index ca6983e..70525d8 100644 --- a/scripts/notes.py +++ b/scripts/notes.py @@ -11,23 +11,11 @@ from edit import edit class Notes: def __init__(self, course): self.course = course - if 'notes' in course.info: - self.info = course.info['notes'] - else: - self.info = [] - if 'path' in self.info: - self.root = course.path / self.info['path'] - self.root.mkdir(parents=True, exist_ok=True) - else: - self.root = course.path - if 'master_file' in self.info: - self.master_file = self.root / self.info['master_file'] - else: - self.master_file = self.root / DEFAULT_MASTER_FILE_NAME - if 'full_file' in self.info: - self.full_file: Path = self.root / self.info['full_file'] - else: - self.full_file: Path = None + self.info = course.info['notes'] + self.root = course.path / self.info['path'] + self.root.mkdir(parents=True, exist_ok=True) + self.master_file = self.root / self.info['master_file'] + self.full_file = self.root / self.info['full_file'] self._lectures = None @staticmethod