2016-02-16 19:11:56 +01:00
|
|
|
import platform
|
|
|
|
import json
|
2016-02-16 20:57:45 +01:00
|
|
|
import os
|
2016-02-16 19:11:56 +01:00
|
|
|
|
|
|
|
|
|
|
|
class Settings(object):
|
|
|
|
|
|
|
|
def __init__(self):
|
2016-02-16 20:57:45 +01:00
|
|
|
self.path = Settings.get_default_path() + 'toxygen.json'
|
|
|
|
with open(self.path) as fl:
|
2016-02-16 19:11:56 +01:00
|
|
|
data = fl.read()
|
|
|
|
self.data = json.loads(data)
|
|
|
|
|
|
|
|
def __get__(self, attr):
|
|
|
|
return self.data[attr]
|
|
|
|
|
2016-02-16 20:57:45 +01:00
|
|
|
def save(self):
|
|
|
|
text = json.dumps(self.data)
|
|
|
|
with open(self.path, 'w') as fl:
|
|
|
|
fl.write(text)
|
|
|
|
|
2016-02-16 19:11:56 +01:00
|
|
|
@staticmethod
|
|
|
|
def get_default_path():
|
|
|
|
name = platform.system()
|
|
|
|
if name == 'Linux':
|
2016-02-16 20:57:45 +01:00
|
|
|
return os.getenv('HOME') + '/.config/tox/'
|
|
|
|
elif name == 'Windows':
|
|
|
|
return os.getenv('APPDATA') + '/Tox/'
|
|
|
|
|