Browse Source

Added dumping jsons to data

news
Daniel Skýpala 2 years ago
parent
commit
a43b21d853
  1. 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…
Cancel
Save