Added dumping jsons to data

This commit is contained in:
Daniel Skýpala 2023-03-26 14:48:14 +02:00
parent 3978b44793
commit a43b21d853

View file

@ -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)