From f92385244c8f8deaaafe2e0dd9499220a0188e08 Mon Sep 17 00:00:00 2001 From: Athanasius Date: Mon, 11 Jan 2021 15:37:17 +0000 Subject: [PATCH] config: Add class member and methods for signalling/checking shutdown status --- config.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/config.py b/config.py index 08d7ec89..f0915cac 100644 --- a/config.py +++ b/config.py @@ -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'\\;')