defaults settings added

This commit is contained in:
ingvar1995 2016-02-17 22:04:39 +03:00
parent 97cf9e5df5
commit b9446235ca
1 changed files with 29 additions and 3 deletions

View File

@ -7,9 +7,35 @@ class Settings(object):
def __init__(self):
self.path = Settings.get_default_path() + 'toxygen.json'
with open(self.path) as fl:
data = fl.read()
self.data = json.loads(data)
# TODO: create new if old not found
if os.path.exists(self.path):
with open(self.path) as fl:
data = fl.read()
self.data = json.loads(data)
else:
self.create_default_settings()
def create_default_settings(self):
self.data = {
"theme": "default",
"ipv6_enabled": True,
"udp_enabled": True,
"proxy_type": 0,
"proxy_host": "0",
"proxy_port": 0,
"start_port": 0,
"end_port": 0,
"tcp_port": 0,
"notifications": True,
"sound_notifications": False,
"language": "en-en",
"save_history": False,
"allow_inline": True,
"allow_auto_accept": False,
"auto_accept_from_friends": [],
"friends_aliases": [],
"typing_notifications": True
}
def __get__(self, attr):
return self.data[attr]