2021-09-17 12:42:08 +02:00
|
|
|
import subprocess
|
2021-09-17 13:02:54 +02:00
|
|
|
from typing import Dict, List
|
2021-09-17 12:42:08 +02:00
|
|
|
|
|
|
|
|
|
|
|
class Links:
|
|
|
|
def __init__(self, course):
|
|
|
|
self.course = course # A course
|
2021-09-17 13:02:54 +02:00
|
|
|
self.info: Dict = course.info['links']
|
2021-09-17 12:42:08 +02:00
|
|
|
|
|
|
|
def open(self, key: str):
|
|
|
|
self.open_link_in_browser(self.info[key])
|
|
|
|
|
2021-09-17 13:02:54 +02:00
|
|
|
def available(self) -> List[str]:
|
|
|
|
return [key for key in self.info.keys() if self.info[key] != '']
|
|
|
|
|
2021-09-17 12:42:08 +02:00
|
|
|
@staticmethod
|
|
|
|
def open_link_in_browser(url):
|
|
|
|
result = subprocess.run(
|
|
|
|
['qutebrowser', str(url)],
|
|
|
|
stdout=subprocess.DEVNULL,
|
|
|
|
stderr=subprocess.DEVNULL
|
|
|
|
)
|