def getSetting(self, nodeKey, settingTree=None): if not settingTree: settingTree = self.settingTree settingValue = SettingHelper.getSetting(nodeKey, settingTree) if ObjectHelper.isEmpty(settingValue): return SettingHelper.getSetting(nodeKey, self.defaultSettingTree) return settingValue
def loadLocalConfiguration(self, loadLocalConfig, printRootPathStatus, globalsEverything): self.loadLocalConfig = loadLocalConfig self.localConfiguration = {} if self.loadLocalConfig: try: self.localConfiguration = self.getSettingTree( settingFilePath=Globals.LOCAL_CONFIGURATION_FILE_NAME, settingTree=None) except Exception as exception: self.log( f'Failed to load {Globals.LOCAL_CONFIGURATION_FILE_NAME} settings', exception=exception) keyQuery = SettingHelper.querySetting(AttributeKey.KW_KEY, self.localConfiguration) keyValueQuery = {} for key, value in keyQuery.items(): KW_DOT_KEY = f'{c.DOT}{AttributeKey.KW_KEY}' if key.endswith(KW_DOT_KEY): environmentInjection = SettingHelper.getSetting( key[:-len(KW_DOT_KEY)], self.localConfiguration) if (ObjectHelper.isDictionary(environmentInjection) and AttributeKey.KW_KEY in environmentInjection and AttributeKey.KW_VALUE in environmentInjection and 2 == len(environmentInjection)): EnvironmentHelper.update( environmentInjection[AttributeKey.KW_KEY], environmentInjection[AttributeKey.KW_VALUE]) log.loadSettings() self.printRootPathStatus = printRootPathStatus self.globalsEverything = globalsEverything self.ignoreModules = IGNORE_MODULES self.ignoreResources = IGNORE_REOURCES self.activeEnvironment = SettingHelper.getActiveEnvironment() if ObjectHelper.isNotEmpty( self.localConfiguration) and SettingHelper.getSetting( 'print-status', self.localConfiguration): SettingHelper.printSettings(self.localConfiguration, "Local Configuration") basicSettingsAsDictionary = { 'activeEnvironment': self.activeEnvironment, 'successStatus': self.successStatus, 'settingStatus': self.settingStatus, 'debugStatus': self.debugStatus, 'warningStatus': self.warningStatus, 'failureStatus': self.failureStatus, 'errorStatus': self.errorStatus, 'wrapperStatus': self.wrapperStatus, 'infoStatus': self.infoStatus, 'statusStatus': self.statusStatus, 'logStatus': self.logStatus, 'globalsEverything': self.globalsEverything, 'printRootPathStatus': self.printRootPathStatus } log.prettyPython(self.__class__, f'Basic settings', basicSettingsAsDictionary, logLevel=log.SETTING)
def accessTree(self, nodeKey, tree): return SettingHelper.getSetting(nodeKey, tree)