Skip to content
Snippets Groups Projects
Commit 8d42cb92 authored by David Trattnig's avatar David Trattnig
Browse files

style: improve json file layout

parent a5050850
No related branches found
No related tags found
1 merge request!35ORM-less scheduling
Pipeline #7763 passed
......@@ -56,6 +56,7 @@ class TimetableService:
last_successful_fetch: datetime = None
cache_location: str = None
timetable_file: str = None
restorable: bool
def __init__(self, cache_location: str):
"""
......@@ -66,7 +67,7 @@ class TimetableService:
"""
self.config = AuraConfig.instance.config
self.logger = logging.getLogger("engine")
jsonpickle.set_encoder_options("json", sort_keys=True, indent=4)
jsonpickle.set_encoder_options("json", sort_keys=False, indent=2)
if cache_location[-1] != "/":
cache_location += "/"
......@@ -74,6 +75,7 @@ class TimetableService:
os.makedirs(cache_location, exist_ok=True)
self.cache_location = cache_location
self.timetable_file = self.cache_location + "/timetable.json"
self.restorable = False
@synchronized
def refresh(self):
......@@ -125,7 +127,7 @@ class TimetableService:
"""
try:
with open(self.timetable_file, "w") as file:
file.write(jsonpickle.encode(self.timetable))
file.write(jsonpickle.encode(self.timetable, unpicklable=self.restorable))
self.logger.info(SU.green("timetable.json stored"))
except Exception as e:
self.logger.error(SU.red(f"Error while storing {self.timetable_file}"), e)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment