1
0
Fork 0
mirror of https://codeberg.org/Mo8it/AdvLabDB.git synced 2024-12-20 23:41:20 +00:00
AdvLabDB/advlabdb/configUtils.py
2022-01-13 02:25:31 +01:00

26 lines
575 B
Python

import json
def getConfig(label):
with open("config.json", "r") as f:
return json.load(f)[label] # TODO: error handling
def setConfig(label, value, new=False):
with open("config.json", "r") as f:
config = json.load(f)
if new and (label in config):
# Setting is not new! # TODO
return False
if not new and (label not in config):
# Tried to update a setting which is new! # TODO
return False
config[label] = value
with open("config.json", "w") as f:
json.dump(config, f)
return True