put cfgfile into its own class
This commit is contained in:
parent
7d17d77d77
commit
6253e71a47
14
cfgfile.py
Normal file
14
cfgfile.py
Normal file
@ -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
Block a user