diff --git a/scripts/courses.py b/scripts/courses.py index 2a63bef..ba68b15 100644 --- a/scripts/courses.py +++ b/scripts/courses.py @@ -2,6 +2,7 @@ import warnings import yaml +from typing import List from config import ROOT, CURRENT_COURSE_ROOT, CURRENT_COURSE_SYMLINK, CURRENT_COURSE_WATCH_FILE, COURSE_IGNORE_FILE, \ COURSE_INFO_FILE_NAME, FALLBACK_COURSE_INFO_FILE @@ -31,7 +32,7 @@ class Course: self._notes = None @property - def notes(self): + def notes(self) -> Notes: if not self._notes: self._notes = Notes(self) return self._notes @@ -42,7 +43,7 @@ class Course: return self.path == other.path -def ignored_courses(): +def ignored_courses() -> List[Course]: if (ROOT / COURSE_IGNORE_FILE).is_file(): with open(ROOT / COURSE_IGNORE_FILE) as ignore: lines = ignore.readlines() @@ -53,7 +54,7 @@ def ignored_courses(): return [] -def read_files(): +def read_files() -> List[Course]: course_directories = [x for x in ROOT.iterdir() if x.is_dir() and x not in ignored_courses()] _courses = [Course(path) for path in course_directories] return sorted(_courses, key=lambda c: c.name) @@ -64,7 +65,7 @@ class Courses(list): list.__init__(self, read_files()) @property - def current(self): + def current(self) -> Course: return Course(CURRENT_COURSE_ROOT.resolve()) @current.setter diff --git a/scripts/notes.py b/scripts/notes.py index b14ccbb..533ae35 100644 --- a/scripts/notes.py +++ b/scripts/notes.py @@ -1,6 +1,7 @@ #!/usr/bin/python3 import subprocess from pathlib import Path +from typing import Dict from config import LECTURE_START_MARKER, LECTURE_END_MARKER, DEFAULT_IMPORT_INDENTATION from edit import edit @@ -10,12 +11,12 @@ from parse_counters import parse_counters, dict2setcounters class Notes: def __init__(self, course): - self.course = course - self.info = course.info['notes'] - self.root = course.path / self.info['path'] + self.course = course # A course + self.info: Dict = course.info['notes'] + self.root: Path = 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.master_file: Path = self.root / self.info['master_file'] + self.full_file: Path = self.root / self.info['full_file'] self._lectures = None @staticmethod @@ -80,6 +81,20 @@ class Notes: def edit_full(self): edit(self.full_file) + def open_master(self): + result = subprocess.run( + ['zathura', str(self.master_file.with_suffix('.pdf'))], + stdout=subprocess.DEVNULL, + stderr=subprocess.DEVNULL + ) + + def open_full(self): + result = subprocess.run( + ['zathura', str(self.full_file.with_suffix('.pdf'))], + stdout=subprocess.DEVNULL, + stderr=subprocess.DEVNULL + ) + def compile_master(self): result = subprocess.run( ['latexmk', '-f', '-interaction=nonstopmode', str(self.master_file)],