settings - docs and fixes
This commit is contained in:
parent
1734ea02f9
commit
c5ec90a8a4
1 changed files with 13 additions and 2 deletions
|
@ -7,6 +7,9 @@ import pyaudio
|
||||||
|
|
||||||
|
|
||||||
class Settings(Singleton, dict):
|
class Settings(Singleton, dict):
|
||||||
|
"""
|
||||||
|
Settings of current profile + global app settings
|
||||||
|
"""
|
||||||
|
|
||||||
def __init__(self, name):
|
def __init__(self, name):
|
||||||
self.path = ProfileHelper.get_path() + str(name) + '.json'
|
self.path = ProfileHelper.get_path() + str(name) + '.json'
|
||||||
|
@ -47,6 +50,9 @@ class Settings(Singleton, dict):
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_default_settings():
|
def get_default_settings():
|
||||||
|
"""
|
||||||
|
Default profile settings
|
||||||
|
"""
|
||||||
return {
|
return {
|
||||||
'theme': 'default',
|
'theme': 'default',
|
||||||
'ipv6_enabled': True,
|
'ipv6_enabled': True,
|
||||||
|
@ -108,6 +114,9 @@ class Settings(Singleton, dict):
|
||||||
fl.write(data)
|
fl.write(data)
|
||||||
|
|
||||||
def set_active_profile(self):
|
def set_active_profile(self):
|
||||||
|
"""
|
||||||
|
Mark current profile as active
|
||||||
|
"""
|
||||||
path = Settings.get_default_path() + 'toxygen.json'
|
path = Settings.get_default_path() + 'toxygen.json'
|
||||||
if os.path.isfile(path):
|
if os.path.isfile(path):
|
||||||
with open(path) as fl:
|
with open(path) as fl:
|
||||||
|
@ -176,6 +185,9 @@ class ProfileHelper(Singleton):
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def find_profiles():
|
def find_profiles():
|
||||||
|
"""
|
||||||
|
Find available tox profiles
|
||||||
|
"""
|
||||||
path = Settings.get_default_path()
|
path = Settings.get_default_path()
|
||||||
result = []
|
result = []
|
||||||
# check default path
|
# check default path
|
||||||
|
@ -203,8 +215,7 @@ class ProfileHelper(Singleton):
|
||||||
data = json.loads(data)
|
data = json.loads(data)
|
||||||
if 'active_profile' in data:
|
if 'active_profile' in data:
|
||||||
return path in data['active_profile']
|
return path in data['active_profile']
|
||||||
else:
|
return False
|
||||||
return False
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_path():
|
def get_path():
|
||||||
|
|
Loading…
Reference in a new issue