Show More
@@ -15,7 +15,6 b' from __future__ import print_function' | |||||
15 | # Stdlib imports |
|
15 | # Stdlib imports | |
16 | import atexit |
|
16 | import atexit | |
17 | import datetime |
|
17 | import datetime | |
18 | import abc |
|
|||
19 | import os |
|
18 | import os | |
20 | import re |
|
19 | import re | |
21 | try: |
|
20 | try: | |
@@ -103,22 +102,19 b' def catch_corrupt_db(f, self, *a, **kw):' | |||||
103 | class HistoryAccessorBase(Configurable): |
|
102 | class HistoryAccessorBase(Configurable): | |
104 | """An abstract class for History Accessors """ |
|
103 | """An abstract class for History Accessors """ | |
105 |
|
104 | |||
106 | @abc.abstractmethod |
|
|||
107 | def get_tail(self, n=10, raw=True, output=False, include_latest=False): |
|
105 | def get_tail(self, n=10, raw=True, output=False, include_latest=False): | |
108 | pass |
|
106 | raise NotImplementedError | |
109 |
|
107 | |||
110 | @abc.abstractmethod |
|
|||
111 | def search(self, pattern="*", raw=True, search_raw=True, |
|
108 | def search(self, pattern="*", raw=True, search_raw=True, | |
112 | output=False, n=None, unique=False): |
|
109 | output=False, n=None, unique=False): | |
113 | pass |
|
110 | raise NotImplementedError | |
114 |
|
111 | |||
115 | @abc.abstractmethod |
|
|||
116 | def get_range(self, session, start=1, stop=None, raw=True,output=False): |
|
112 | def get_range(self, session, start=1, stop=None, raw=True,output=False): | |
117 | pass |
|
113 | raise NotImplementedError | |
118 |
|
114 | |||
119 | @abc.abstractmethod |
|
|||
120 | def get_range_by_str(self, rangestr, raw=True, output=False): |
|
115 | def get_range_by_str(self, rangestr, raw=True, output=False): | |
121 | pass |
|
116 | raise NotImplementedError | |
|
117 | ||||
122 |
|
118 | |||
123 | class HistoryAccessor(HistoryAccessorBase): |
|
119 | class HistoryAccessor(HistoryAccessorBase): | |
124 | """Access the history database without adding to it. |
|
120 | """Access the history database without adding to it. |
@@ -12,7 +12,6 b'' | |||||
12 | #----------------------------------------------------------------------------- |
|
12 | #----------------------------------------------------------------------------- | |
13 |
|
13 | |||
14 | from IPython.core.history import HistoryAccessorBase |
|
14 | from IPython.core.history import HistoryAccessorBase | |
15 | from IPython.utils import py3compat |
|
|||
16 | from IPython.utils.traitlets import Dict, List |
|
15 | from IPython.utils.traitlets import Dict, List | |
17 |
|
16 | |||
18 | try: |
|
17 | try: | |
@@ -46,9 +45,6 b' class ZMQHistoryManager(HistoryAccessorBase):' | |||||
46 | Load the history over ZMQ from the kernel. Wraps the history |
|
45 | Load the history over ZMQ from the kernel. Wraps the history | |
47 | messaging with loop to wait to get history results. |
|
46 | messaging with loop to wait to get history results. | |
48 | """ |
|
47 | """ | |
49 | # 'range' (fill in session, start and stop params), |
|
|||
50 | # 'tail' (fill in n) |
|
|||
51 | # 'search' (fill in pattern param). |
|
|||
52 | msg_id = self.client.history(raw=raw, output=output, |
|
48 | msg_id = self.client.history(raw=raw, output=output, | |
53 | hist_access_type=hist_access_type, |
|
49 | hist_access_type=hist_access_type, | |
54 | **kwargs) |
|
50 | **kwargs) | |
@@ -64,12 +60,6 b' class ZMQHistoryManager(HistoryAccessorBase):' | |||||
64 | break |
|
60 | break | |
65 | return history |
|
61 | return history | |
66 |
|
62 | |||
67 | def writeout_cache(self): |
|
|||
68 | """ |
|
|||
69 | Not needed for ZMQ-based histories. |
|
|||
70 | """ |
|
|||
71 | pass |
|
|||
72 |
|
||||
73 | def get_tail(self, n=10, raw=True, output=False, include_latest=False): |
|
63 | def get_tail(self, n=10, raw=True, output=False, include_latest=False): | |
74 | return self._load_history(hist_access_type='tail', n=n, raw=raw, |
|
64 | return self._load_history(hist_access_type='tail', n=n, raw=raw, | |
75 | output=output) |
|
65 | output=output) | |
@@ -87,7 +77,7 b' class ZMQHistoryManager(HistoryAccessorBase):' | |||||
87 |
|
77 | |||
88 | def get_range_by_str(self, rangestr, raw=True, output=False): |
|
78 | def get_range_by_str(self, rangestr, raw=True, output=False): | |
89 | return self._load_history(hist_access_type='range', raw=raw, |
|
79 | return self._load_history(hist_access_type='range', raw=raw, | |
90 | output=output, rangestr=rangetr) |
|
80 | output=output, rangestr=rangestr) | |
91 |
|
81 | |||
92 | def end_session(self): |
|
82 | def end_session(self): | |
93 | """ |
|
83 | """ | |
@@ -96,16 +86,8 b' class ZMQHistoryManager(HistoryAccessorBase):' | |||||
96 | pass |
|
86 | pass | |
97 |
|
87 | |||
98 | def reset(self, new_session=True): |
|
88 | def reset(self, new_session=True): | |
99 | """Clear the session history, releasing all object references, and |
|
89 | """ | |
100 | optionally open a new session.""" |
|
90 | Nothing to do for ZMQ-based histories. | |
101 | self.output_hist.clear() |
|
91 | """ | |
102 | # The directory history can't be completely empty |
|
92 | pass | |
103 | self.dir_hist[:] = [py3compat.getcwd()] |
|
|||
104 |
|
||||
105 | if new_session: |
|
|||
106 | if self.session_number: |
|
|||
107 | self.end_session() |
|
|||
108 | self.input_hist_parsed[:] = [""] |
|
|||
109 | self.input_hist_raw[:] = [""] |
|
|||
110 | self.new_session() |
|
|||
111 |
|
93 |
General Comments 0
You need to be logged in to leave comments.
Login now