Inheritance diagram for IPython.core.history:
History related magics and functionality
Bases: IPython.config.configurable.Configurable
Access the history database without adding to it.
This is intended for use by standalone history tools. IPython shells use HistoryManager, below, which is a subclass of this.
Create a new history accessor.
Parameters : | profile : str
hist_file : str
config : :
|
---|
Get the config class config section
Get the help string for this class in ReST format.
If inst is given, it’s current trait values will be used in place of class defaults.
Get the help string for a single trait.
If inst is given, it’s current trait values will be used in place of the class default.
Get the help string for a single trait and print it.
Get a list of all the names of this classes traits.
This method is just like the trait_names() method, but is unbound.
Get a list of all the traits of this class.
This method is just like the traits() method, but is unbound.
The TraitTypes returned don’t know anything about the values that the various HasTrait’s instances are holding.
This follows the same algorithm as traits does and does not allow for any simple way of specifying merely that a metadata name exists, but has any value. This is because get_metadata returns None if a metadata key doesn’t exist.
A trait whose value must be an instance of a specified class.
The value can also be an instance of a subclass of the specified class.
A trait whose value must be an instance of a specified class.
The value can also be an instance of a subclass of the specified class.
Retrieve input by session.
Parameters : | session : int
start : int
stop : int
raw : bool
output : bool
|
---|---|
Returns : | An iterator over the desired lines. Each line is a 3-tuple, either : (session, line, input) if output is False, or : (session, line, (input, output)) if output is True. : |
Get lines of history from a string of ranges, as used by magic commands %hist, %save, %macro, etc.
Parameters : | rangestr : str
raw, output : bool
|
---|---|
Returns : | Tuples as :meth:`get_range` : |
get info about a session
Parameters : | session : int
|
---|---|
Returns : | (session_id [int], start [datetime], end [datetime], num_cmds [int], : remark [unicode]) : Sessions that are running or did not exit cleanly will have `end=None` : and `num_cmds=None`. : |
Get the last n lines from the history database.
Parameters : | n : int
raw, output : bool
include_latest : bool
|
---|---|
Returns : | Tuples as :meth:`get_range` : |
A trait for unicode strings.
Connect to the database, and create tables if necessary.
Setup a handler to be called when a trait changes.
This is used to setup dynamic notifications of trait changes.
Static handlers can be created by creating methods on a HasTraits subclass with the naming convention ‘_[traitname]_changed’. Thus, to create static handler for the trait ‘a’, create the method _a_changed(self, name, old, new) (fewer arguments can be used, see below).
Parameters : | handler : callable
name : list, str, None
remove : bool
|
---|
Search the database using unix glob-style matching (wildcards * and ?).
Parameters : | pattern : str
search_raw : bool
raw, output : bool
|
---|---|
Returns : | Tuples as :meth:`get_range` : |
Get metadata values for trait by key.
Get a list of all the names of this classes traits.
Get a list of all the traits of this class.
The TraitTypes returned don’t know anything about the values that the various HasTrait’s instances are holding.
This follows the same algorithm as traits does and does not allow for any simple way of specifying merely that a metadata name exists, but has any value. This is because get_metadata returns None if a metadata key doesn’t exist.
Fire the traits events when the config is updated.
Overridden by HistoryManager to dump the cache before certain database lookups.
Bases: IPython.core.history.HistoryAccessor
A class to organize all history-related functionality in one place.
Create a new history manager associated with a shell instance.
Get the config class config section
Get the help string for this class in ReST format.
If inst is given, it’s current trait values will be used in place of class defaults.
Get the help string for a single trait.
If inst is given, it’s current trait values will be used in place of the class default.
Get the help string for a single trait and print it.
Get a list of all the names of this classes traits.
This method is just like the trait_names() method, but is unbound.
Get a list of all the traits of this class.
This method is just like the traits() method, but is unbound.
The TraitTypes returned don’t know anything about the values that the various HasTrait’s instances are holding.
This follows the same algorithm as traits does and does not allow for any simple way of specifying merely that a metadata name exists, but has any value. This is because get_metadata returns None if a metadata key doesn’t exist.
A trait whose value must be an instance of a specified class.
The value can also be an instance of a subclass of the specified class.
A trait whose value must be an instance of a specified class.
The value can also be an instance of a subclass of the specified class.
An integer trait.
Longs that are unnecessary (<= sys.maxint) are cast to ints.
An instance of a Python list.
A boolean (True, False) trait.
An instance of a Python list.
An instance of a Python list.
Close the database session, filling in the end time and line count.
Retrieve input by session.
Parameters : | session : int
start : int
stop : int
raw : bool
output : bool
|
---|---|
Returns : | An iterator over the desired lines. Each line is a 3-tuple, either : (session, line, input) if output is False, or : (session, line, (input, output)) if output is True. : |
Get lines of history from a string of ranges, as used by magic commands %hist, %save, %macro, etc.
Parameters : | rangestr : str
raw, output : bool
|
---|---|
Returns : | Tuples as :meth:`get_range` : |
get info about a session
Parameters : | session : int
|
---|---|
Returns : | (session_id [int], start [datetime], end [datetime], num_cmds [int], : remark [unicode]) : Sessions that are running or did not exit cleanly will have `end=None` : and `num_cmds=None`. : |
Get the last n lines from the history database.
Parameters : | n : int
raw, output : bool
include_latest : bool
|
---|---|
Returns : | Tuples as :meth:`get_range` : |
A trait for unicode strings.
Connect to the database, and create tables if necessary.
An instance of a Python list.
An instance of a Python list.
Give the current session a name in the history database.
Get a new session number.
Setup a handler to be called when a trait changes.
This is used to setup dynamic notifications of trait changes.
Static handlers can be created by creating methods on a HasTraits subclass with the naming convention ‘_[traitname]_changed’. Thus, to create static handler for the trait ‘a’, create the method _a_changed(self, name, old, new) (fewer arguments can be used, see below).
Parameters : | handler : callable
name : list, str, None
remove : bool
|
---|
An instance of a Python dict.
An instance of a Python dict.
Clear the session history, releasing all object references, and optionally open a new session.
A trait whose value must be an instance of a specified class.
The value can also be an instance of a subclass of the specified class.
A trait whose value must be an instance of a specified class.
The value can also be an instance of a subclass of the specified class.
Search the database using unix glob-style matching (wildcards * and ?).
Parameters : | pattern : str
search_raw : bool
raw, output : bool
|
---|---|
Returns : | Tuples as :meth:`get_range` : |
An integer trait.
Longs that are unnecessary (<= sys.maxint) are cast to ints.
A trait whose value must be an instance of a specified class.
The value can also be an instance of a subclass of the specified class.
Store source and raw input in history and create input cache variables _i*.
Parameters : | line_num : int
source : str
source_raw : str, optional
|
---|
If database output logging is enabled, this saves all the outputs from the indicated prompt number to the database. It’s called by run_cell after code has been executed.
Parameters : | line_num : int
|
---|
Get metadata values for trait by key.
Get a list of all the names of this classes traits.
Get a list of all the traits of this class.
The TraitTypes returned don’t know anything about the values that the various HasTrait’s instances are holding.
This follows the same algorithm as traits does and does not allow for any simple way of specifying merely that a metadata name exists, but has any value. This is because get_metadata returns None if a metadata key doesn’t exist.
Fire the traits events when the config is updated.
Write any entries in the cache to the database.
Bases: threading.Thread
This thread takes care of writing history to the database, so that the UI isn’t held up while that happens.
It waits for the HistoryManager’s save_flag to be set, then writes out the history cache. The main thread is responsible for setting the flag when the cache size reaches a defined threshold.
This can be called from the main thread to safely stop this thread.
Note that it does not attempt to write out remaining history before exiting. That should be done by calling the HistoryManager’s end_session method.
Turn a string of history ranges into 3-tuples of (session, start, stop).
Examples
list(extract_input_ranges(“~8/5-~7/4 2”)) [(-8, 5, None), (-7, 1, 4), (0, 2, 3)]
return an empty list in the absence of sqlite