def _merge_pdicts(self, pdict1, pdict2): incoming_pdict = ParameterDictionary.load(pdict1) outgoing_pdict = ParameterDictionary.load(pdict2) merged_pdict = ParameterDictionary() for k, v in incoming_pdict.iteritems(): ordinal, v = v if k not in merged_pdict: merged_pdict.add_context(v) for k, v in outgoing_pdict.iteritems(): ordinal, v = v if k not in merged_pdict: merged_pdict.add_context(v) return merged_pdict
def _execute_transform(self, msg, streams): stream_in_id,stream_out_id = streams stream_def_in = self.read_stream_def(stream_in_id) stream_def_out = self.read_stream_def(stream_out_id) incoming_pdict_dump = stream_def_in.parameter_dictionary outgoing_pdict_dump = stream_def_out.parameter_dictionary incoming_pdict = ParameterDictionary.load(incoming_pdict_dump) outgoing_pdict = ParameterDictionary.load(outgoing_pdict_dump) merged_pdict = ParameterDictionary() for k,v in incoming_pdict.iteritems(): ordinal, v = v if k not in merged_pdict: merged_pdict.add_context(v) for k,v in outgoing_pdict.iteritems(): ordinal, v = v if k not in merged_pdict: merged_pdict.add_context(v) rdt_temp = RecordDictionaryTool(param_dictionary=merged_pdict) rdt_in = RecordDictionaryTool.load_from_granule(msg) for field in rdt_temp.fields: if not isinstance(rdt_temp._pdict.get_context(field).param_type, ParameterFunctionType): try: rdt_temp[field] = rdt_in[field] except KeyError: pass for field in rdt_temp.fields: if isinstance(rdt_temp._pdict.get_context(field).param_type, ParameterFunctionType): rdt_temp[field] = rdt_temp[field] rdt_out = RecordDictionaryTool(stream_definition_id=stream_def_out._id) for field in rdt_out.fields: rdt_out[field] = rdt_temp[field] return rdt_out