Package rekall :: Package ui :: Module identity
[frames] | no frames]

Source Code for Module rekall.ui.identity

 1  # Rekall Memory Forensics 
 2  # Copyright (C) 2012 Michael Cohen 
 3  # Copyright 2014 Google Inc. All Rights Reserved. 
 4  # 
 5  # This program is free software; you can redistribute it and/or modify 
 6  # it under the terms of the GNU General Public License as published by 
 7  # the Free Software Foundation; either version 2 of the License, or (at 
 8  # your option) any later version. 
 9  # 
10  # This program is distributed in the hope that it will be useful, but 
11  # WITHOUT ANY WARRANTY; without even the implied warranty of 
12  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 
13  # General Public License for more details. 
14  # 
15  # You should have received a copy of the GNU General Public License 
16  # along with this program; if not, write to the Free Software 
17  # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 
18  # 
19   
20  """This module implements a pass-through renderer. 
21   
22  The renderer in this module just passes table rows along as it received them. 
23  """ 
24   
25  from rekall.ui import renderer as renderer_module 
26   
27   
28 -class IdentityRenderer(renderer_module.BaseRenderer):
29 columns = None 30 plugin_name = None 31 rows = None 32
33 - def __init__(self, *_, **kwargs):
34 super(IdentityRenderer, self).__init__(session=kwargs.get("session")) 35 self.rows = [] 36 self.delegated_renderer = self.session.GetRenderer()
37
38 - def __enter__(self):
39 return self
40
41 - def __exit__(self, *_):
42 pass
43
44 - def format(self, *args):
45 self.delegated_renderer.format(*args)
46
47 - def flush(self):
48 self.delegated_renderer.flush()
49
50 - def start(self, plugin_name=None, **_):
51 super(IdentityRenderer, self).start(plugin_name=plugin_name, **_) 52 self.plugin_name = plugin_name 53 return self
54
55 - def table_header(self, columns=None, **_):
56 self.columns = [] 57 for column in columns: 58 if isinstance(column, dict): 59 self.columns.append(column) 60 elif isinstance(column, tuple): 61 self.columns.append(dict(name=column[0], 62 formatstring=column[2])) 63 else: 64 raise TypeError("Column spec must be dict or tuple. Got %r." 65 % column)
66
67 - def _get_column_name(self, idx):
68 column = self.columns[idx] 69 if isinstance(column, tuple): 70 return column[1] 71 72 return column["name"]
73
74 - def table_row(self, *values, **_):
75 row = dict() 76 for idx, value in enumerate(values): 77 name = self._get_column_name(idx) 78 row[name] = value 79 80 self.rows.append(row)
81
82 - def open(self, **kwargs):
83 return self.delegated_renderer.open(**kwargs)
84