Return an empty dict when loading non existant file
This commit is contained in:
+5
-2
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user