mirror of
https://codeberg.org/Mo8it/AdvLabDB.git
synced 2024-11-08 21:21:06 +00:00
25 lines
572 B
Python
25 lines
572 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
|