Make config dir if it doesn't exist, and use AppData in Windows. When in Rome...
This commit is contained in:
parent
e6c0ec0e2e
commit
ae9a1ed77c
13
utils.py
13
utils.py
|
@ -3,8 +3,13 @@ import os
|
||||||
import easygui
|
import easygui
|
||||||
import platform
|
import platform
|
||||||
|
|
||||||
def get_config_dir():
|
def get_config_dir(make=False):
|
||||||
return os.path.join(os.path.expanduser('~'), '.ed_tools/')
|
if windows_detected():
|
||||||
|
config_suffix = os.path.join('AppData', 'Local', 'ed_tools')
|
||||||
|
else:
|
||||||
|
config_suffix = '.ed_tools'
|
||||||
|
|
||||||
|
return os.path.join(os.path.expanduser('~'), config_suffix)
|
||||||
|
|
||||||
def get_settings():
|
def get_settings():
|
||||||
"""
|
"""
|
||||||
|
@ -17,6 +22,10 @@ def get_settings():
|
||||||
if os.path.isfile(filename):
|
if os.path.isfile(filename):
|
||||||
settings.read(filename)
|
settings.read(filename)
|
||||||
else:
|
else:
|
||||||
|
try:
|
||||||
|
os.makedirs(get_config_dir())
|
||||||
|
except:
|
||||||
|
pass
|
||||||
_init_settings(settings, filename)
|
_init_settings(settings, filename)
|
||||||
|
|
||||||
return settings
|
return settings
|
||||||
|
|
Reference in New Issue
Block a user