add ls, start and end command

This commit is contained in:
2024-06-13 11:15:48 +02:00
parent ce461bd087
commit c78b314684
3 changed files with 56 additions and 9 deletions

View File

@@ -9,7 +9,7 @@ class DataStore:
if create:
# Store emtpty list
self._time_slots = []
self._write_update()
self.write_update()
else:
# Load dicts from file
with open(self._filename, "r") as f:
@@ -23,18 +23,18 @@ class DataStore:
self._time_slots = [deserialize(d) for d in self._time_slots]
def _write_update(self):
def write_update(self):
"""Saves the updates made to the DataStore object to disk."""
with open(self._filename, "w+") as f:
json.dump(self._time_slots, f, default=vars)
def add_time_slot(self, time_slot: TimeSlot):
self._time_slots.append(time_slot)
self._write_update()
self.write_update()
def remove_time_slot(self, time_slot: TimeSlot):
self._time_slots.remove(time_slot)
self._write_update()
self.write_update()
def get_all_time_slots(self):
return self._time_slots[:]