You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
21 lines
502 B
21 lines
502 B
2 years ago
|
from typing import Any
|
||
2 years ago
|
import json
|
||
|
import os.path
|
||
|
|
||
|
DATA_FOLDER = "data"
|
||
|
|
||
|
def load_json(filename: str):
|
||
|
with open(filename + ".json") as f:
|
||
|
content = json.load(f)
|
||
|
return content
|
||
|
|
||
2 years ago
|
def dump_json(filename: str, data: Any):
|
||
|
with open(filename + ".json", "w") as f:
|
||
|
json.dump(data, f)
|
||
|
|
||
2 years ago
|
def load_data(filename: str):
|
||
|
return load_json(os.path.join(DATA_FOLDER, filename))
|
||
2 years ago
|
|
||
|
def dump_data(filename: str, data: Any):
|
||
|
return dump_json(os.path.join(DATA_FOLDER, filename), data)
|