This repository has been archived on 2018-07-26. You can view files and clone it, but cannot push or open issues or pull requests.
auditbot/prefer.py

25 lines
497 B
Python

import json
def toJSONFile(obj,filename):
with open(filename,"w") as f:
json.dump(obj,f,indent="\t")
def fromJSONFile(filename):
with open(filename) as f:
return json.load(f)
class Preferences:
def __init__(self,filename):
self.data = fromJSONFile(filename)
self.filename = filename
def get(self,id,default=None):
if id not in self.data.keys():
return default
else:
return self.data[id]
def set(self,id,val):
self.data[id] = val
toJSONFile(self.data,self.filename)