diff options
Diffstat (limited to 'config.py')
-rw-r--r-- | config.py | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/config.py b/config.py new file mode 100644 index 0000000..fac5f9b --- /dev/null +++ b/config.py @@ -0,0 +1,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"] |