diff --git a/scripts/links.py b/scripts/links.py index 7389e82..efbeebf 100644 --- a/scripts/links.py +++ b/scripts/links.py @@ -1,14 +1,18 @@ import subprocess +from typing import Dict, List class Links: def __init__(self, course): self.course = course # A course - self.info = course.info['links'] + self.info: Dict = course.info['links'] def open(self, key: str): self.open_link_in_browser(self.info[key]) + def available(self) -> List[str]: + return [key for key in self.info.keys() if self.info[key] != ''] + @staticmethod def open_link_in_browser(url): result = subprocess.run( diff --git a/scripts/open.py b/scripts/open.py new file mode 100644 index 0000000..a84b9c9 --- /dev/null +++ b/scripts/open.py @@ -0,0 +1,36 @@ +#!/usr/bin/python3 +from courses import Courses +import sys + + +def open_spec(specification: str): + current = Courses().current + + switcher = { + 'full': current.notes.open_full, + 'master': current.notes.open_master + } + + if specification in switcher.keys(): + return switcher[specification]() + + link_type = { + 'webpage': 'webpage', + 'w': 'webpage', + 'url': 'webpage', + 'u': 'webpage', + 'ecampus': 'ecampus', + 'e': 'ecampus', + 'sciebo': 'sciebo', + 's': 'sciebo', + 'basis': 'basis', + 'b': 'basis', + 'github': 'github', + 'g': 'github' + } + return current.links.open(link_type[specification]) + + +if __name__ == "__main__": + for arg in sys.argv[1:]: + open_spec(arg)