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-13 14:27:21 +00:00
|
|
|
self.cfg_file = '/Volumes/GMGAUTHIER/keys/pwdtools/config.json'
|
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):
|
2019-03-12 15:32:12 +00:00
|
|
|
return self.data["pwdfilename"]
|
2019-03-12 12:27:34 +00:00
|
|
|
|
2019-03-12 14:57:58 +00:00
|
|
|
def set_pwdfilename(self, pwdfilename):
|
|
|
|
self.data["pwdfilename"] = pwdfilename
|
|
|
|
self.write(self.data)
|
2019-03-12 12:27:34 +00:00
|
|
|
|
|
|
|
def get_secret(self):
|
|
|
|
return self.data["secret"]
|
|
|
|
|
|
|
|
def set_secret(self, secret):
|
2019-03-12 14:57:58 +00:00
|
|
|
self.data["secret"] = secret
|
|
|
|
self.write(self.data)
|
2019-03-12 12:27:34 +00:00
|
|
|
|
2019-03-13 14:27:21 +00:00
|
|
|
def read(self):
|
|
|
|
with open(self.cfg_file, mode="r") as cfgfile:
|
2019-03-12 12:27:34 +00:00
|
|
|
return json.load(cfgfile)
|
|
|
|
|
2019-03-13 14:27:21 +00:00
|
|
|
def write(self, keys):
|
|
|
|
with open(self.cfg_file, mode="w") as cfgfile:
|
2019-03-12 12:27:34 +00:00
|
|
|
cfgfile.write(json.dumps(keys))
|