passwdtools/configuration.py

29 lines
582 B
Python
Raw Normal View History

2019-03-11 16:29:14 +00:00
import json
2019-03-12 12:27:34 +00:00
class Config:
2019-03-11 16:29:14 +00:00
def __init__(self):
2019-03-12 12:27:34 +00:00
self.data = self.read()
2019-03-11 16:29:14 +00:00
2019-03-12 12:27:34 +00:00
def get_pwdfilename(self):
return self.data["pwdfile"]
def set_pwdfilename(self):
pass
def get_secret(self):
return self.data["secret"]
def set_secret(self, secret):
pass
@staticmethod
def read():
with open('cfg/config.json', mode="r") as cfgfile:
return json.load(cfgfile)
@staticmethod
def write(keys):
with open('cfg/config.json', mode="w") as cfgfile:
cfgfile.write(json.dumps(keys))