Return an empty dict when loading non existant file
This commit is contained in:
parent
7e7ffd6f49
commit
a49c5f012f
@ -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:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user