##// END OF EJS Templates
Improve history API docs
Thomas Kluyver -
Show More
@@ -29,6 +29,7 b' import threading'
29 # Our own packages
29 # Our own packages
30 from IPython.config.configurable import Configurable
30 from IPython.config.configurable import Configurable
31 from IPython.external.decorator import decorator
31 from IPython.external.decorator import decorator
32 from IPython.utils.decorators import undoc
32 from IPython.utils.path import locate_profile
33 from IPython.utils.path import locate_profile
33 from IPython.utils import py3compat
34 from IPython.utils import py3compat
34 from IPython.utils.traitlets import (
35 from IPython.utils.traitlets import (
@@ -40,6 +41,7 b' from IPython.utils.warn import warn'
40 # Classes and functions
41 # Classes and functions
41 #-----------------------------------------------------------------------------
42 #-----------------------------------------------------------------------------
42
43
44 @undoc
43 class DummyDB(object):
45 class DummyDB(object):
44 """Dummy DB that will act as a black hole for history.
46 """Dummy DB that will act as a black hole for history.
45
47
@@ -59,7 +61,7 b' class DummyDB(object):'
59
61
60 @decorator
62 @decorator
61 def needs_sqlite(f, self, *a, **kw):
63 def needs_sqlite(f, self, *a, **kw):
62 """return an empty list in the absence of sqlite"""
64 """Decorator: return an empty list in the absence of sqlite."""
63 if sqlite3 is None or not self.enabled:
65 if sqlite3 is None or not self.enabled:
64 return []
66 return []
65 else:
67 else:
@@ -69,6 +71,7 b' def needs_sqlite(f, self, *a, **kw):'
69 if sqlite3 is not None:
71 if sqlite3 is not None:
70 DatabaseError = sqlite3.DatabaseError
72 DatabaseError = sqlite3.DatabaseError
71 else:
73 else:
74 @undoc
72 class DatabaseError(Exception):
75 class DatabaseError(Exception):
73 "Dummy exception when sqlite could not be imported. Should never occur."
76 "Dummy exception when sqlite could not be imported. Should never occur."
74
77
@@ -159,7 +162,7 b' class HistoryAccessor(Configurable):'
159 hist_file : str
162 hist_file : str
160 Path to an SQLite history database stored by IPython. If specified,
163 Path to an SQLite history database stored by IPython. If specified,
161 hist_file overrides profile.
164 hist_file overrides profile.
162 config :
165 config : :class:`~IPython.config.loader.Config`
163 Config object. hist_file can also be set through this.
166 Config object. hist_file can also be set through this.
164 """
167 """
165 # We need a pointer back to the shell for various tasks.
168 # We need a pointer back to the shell for various tasks.
@@ -254,8 +257,8 b' class HistoryAccessor(Configurable):'
254
257
255 @needs_sqlite
258 @needs_sqlite
256 @catch_corrupt_db
259 @catch_corrupt_db
257 def get_session_info(self, session=0):
260 def get_session_info(self, session):
258 """get info about a session
261 """Get info about a session.
259
262
260 Parameters
263 Parameters
261 ----------
264 ----------
@@ -383,6 +386,7 b' class HistoryAccessor(Configurable):'
383
386
384 Returns
387 Returns
385 -------
388 -------
389 entries
386 An iterator over the desired lines. Each line is a 3-tuple, either
390 An iterator over the desired lines. Each line is a 3-tuple, either
387 (session, line, input) if output is False, or
391 (session, line, input) if output is False, or
388 (session, line, (input, output)) if output is True.
392 (session, line, (input, output)) if output is True.
@@ -545,14 +549,14 b' class HistoryManager(HistoryAccessor):'
545 # Methods for retrieving history
549 # Methods for retrieving history
546 # ------------------------------
550 # ------------------------------
547 def get_session_info(self, session=0):
551 def get_session_info(self, session=0):
548 """get info about a session
552 """Get info about a session.
549
553
550 Parameters
554 Parameters
551 ----------
555 ----------
552
556
553 session : int
557 session : int
554 Session number to retrieve. The current session is 0, and negative
558 Session number to retrieve. The current session is 0, and negative
555 numbers count back from current session, so -1 is previous session.
559 numbers count back from current session, so -1 is the previous session.
556
560
557 Returns
561 Returns
558 -------
562 -------
@@ -616,6 +620,7 b' class HistoryManager(HistoryAccessor):'
616
620
617 Returns
621 Returns
618 -------
622 -------
623 entries
619 An iterator over the desired lines. Each line is a 3-tuple, either
624 An iterator over the desired lines. Each line is a 3-tuple, either
620 (session, line, input) if output is False, or
625 (session, line, input) if output is False, or
621 (session, line, (input, output)) if output is True.
626 (session, line, (input, output)) if output is True.
@@ -632,7 +637,7 b' class HistoryManager(HistoryAccessor):'
632 ## ----------------------------
637 ## ----------------------------
633 def store_inputs(self, line_num, source, source_raw=None):
638 def store_inputs(self, line_num, source, source_raw=None):
634 """Store source and raw input in history and create input cache
639 """Store source and raw input in history and create input cache
635 variables _i*.
640 variables ``_i*``.
636
641
637 Parameters
642 Parameters
638 ----------
643 ----------
@@ -803,7 +808,7 b' def extract_hist_ranges(ranges_str):'
803
808
804 Examples
809 Examples
805 --------
810 --------
806 list(extract_input_ranges("~8/5-~7/4 2"))
811 >>> list(extract_input_ranges("~8/5-~7/4 2"))
807 [(-8, 5, None), (-7, 1, 4), (0, 2, 3)]
812 [(-8, 5, None), (-7, 1, 4), (0, 2, 3)]
808 """
813 """
809 for range_str in ranges_str.split():
814 for range_str in ranges_str.split():
General Comments 0
You need to be logged in to leave comments. Login now