1
0
mirror of https://github.com/EDCD/EDMarketConnector.git synced 2025-04-16 09:10:35 +03:00

config: Add class member and methods for signalling/checking shutdown status

This commit is contained in:
Athanasius 2021-01-11 15:37:17 +00:00
parent e51bde44ef
commit f92385244c

View File

@ -117,6 +117,8 @@ class Config(object):
if platform=='darwin':
def __init__(self):
self.in_shutdown = False # Is the application currently shutting down ?
self.app_dir = join(NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, True)[0], appname)
if not isdir(self.app_dir):
mkdir(self.app_dir)
@ -177,9 +179,16 @@ class Config(object):
self.save()
self.defaults = None
def set_shutdown(self):
self.in_shutdown = True
def shutting_down(self) -> bool:
return self.in_shutdown
elif platform=='win32':
def __init__(self):
self.in_shutdown = False # Is the application currently shutting down ?
self.app_dir = join(KnownFolderPath(FOLDERID_LocalAppData), appname)
if not isdir(self.app_dir):
@ -268,11 +277,18 @@ class Config(object):
RegCloseKey(self.hkey)
self.hkey = None
def set_shutdown(self):
self.in_shutdown = True
def shutting_down(self) -> bool:
return self.in_shutdown
elif platform=='linux':
SECTION = 'config'
def __init__(self):
self.in_shutdown = False # Is the application currently shutting down ?
# http://standards.freedesktop.org/basedir-spec/latest/ar01s03.html
self.app_dir = join(getenv('XDG_DATA_HOME', expanduser('~/.local/share')), appname)
@ -346,6 +362,12 @@ class Config(object):
self.save()
self.config = None
def set_shutdown(self):
self.in_shutdown = True
def shutting_down(self) -> bool:
return self.in_shutdown
def _escape(self, val):
return str(val).replace(u'\\', u'\\\\').replace(u'\n', u'\\n').replace(u';', u'\\;')