Show More
@@ -186,7 +186,7 b' class HistoryManager(object):' | |||||
186 | if self.shell.has_readline: |
|
186 | if self.shell.has_readline: | |
187 | self.populate_readline_history() |
|
187 | self.populate_readline_history() | |
188 |
|
188 | |||
189 | def get_history(self, index=None, raw=False, output=True): |
|
189 | def get_history(self, index=None, raw=False, output=True,this_session=True): | |
190 | """Get the history list. |
|
190 | """Get the history list. | |
191 |
|
191 | |||
192 | Get the input and output history. |
|
192 | Get the input and output history. | |
@@ -201,6 +201,9 b' class HistoryManager(object):' | |||||
201 | If True, return the raw input. |
|
201 | If True, return the raw input. | |
202 | output : bool |
|
202 | output : bool | |
203 | If True, then return the output as well. |
|
203 | If True, then return the output as well. | |
|
204 | this_session : bool | |||
|
205 | If True, indexing is from 1 at the start of this session. | |||
|
206 | If False, indexing is from 1 at the start of the whole history. | |||
204 |
|
207 | |||
205 | Returns |
|
208 | Returns | |
206 | ------- |
|
209 | ------- | |
@@ -214,9 +217,13 b' class HistoryManager(object):' | |||||
214 | input_hist = self.input_hist_parsed |
|
217 | input_hist = self.input_hist_parsed | |
215 | if output: |
|
218 | if output: | |
216 | output_hist = self.output_hist |
|
219 | output_hist = self.output_hist | |
|
220 | ||||
|
221 | if this_session: | |||
|
222 | offset = self.session_offset | |||
|
223 | else: | |||
|
224 | offset = -1 | |||
217 |
|
225 | |||
218 | n = len(input_hist) |
|
226 | n = len(input_hist) | |
219 | offset = self.session_offset |
|
|||
220 | if index is None: |
|
227 | if index is None: | |
221 | start=offset+1; stop=n |
|
228 | start=offset+1; stop=n | |
222 | elif isinstance(index, int): |
|
229 | elif isinstance(index, int): |
@@ -1277,8 +1277,8 b' class InteractiveShell(Configurable, Magic):' | |||||
1277 | self.reload_history() |
|
1277 | self.reload_history() | |
1278 | return wrapper |
|
1278 | return wrapper | |
1279 |
|
1279 | |||
1280 | def get_history(self, index=None, raw=False, output=True): |
|
1280 | def get_history(self, index=None, raw=False, output=True,this_session=True): | |
1281 | return self.history_manager.get_history(index, raw, output) |
|
1281 | return self.history_manager.get_history(index, raw, output,this_session) | |
1282 |
|
1282 | |||
1283 |
|
1283 | |||
1284 | #------------------------------------------------------------------------- |
|
1284 | #------------------------------------------------------------------------- |
@@ -213,7 +213,8 b' class IPythonWidget(FrontendWidget):' | |||||
213 | """ Reimplemented to make a history request. |
|
213 | """ Reimplemented to make a history request. | |
214 | """ |
|
214 | """ | |
215 | super(IPythonWidget, self)._started_channels() |
|
215 | super(IPythonWidget, self)._started_channels() | |
216 |
self.kernel_manager.xreq_channel.history(raw=True, output=False |
|
216 | self.kernel_manager.xreq_channel.history(raw=True, output=False, | |
|
217 | this_session=False) | |||
217 |
|
218 | |||
218 | #--------------------------------------------------------------------------- |
|
219 | #--------------------------------------------------------------------------- | |
219 | # 'ConsoleWidget' public interface |
|
220 | # 'ConsoleWidget' public interface |
@@ -309,10 +309,9 b' class Kernel(Configurable):' | |||||
309 | logger.debug(msg) |
|
309 | logger.debug(msg) | |
310 |
|
310 | |||
311 | def history_request(self, ident, parent): |
|
311 | def history_request(self, ident, parent): | |
312 | output = parent['content']['output'] |
|
312 | # parent['content'] should contain keys "index", "raw", "output" and | |
313 | index = parent['content']['index'] |
|
313 | # "this_session". | |
314 | raw = parent['content']['raw'] |
|
314 | hist = self.shell.get_history(**parent['content']) | |
315 | hist = self.shell.get_history(index=index, raw=raw, output=output) |
|
|||
316 | content = {'history' : hist} |
|
315 | content = {'history' : hist} | |
317 | msg = self.session.send(self.reply_socket, 'history_reply', |
|
316 | msg = self.session.send(self.reply_socket, 'history_reply', | |
318 | content, parent, ident) |
|
317 | content, parent, ident) |
@@ -282,7 +282,7 b' class XReqSocketChannel(ZmqSocketChannel):' | |||||
282 | self._queue_request(msg) |
|
282 | self._queue_request(msg) | |
283 | return msg['header']['msg_id'] |
|
283 | return msg['header']['msg_id'] | |
284 |
|
284 | |||
285 | def history(self, index=None, raw=False, output=True): |
|
285 | def history(self, index=None, raw=False, output=True, this_session=True): | |
286 | """Get the history list. |
|
286 | """Get the history list. | |
287 |
|
287 | |||
288 | Parameters |
|
288 | Parameters | |
@@ -295,12 +295,16 b' class XReqSocketChannel(ZmqSocketChannel):' | |||||
295 | If True, return the raw input. |
|
295 | If True, return the raw input. | |
296 | output : bool |
|
296 | output : bool | |
297 | If True, then return the output as well. |
|
297 | If True, then return the output as well. | |
|
298 | this_session : bool | |||
|
299 | If True, returns only history from the current session. Otherwise, | |||
|
300 | includes reloaded history from previous sessions. | |||
298 |
|
301 | |||
299 | Returns |
|
302 | Returns | |
300 | ------- |
|
303 | ------- | |
301 | The msg_id of the message sent. |
|
304 | The msg_id of the message sent. | |
302 | """ |
|
305 | """ | |
303 |
content = dict(index=index, raw=raw, output=output |
|
306 | content = dict(index=index, raw=raw, output=output, | |
|
307 | this_session=this_session) | |||
304 | msg = self.session.msg('history_request', content) |
|
308 | msg = self.session.msg('history_request', content) | |
305 | self._queue_request(msg) |
|
309 | self._queue_request(msg) | |
306 | return msg['header']['msg_id'] |
|
310 | return msg['header']['msg_id'] |
General Comments 0
You need to be logged in to leave comments.
Login now