##// END OF EJS Templates
Small fix and cleanup for exit/quit command filtering.
Fernando Perez -
Show More
@@ -56,6 +56,11 b' class HistoryManager(object):'
56 # history update, we populate the user's namespace with these, shifted as
56 # history update, we populate the user's namespace with these, shifted as
57 # necessary.
57 # necessary.
58 _i00, _i, _ii, _iii = '','','',''
58 _i00, _i, _ii, _iii = '','','',''
59
60 # A set with all forms of the exit command, so that we don't store them in
61 # the history (it's annoying to rewind the first entry and land on an exit
62 # call).
63 _exit_commands = None
59
64
60 def __init__(self, shell):
65 def __init__(self, shell):
61 """Create a new history manager associated with a shell instance.
66 """Create a new history manager associated with a shell instance.
@@ -91,11 +96,14 b' class HistoryManager(object):'
91
96
92 self._i00, self._i, self._ii, self._iii = '','','',''
97 self._i00, self._i, self._ii, self._iii = '','','',''
93
98
99 self._exit_commands = set(['Quit', 'quit', 'Exit', 'exit', '%Quit',
100 '%quit', '%Exit', '%exit'])
101
94 # Object is fully initialized, we can now call methods on it.
102 # Object is fully initialized, we can now call methods on it.
95
103
96 # Fill the history zero entry, user counter starts at 1
104 # Fill the history zero entry, user counter starts at 1
97 self.store_inputs('\n', '\n')
105 self.store_inputs('\n', '\n')
98
106
99 def _init_shadow_hist(self):
107 def _init_shadow_hist(self):
100 try:
108 try:
101 self.shadow_db = PickleShareDB(os.path.join(
109 self.shadow_db = PickleShareDB(os.path.join(
@@ -207,9 +215,11 b' class HistoryManager(object):'
207 """
215 """
208 if source_raw is None:
216 if source_raw is None:
209 source_raw = source
217 source_raw = source
210 # do not store quit/exit commands
218
211 if source_raw in ['Quit', 'quit', 'Exit', 'exit', '%Quit', '%quit', '%Exit', '%exit']:
219 # do not store exit/quit commands
220 if source_raw.strip() in self._exit_commands:
212 return
221 return
222
213 self.input_hist_parsed.append(source.rstrip())
223 self.input_hist_parsed.append(source.rstrip())
214 self.input_hist_raw.append(source_raw.rstrip())
224 self.input_hist_raw.append(source_raw.rstrip())
215 self.shadow_hist.add(source)
225 self.shadow_hist.add(source)
General Comments 0
You need to be logged in to leave comments. Login now