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