1
0
Fork 0
mirror of synced 2024-06-29 19:50:25 +12:00

Corrected how to create the config.json file if it does not exist

This commit is contained in:
Phxntxm 2016-08-12 14:52:44 -05:00
parent c95bdcbd96
commit d14df8e3ea

View file

@ -33,12 +33,16 @@ except KeyError:
def saveContent(key: str, content):
with open("config.json", "a+") as jf:
data = json.load(jf)
data[key] = content
jf.seek(0)
jf.truncate()
json.dump(data, jf, indent=4)
try:
with open("config.json", "r+") as jf:
data = json.load(jf)
data[key] = content
jf.seek(0)
jf.truncate()
json.dump(data, jf, indent=4)
except FileNotFoundError:
with open("config.json", "w+") as jf:
json.dump({key: content}, jf, indent=4)
def getContent(key: str):