Move config to shared data directory
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
import json
|
||||
import os
|
||||
from typing import Optional
|
||||
|
||||
CONFIG = 'config.json'
|
||||
CONFIG = 'data/config.json'
|
||||
config: dict = {
|
||||
'inf19x-insiders-enable': False,
|
||||
'loeh-enable': False,
|
||||
@@ -38,8 +39,13 @@ config_meta: dict = {
|
||||
}
|
||||
|
||||
|
||||
def _make_dirs():
|
||||
os.makedirs(os.path.dirname(CONFIG), exist_ok=True)
|
||||
|
||||
|
||||
def config_load() -> dict:
|
||||
try:
|
||||
_make_dirs()
|
||||
config_file = open(CONFIG, 'r')
|
||||
config.update(json.load(config_file))
|
||||
except (json.JSONDecodeError, FileNotFoundError):
|
||||
@@ -48,6 +54,7 @@ def config_load() -> dict:
|
||||
|
||||
|
||||
def config_save():
|
||||
_make_dirs()
|
||||
with open(CONFIG, 'w') as config_file:
|
||||
json.dump(config, config_file)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user