Browse Source

Default json content from python file

news
Daniel Skýpala 2 years ago
parent
commit
85a4fa85ae
  1. 4
      hrochobot/utils/data.py
  2. 3
      hrochobot/utils/json_templates.py

4
hrochobot/utils/data.py

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

3
hrochobot/utils/json_templates.py

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