diff --git a/scripts/courses.py b/scripts/courses.py index ba68b15..5c9ff63 100644 --- a/scripts/courses.py +++ b/scripts/courses.py @@ -7,6 +7,7 @@ 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 from notes import Notes +from links import Links from utils import merge_dictionaries @@ -30,6 +31,13 @@ class Course: fallback_file = {} self.info = merge_dictionaries(self.info, fallback_file) self._notes = None + self._links = None + + @property + def links(self) -> Links: + if not self._links: + self._links = Links(self) + return self._links @property def notes(self) -> Notes: diff --git a/scripts/links.py b/scripts/links.py new file mode 100644 index 0000000..7389e82 --- /dev/null +++ b/scripts/links.py @@ -0,0 +1,18 @@ +import subprocess + + +class Links: + def __init__(self, course): + self.course = course # A course + self.info = course.info['links'] + + def open(self, key: str): + self.open_link_in_browser(self.info[key]) + + @staticmethod + def open_link_in_browser(url): + result = subprocess.run( + ['qutebrowser', str(url)], + stdout=subprocess.DEVNULL, + stderr=subprocess.DEVNULL + )