diff --git a/src/aura_engine/scheduling/timetable.py b/src/aura_engine/scheduling/timetable.py index 9d7e3e88342f4618a49bc9aee636c382957e923b..88e4c943cb5aa722a17808a5e705c44f9a227b35 100644 --- a/src/aura_engine/scheduling/timetable.py +++ b/src/aura_engine/scheduling/timetable.py @@ -28,7 +28,6 @@ from __future__ import annotations import logging import os -import pathlib from datetime import datetime import confuse @@ -63,7 +62,7 @@ class TimetableService: Initialize. Args: - cache_location (str): Path to folder where timetable.json is cached. + cache_location (str): Path to folder where timetable.json is stored. """ self.config = AuraConfig.instance.config self.logger = logging.getLogger("engine") @@ -75,7 +74,6 @@ class TimetableService: os.makedirs(cache_location, exist_ok=True) self.cache_location = cache_location self.timetable_file = self.cache_location + "/timetable.json" - self.load_timetable() @synchronized def refresh(self): @@ -110,20 +108,6 @@ class TimetableService: self.logger.warning(msg) self.logger.debug("Exception in API Fetcher: \n" + str(response.exception)) - def load_timetable(self): - """ - Loads the timetable from the local JSON file used for caching. - """ - if self.timetable_file_exists(): - try: - with open(self.timetable_file, "r") as file: - self.timetable = jsonpickle.decode(file.read()) - self.logger.info(SU.green("timetable.json loaded")) - except Exception as e: - self.logger.error(SU.red(f"Error while reading {self.timetable_file}"), e) - else: - self.logger.info(SU.green("timetable.json not yet available")) - def merge_timetable(self, remote_timeslots: list): """ Merge the fetched timeslots with the current local timetable. @@ -283,32 +267,6 @@ class TimetableService: return True return False - def timetable_file_exists(self) -> bool: - """ - Checks if 'timetable.json' is available. - - Returns: - bool: True if file is existing. - """ - return pathlib.Path(self.timetable_file).is_file() - - def delete_timetable_file(self) -> bool: - """ - Delete the `timetable.json` file. - - Returns: - (bool): `True` if file is deleted. - """ - try: - if os.path.exists(self.timetable_file): - os.remove(self.timetable_file) - self.logger.info(SU.green(f"Purged '{self.timetable_file}'")) - except Exception as e: - msg = f"Error while deleting '{self.timetable_file}'" - self.logger.critical(SU.red(msg), e) - return False - return True - def terminate(self): """ Call this when the thread is stopped or a signal to terminate is received.