home *** CD-ROM | disk | FTP | other *** search
- # Source Generated with Decompyle++
- # File: in.pyc (Python 2.6)
-
- __docformat__ = 'restructuredtext en'
- from copy import copy
- from util import InputList
-
- class History(object):
-
- def __init__(self, input_cache = None, output_cache = None):
- self.namespace_additions = dict(_ = None, __ = None, ___ = None)
- if input_cache is None:
- input_cache = InputList([])
-
- self.input_cache = input_cache
- if output_cache is None:
- output_cache = { }
-
- self.output_cache = output_cache
-
-
- def get_history_item(self, index):
- if index >= 0 and index < len(self.input_cache):
- return self.input_cache[index]
-
-
-
- class InterpreterHistory(History):
-
- def setup_namespace(self, namespace):
- namespace['In'] = self.input_cache
- namespace['_ih'] = self.input_cache
- namespace['Out'] = self.output_cache
- namespace['_oh'] = self.output_cache
-
-
- def update_history(self, interpreter, python):
- number = interpreter.current_cell_number
- new_obj = interpreter.display_trap.obj
- if new_obj is not None:
- self.namespace_additions['___'] = self.namespace_additions['__']
- self.namespace_additions['__'] = self.namespace_additions['_']
- self.namespace_additions['_'] = new_obj
- self.output_cache[number] = new_obj
-
- interpreter.user_ns.update(self.namespace_additions)
- self.input_cache.add(number, python)
-
-
- def get_history_item(self, index):
- if index > 0 and index < len(self.input_cache) - 1:
- return self.input_cache[-index]
-
-
- def get_input_cache(self):
- return copy(self.input_cache)
-
-
- def get_input_after(self, index):
- return list.__getslice__(self.input_cache, index, len(self.input_cache))
-
-
-
- class FrontEndHistory(History):
-
- def add_items(self, item_list):
- self.input_cache.extend(item_list)
-
-
-