Default json content from python file

This commit is contained in:
Daniel Skýpala 2023-05-17 17:03:26 +02:00
parent fa88690f92
commit 85a4fa85ae
2 changed files with 6 additions and 1 deletions

View file

@ -2,13 +2,15 @@ from typing import Any
import json
import os.path
from hrochobot.utils.json_templates import TEMPLATES
EXAMPLE_DATA = "data.example"
DATA_FOLDER = "TODO"
def load_json(filename: str):
filename += ".json"
if not os.path.exists(filename):
filename = os.path.join(EXAMPLE_DATA, os.path.basename(filename))
return json.loads(TEMPLATES[os.path.basename(filename)])
with open(filename) as f:
content = json.load(f)

View file

@ -0,0 +1,3 @@
TEMPLATES = {
'roles.json' : '{"secret_roles": {}}',
}