From 55f809054e87c130db285d573cdf60bf421f7e41 2014-11-14 01:56:47 From: Doug Blank Date: 2014-11-14 01:56:47 Subject: [PATCH] Addressed issues: replaced abc with NotImplementedError; removed unneeded methods; fixed typo --- diff --git a/IPython/core/history.py b/IPython/core/history.py index 92c1a5d..53d22e5 100644 --- a/IPython/core/history.py +++ b/IPython/core/history.py @@ -15,7 +15,6 @@ from __future__ import print_function # Stdlib imports import atexit import datetime -import abc import os import re try: @@ -103,22 +102,19 @@ def catch_corrupt_db(f, self, *a, **kw): class HistoryAccessorBase(Configurable): """An abstract class for History Accessors """ - @abc.abstractmethod def get_tail(self, n=10, raw=True, output=False, include_latest=False): - pass + raise NotImplementedError - @abc.abstractmethod def search(self, pattern="*", raw=True, search_raw=True, output=False, n=None, unique=False): - pass + raise NotImplementedError - @abc.abstractmethod def get_range(self, session, start=1, stop=None, raw=True,output=False): - pass + raise NotImplementedError - @abc.abstractmethod def get_range_by_str(self, rangestr, raw=True, output=False): - pass + raise NotImplementedError + class HistoryAccessor(HistoryAccessorBase): """Access the history database without adding to it. diff --git a/IPython/terminal/console/zmqhistory.py b/IPython/terminal/console/zmqhistory.py index a2059b2..c982733 100644 --- a/IPython/terminal/console/zmqhistory.py +++ b/IPython/terminal/console/zmqhistory.py @@ -12,7 +12,6 @@ #----------------------------------------------------------------------------- from IPython.core.history import HistoryAccessorBase -from IPython.utils import py3compat from IPython.utils.traitlets import Dict, List try: @@ -46,9 +45,6 @@ class ZMQHistoryManager(HistoryAccessorBase): Load the history over ZMQ from the kernel. Wraps the history messaging with loop to wait to get history results. """ - # 'range' (fill in session, start and stop params), - # 'tail' (fill in n) - # 'search' (fill in pattern param). msg_id = self.client.history(raw=raw, output=output, hist_access_type=hist_access_type, **kwargs) @@ -64,12 +60,6 @@ class ZMQHistoryManager(HistoryAccessorBase): break return history - def writeout_cache(self): - """ - Not needed for ZMQ-based histories. - """ - pass - def get_tail(self, n=10, raw=True, output=False, include_latest=False): return self._load_history(hist_access_type='tail', n=n, raw=raw, output=output) @@ -87,7 +77,7 @@ class ZMQHistoryManager(HistoryAccessorBase): def get_range_by_str(self, rangestr, raw=True, output=False): return self._load_history(hist_access_type='range', raw=raw, - output=output, rangestr=rangetr) + output=output, rangestr=rangestr) def end_session(self): """ @@ -96,16 +86,8 @@ class ZMQHistoryManager(HistoryAccessorBase): pass def reset(self, new_session=True): - """Clear the session history, releasing all object references, and - optionally open a new session.""" - self.output_hist.clear() - # The directory history can't be completely empty - self.dir_hist[:] = [py3compat.getcwd()] - - if new_session: - if self.session_number: - self.end_session() - self.input_hist_parsed[:] = [""] - self.input_hist_raw[:] = [""] - self.new_session() + """ + Nothing to do for ZMQ-based histories. + """ + pass