From b903c46bd6de776b15c87316c695383e65b78406 Mon Sep 17 00:00:00 2001 From: ingvar1995 Date: Tue, 16 Feb 2016 22:57:45 +0300 Subject: [PATCH] settings update --- src/settings.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/settings.py b/src/settings.py index 5cfd85d..0658c4b 100644 --- a/src/settings.py +++ b/src/settings.py @@ -1,22 +1,29 @@ -import getpass import platform import json +import os class Settings(object): def __init__(self): - path = Settings.get_default_path() + 'toxygen.json' - with open(path) as fl: + self.path = Settings.get_default_path() + 'toxygen.json' + with open(self.path) as fl: data = fl.read() self.data = json.loads(data) def __get__(self, attr): return self.data[attr] + def save(self): + text = json.dumps(self.data) + with open(self.path, 'w') as fl: + fl.write(text) + @staticmethod def get_default_path(): name = platform.system() if name == 'Linux': - user = getpass.getuser() - return '/home/{}/.config/tox/'.format(user) + return os.getenv('HOME') + '/.config/tox/' + elif name == 'Windows': + return os.getenv('APPDATA') + '/Tox/' +