Added dumping jsons to data
This commit is contained in:
parent
3978b44793
commit
a43b21d853
1 changed files with 8 additions and 0 deletions
8
data.py
8
data.py
|
@ -1,3 +1,4 @@
|
||||||
|
from typing import Any
|
||||||
import json
|
import json
|
||||||
import os.path
|
import os.path
|
||||||
|
|
||||||
|
@ -8,5 +9,12 @@ def load_json(filename: str):
|
||||||
content = json.load(f)
|
content = json.load(f)
|
||||||
return content
|
return content
|
||||||
|
|
||||||
|
def dump_json(filename: str, data: Any):
|
||||||
|
with open(filename + ".json", "w") as f:
|
||||||
|
json.dump(data, f)
|
||||||
|
|
||||||
def load_data(filename: str):
|
def load_data(filename: str):
|
||||||
return load_json(os.path.join(DATA_FOLDER, filename))
|
return load_json(os.path.join(DATA_FOLDER, filename))
|
||||||
|
|
||||||
|
def dump_data(filename: str, data: Any):
|
||||||
|
return dump_json(os.path.join(DATA_FOLDER, filename), data)
|
||||||
|
|
Loading…
Reference in a new issue