parent
7d17d77d77
commit
6253e71a47
2 changed files with 19 additions and 13 deletions
@ -0,0 +1,14 @@ |
||||
import json |
||||
|
||||
|
||||
class CfgFile: |
||||
def __init__(self): |
||||
self.cfg_file = '/Volumes/GMGAUTHIER/keys/pwdtools/config.json' |
||||
|
||||
def read(self): |
||||
with open(self.cfg_file, mode="r") as cfgfile: |
||||
return json.load(cfgfile) |
||||
|
||||
def write(self, keys): |
||||
with open(self.cfg_file, mode="w") as cfgfile: |
||||
cfgfile.write(json.dumps(keys)) |
@ -1,29 +1,21 @@ |
||||
import json |
||||
from cfgfile import CfgFile |
||||
|
||||
|
||||
class Config: |
||||
def __init__(self): |
||||
self.cfg_file = '/Volumes/GMGAUTHIER/keys/pwdtools/config.json' |
||||
self.data = self.read() |
||||
self.cfgfile = CfgFile() |
||||
self.data = self.cfgfile.read() |
||||
|
||||
def get_pwdfilename(self): |
||||
return self.data["pwdfilename"] |
||||
|
||||
def set_pwdfilename(self, pwdfilename): |
||||
self.data["pwdfilename"] = pwdfilename |
||||
self.write(self.data) |
||||
self.cfgfile.write(self.data) |
||||
|
||||
def get_secret(self): |
||||
return self.data["secret"] |
||||
|
||||
def set_secret(self, secret): |
||||
self.data["secret"] = secret |
||||
self.write(self.data) |
||||
|
||||
def read(self): |
||||
with open(self.cfg_file, mode="r") as cfgfile: |
||||
return json.load(cfgfile) |
||||
|
||||
def write(self, keys): |
||||
with open(self.cfg_file, mode="w") as cfgfile: |
||||
cfgfile.write(json.dumps(keys)) |
||||
self.cfgfile.write(self.data) |
||||
|
Loading…
Reference in new issue