reformat simple_config to comply with electrum and create config dir if it doesnt exist.
This commit is contained in:
parent
af3fe1722b
commit
15eb4d7cb8
|
@ -3,8 +3,22 @@ import os
|
||||||
from util import user_dir
|
from util import user_dir
|
||||||
|
|
||||||
class SimpleConfig:
|
class SimpleConfig:
|
||||||
|
|
||||||
default_options = {"gui": "lite"}
|
default_options = {"gui": "lite"}
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
# Find electrum data folder
|
||||||
|
self.config_folder = user_dir()
|
||||||
|
# Read the file
|
||||||
|
if os.path.exists(self.config_file_path()):
|
||||||
|
self.load_config()
|
||||||
|
else:
|
||||||
|
self.config = self.default_options
|
||||||
|
# Make config directory if it does not yet exist.
|
||||||
|
if not os.path.exists(self.config_folder):
|
||||||
|
os.mkdir(self.config_folder)
|
||||||
|
self.save_config()
|
||||||
|
|
||||||
def set_key(self, key, value, save = True):
|
def set_key(self, key, value, save = True):
|
||||||
self.config[key] = value
|
self.config[key] = value
|
||||||
if save == True:
|
if save == True:
|
||||||
|
@ -26,13 +40,3 @@ class SimpleConfig:
|
||||||
def config_file_path(self):
|
def config_file_path(self):
|
||||||
return "%s" % (self.config_folder + "/config.json")
|
return "%s" % (self.config_folder + "/config.json")
|
||||||
|
|
||||||
def __init__(self):
|
|
||||||
# Find electrum data folder
|
|
||||||
self.config_folder = user_dir()
|
|
||||||
# Read the file
|
|
||||||
if os.path.exists(self.config_file_path()):
|
|
||||||
self.load_config()
|
|
||||||
else:
|
|
||||||
self.config = self.default_options
|
|
||||||
self.save_config()
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue