aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornico <nico@magicbroccoli.de>2019-06-02 15:30:54 +0200
committernico <nico@magicbroccoli.de>2019-06-02 15:30:54 +0200
commit0d7e2f0c7cef6b7a853107bf37d44816244e7749 (patch)
treef131604385c6dd5a065d6c5e0ba1ac5c18554cee
parentf0940cc6152faec3695301c1f70430fddc38a898 (diff)
file system clutter
+ add correct path to config.json to prevent file system clutter
-rw-r--r--config.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/config.py b/config.py
index ff6f9fa..fac5f9b 100644
--- a/config.py
+++ b/config.py
@@ -1,13 +1,18 @@
# -*- 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("config.json", "r", encoding="utf-8") as f:
+ with open(filepath, "r", encoding="utf-8") as f:
config = json.load(f)
except FileNotFoundError:
- with open("config.json", "w", encoding="utf-8") as f:
+ with open(filepath, "w", encoding="utf-8") as f:
config = {
"name": "",
}