

def Layout(self, request, response):
    if self.proxy:
        collection = self.proxy
    else:
        try:
            aff4_path = (self.state.get('aff4_path') or request.REQ.get('aff4_path'))
            collection = aff4.FACTORY.Open(aff4_path, aff4_type='RekallResponseCollection', token=request.token)
        except IOError:
            return
    output_directories = set()
    renderer = GRRRekallViewerRenderer(session.Session())
    for rekall_response in collection:
        for statement in json.loads(rekall_response.json_messages):
            command = statement[0]
            if (command == 'm'):
                self._flush_table()
                self._flush_freetext()
                self.elements.append(PluginHeader(statement[1]))
            elif (command == 's'):
                self._flush_table()
                self._flush_freetext()
                self.elements.append(SectionHeader(**statement[1]))
            elif (command == 'f'):
                self._flush_table()
                format_string = statement[1]
                try:
                    args = statement[2:]
                except IndexError:
                    args = []

                def FormatCallback(match):
                    arg_pos = int(match.group(1))
                    arg = args[arg_pos]
                    return GetRekallObjectSummary(renderer, arg)
                rendered_free_text = re.sub('\\{(\\d+)(?:\\:.+?\\}|\\})', FormatCallback, format_string)
                self.free_text.append(rendered_free_text)
            elif (command == 'e'):
                self._flush_table()
                self._flush_freetext()
                self.elements.append(RekallErrorRenderer(statement[1]))
            elif (command == 't'):
                self._flush_table()
                self._flush_freetext()
                self.current_table = RekallTable(statement[1])
            elif (command == 'r'):
                self._flush_freetext()
                if (not self.current_table):
                    logging.warn('Rekall plugin %s tried to write a table row but no table was defined.', rekall_response.plugin)
                    self.free_text.append(utils.SmartStr(statement[1]))
                    continue
                self.current_table.AddRow(statement[1])
            elif (command == 'file'):
                file_urn = aff4.AFF4Object.VFSGRRClient.PathspecToURN(rdf_paths.PathSpec(**statement[1]), rekall_response.client_urn)
                output_directories.add(rdfvalue.RDFURN(file_urn.Dirname()))
            elif (command == 'p'):
                pass
    self._flush_table()
    self._flush_freetext()
    for directory in output_directories:
        self.elements.append(semantic.RDFURNRenderer(directory))
    return super(RekallResponseCollectionRenderer, self).Layout(request, response)

dataset/ETHPy150Open google/grr/grr/gui/plugins/rekall_viewer.py RekallResponseCollectionRenderer.Layout/original