Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
65c1872444
@ -1,22 +1,29 @@
|
|||||||
import getpass
|
|
||||||
import platform
|
import platform
|
||||||
import json
|
import json
|
||||||
|
import os
|
||||||
|
|
||||||
|
|
||||||
class Settings(object):
|
class Settings(object):
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
path = Settings.get_default_path() + 'toxygen.json'
|
self.path = Settings.get_default_path() + 'toxygen.json'
|
||||||
with open(path) as fl:
|
with open(self.path) as fl:
|
||||||
data = fl.read()
|
data = fl.read()
|
||||||
self.data = json.loads(data)
|
self.data = json.loads(data)
|
||||||
|
|
||||||
def __get__(self, attr):
|
def __get__(self, attr):
|
||||||
return self.data[attr]
|
return self.data[attr]
|
||||||
|
|
||||||
|
def save(self):
|
||||||
|
text = json.dumps(self.data)
|
||||||
|
with open(self.path, 'w') as fl:
|
||||||
|
fl.write(text)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_default_path():
|
def get_default_path():
|
||||||
name = platform.system()
|
name = platform.system()
|
||||||
if name == 'Linux':
|
if name == 'Linux':
|
||||||
user = getpass.getuser()
|
return os.getenv('HOME') + '/.config/tox/'
|
||||||
return '/home/{}/.config/tox/'.format(user)
|
elif name == 'Windows':
|
||||||
|
return os.getenv('APPDATA') + '/Tox/'
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user