def _set_bus_messages_flag(self): request_parameters, config_parameters = Pipeline.get_section_and_config( self.request, self.config, ["parameters"], ["parameters", "properties"]) bus_msgs = "bus-messages" if bus_msgs in config_parameters and bus_msgs in request_parameters and \ isinstance(request_parameters[bus_msgs], bool): self._bus_messages = request_parameters[bus_msgs]
def set_section_defaults(self, request, config, request_section, config_section): section, config = Pipeline.get_section_and_config( request, config, request_section, config_section) for key in config: if (key not in section) and ("default" in config[key]): section[key] = config[key]["default"] if (len(section) != 0): result = request for key in request_section[0:-1]: result = result.setdefault(key, {}) result[request_section[-1]] = section
def _set_section_properties(self, request_section, config_section): # TODO: refactor # pylint: disable=R1702 request, config = Pipeline.get_section_and_config( self.request, self.config, request_section, config_section) for key in config: if isinstance(config[key], dict) and "element" in config[key]: if key in request: if isinstance(config[key]["element"], list): element_properties = [ self._get_element_property(x, key) for x in config[key]["element"] ] else: element_properties = [ self._get_element_property(config[key]["element"], key) ] for element_name, property_name, format_type in element_properties: element = self.pipeline.get_by_name(element_name) if element: if (property_name in [ x.name for x in element.list_properties() ]): if (format_type == "json"): element.set_property( property_name, json.dumps(request[key])) else: element.set_property( property_name, request[key]) self._logger.debug( "Setting element: {}, property: {}, value: {}" .format( element_name, property_name, element.get_property(property_name))) else: self._logger.debug( "Parameter {} given for element {}" " but no property found".format( property_name, element_name)) else: self._logger.debug( "Parameter {} given for element {}" " but no element found".format( property_name, element_name))
def _set_section_properties(self, request_section, config_section): request, config = Pipeline.get_section_and_config( self.request, self.config, request_section, config_section) for key in config: if isinstance(config[key], dict) and "filter" in config[key]: if key in request: if isinstance(config[key]["filter"], list): filter_properties = [self._get_filter_property_config(x, config[key]) for x in config[key]["filter"]] else: filter_properties = [self._get_filter_property_config( config[key]["filter"], config[key])] for _filter in filter_properties: self._set_filter_property(_filter, request[key])