@wrap_exceptions<EOL><INDENT>def update_sources(self):<DEDENT>
ES_documents = self.get_docs_sources_from_ES()<EOL>for doc, update_spec, action_buffer_index, get_from_ES in self.doc_to_update:<EOL><INDENT>if get_from_ES:<EOL><INDENT>ES_doc = next(ES_documents)<EOL>if ES_doc["<STR_LIT>"]:<EOL><INDENT>source = ES_doc["<STR_LIT>"]<EOL><DEDENT>else:<EOL><INDENT>LOG.error(<EOL>"<STR_LIT>"<EOL>"<STR_LIT>"<EOL>"<STR_LIT>",<EOL>doc["<STR_LIT>"],<EOL>update_spec,<EOL>)<EOL>self.reset_action(action_buffer_index)<EOL>continue<EOL><DEDENT><DEDENT>else:<EOL><INDENT>source = self.get_from_sources(doc["<STR_LIT>"], doc["<STR_LIT>"], doc["<STR_LIT>"])<EOL>if not source:<EOL><INDENT>LOG.error(<EOL>"<STR_LIT>"<EOL>"<STR_LIT>"<EOL>"<STR_LIT>",<EOL>doc["<STR_LIT>"],<EOL>update_spec,<EOL>)<EOL>self.reset_action(action_buffer_index)<EOL>continue<EOL><DEDENT><DEDENT>updated = self.docman.apply_update(source, update_spec)<EOL>if "<STR_LIT>" in updated:<EOL><INDENT>del updated["<STR_LIT>"]<EOL><DEDENT>self.add_to_sources(doc, updated)<EOL>self.action_buffer[action_buffer_index][<EOL>"<STR_LIT>"<EOL>] = self.docman._formatter.format_document(updated)<EOL><DEDENT>self.action_buffer = [<EOL>each_action for each_action in self.action_buffer if each_action<EOL>]<EOL>
Update local sources based on response from Elasticsearch