-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsettings.py
36 lines (34 loc) · 1.15 KB
/
settings.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import os
class Settings:
def __init__(self):
homedir = os.environ['HOME']
configdir = os.path.join(homedir, '.config')
settings_path = os.path.join(configdir, 'userraid.ini')
try:
f = open(settings_path, 'rb')
self.__dict__ = eval(f.read())
f.close()
except (IOError, SyntaxError), (code, descr):
os.path.exists(configdir) or os.makedirs(configdir)
# default settings
self.__dict__ = {
"services": {
"Ya.disk": {
"path": "https://webdav.yandex.ru"
},
"Dropbox": {
"path": "https://dav.dropdav.com"
}
},
"accounts": {}
}
self.settings_path = settings_path
self.workdir = os.path.join(homedir, '.useraid')
def __setattr__(self, key, value):
self.__dict__[key] = value
try:
f = open(self.settings_path, 'wb')
f.write(repr(self.__dict__))
f.close()
except IOError, (code, descr):
pass