blob: fac5f9bdf75010ea22534b284fe4a735fe57452c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
# -*- coding: utf-8 -*-
import json
import os
# filepath of the config.json in the project directory
path = os.path.dirname(__file__)
filepath = ("/".join([path, "config.json"]))
# try to read config.json if nonexistent create config.json an populate it
try:
with open(filepath, "r", encoding="utf-8") as f:
config = json.load(f)
except FileNotFoundError:
with open(filepath, "w", encoding="utf-8") as f:
config = {
"name": "",
}
f.write(json.dumps(config))
class Config(object):
name = config["name"]
|