From 2fe27bdc36b1a0f8f2d31c62c8d3ca9548b7a06f Mon Sep 17 00:00:00 2001 From: Chrys Date: Sat, 27 Apr 2019 21:34:55 +0200 Subject: [PATCH] save settingsfile and add API --- src/fenrirscreenreader/core/settingsManager.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/fenrirscreenreader/core/settingsManager.py b/src/fenrirscreenreader/core/settingsManager.py index 45041043..eb21d70a 100644 --- a/src/fenrirscreenreader/core/settingsManager.py +++ b/src/fenrirscreenreader/core/settingsManager.py @@ -41,6 +41,7 @@ class settingsManager(): self.settings = settingsData self.settingArgDict = {} self.bindingsBackup = None + self.settingsFile = '' def initialize(self, environment): self.env = environment def shutdown(self): @@ -75,14 +76,25 @@ class settingsManager(): self.env['soundIcons'][soundIcon] = soundIconFile self.env['runtime']['debug'].writeDebugOut("SoundIcon: " + soundIcon + '.' + soundIconFile, debug.debugLevel.INFO, onAnyLevel=True) siConfig.close() - + def getSettingsFile(self): + return self.settingsFile + def setSettingsFile(self, settingsFile): + if not os.path.exists(settingsFile): + return + if not os.access(settingsFile, os.R_OK): + return + self.settingsFile = settingsFile def loadSettings(self, settingConfigPath): if not os.path.exists(settingConfigPath): return False if not os.access(settingConfigPath, os.R_OK): return False self.env['settings'] = ConfigParser() - self.env['settings'].read(settingConfigPath) + try: + self.env['settings'].read(settingConfigPath) + except: + return False + self.setSettingsFile(settingConfigPath) return True def saveSettings(self, settingConfigPath): # set opt dict here