def _readConfigItem(key, ctx, section): ctx, sub = resource_helper.getSubSection(ctx, section, key, safe=True) config = {} if sub is not None: for itemCtx, item in resource_helper.getIterator(ctx, sub): source = resource_helper.readDict(itemCtx, item) config[source.name] = source.value return config
def readXMLConfig(filename): config = {} ctx, root = resource_helper.getRoot(filename, safe=False) if root is None: return config else: sectionCtx, section = resource_helper.getSubSection(ctx, root, 'common', safe=False) if section is not None: config.update(resource_helper.readDict(sectionCtx, section).value) for key in ('filters', 'formatters', 'handlers', 'loggers'): config[key] = _readConfigItem(key, ctx, root) resource_helper.purgeResource(filename) return config
def readXMLConfig(filename): """ Reads XML file to load the logging configuration as dictionary. Note: Here is no any validation, validation will be applied if trying configure logging package. :param filename: string containing relative path to configuration file that is started from "res" directory. :return: dictionary containing logging configuration. """ config = {} ctx, root = resource_helper.getRoot(filename, safe=False) if root is None: return config else: sectionCtx, section = resource_helper.getSubSection(ctx, root, 'common', safe=False) if section is not None: config.update(resource_helper.readDict(sectionCtx, section).value) for key in ('filters', 'formatters', 'handlers', 'loggers'): config[key] = _readConfigItem(key, ctx, root) resource_helper.purgeResource(filename) return config
def _readStartAssistantEffectSection(xmlCtx, section, _, conditions): item = resource_helper.readDict( resource_helper.ResourceCtx(xmlCtx[1]), _xml.getSubsection(xmlCtx, section, 'hints')) hints = item.value return bc_effects.StartAssistantEffect(hints, conditions=conditions)