add open.py file to easily open course-related stuff
This commit is contained in:
parent
9b528a91a2
commit
7f20952fb4
2 changed files with 41 additions and 1 deletions
|
@ -1,14 +1,18 @@
|
||||||
import subprocess
|
import subprocess
|
||||||
|
from typing import Dict, List
|
||||||
|
|
||||||
|
|
||||||
class Links:
|
class Links:
|
||||||
def __init__(self, course):
|
def __init__(self, course):
|
||||||
self.course = course # A course
|
self.course = course # A course
|
||||||
self.info = course.info['links']
|
self.info: Dict = course.info['links']
|
||||||
|
|
||||||
def open(self, key: str):
|
def open(self, key: str):
|
||||||
self.open_link_in_browser(self.info[key])
|
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
|
@staticmethod
|
||||||
def open_link_in_browser(url):
|
def open_link_in_browser(url):
|
||||||
result = subprocess.run(
|
result = subprocess.run(
|
||||||
|
|
36
scripts/open.py
Normal file
36
scripts/open.py
Normal file
|
@ -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)
|
Loading…
Reference in a new issue