Default json content from python file
This commit is contained in:
parent
fa88690f92
commit
85a4fa85ae
2 changed files with 6 additions and 1 deletions
|
@ -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
Normal file
3
hrochobot/utils/json_templates.py
Normal file
|
@ -0,0 +1,3 @@
|
|||
TEMPLATES = {
|
||||
'roles.json' : '{"secret_roles": {}}',
|
||||
}
|
Loading…
Reference in a new issue