Return an empty dict when loading non existant file

This commit is contained in:
Hubert Van De Walle 2025-07-22 11:20:07 +02:00
parent 7e7ffd6f49
commit a49c5f012f

View File

@ -12,8 +12,11 @@ class DispatchStorage:
@classmethod
def load(cls, date: Optional[str] = None) -> Dict[str, List[int]]:
with open(cls.path(date), "r") as f:
return json.load(f)
try:
with open(cls.path(date), "r") as f:
return json.load(f)
except FileNotFoundError:
return {}
@classmethod
def save(cls, dispatch: Dict[str, List[int]], date: Optional[str] = None) -> None: