Package grizzled :: Module history :: Class History
[frames] | no frames]

Class History

object --+
         |
        History

Base class for history implementations. All concrete history implementations must extend this class.
Instance Methods
 
__init__(self)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
 
show(self, out=sys.stdout)
Dump the history to a file-like object (defaulting to standard output).
str
get_last_matching_item(self, command_name)
Get the most recently entered item that matches command_name at the beginning.
str
get_last_item(self)
Get the most recent item in the history.
str
get_item(self, index)
Get an item from the history.
 
set_completer_delims(self, s)
Set the completer delimiters--the characters that delimit tokens that are eligible for completion.
str
get_completer_delims(self)
Get the completer delimiters--the characters that delimit tokens that are eligible for completion.
 
total(self)
The total number number of commands in the history.
int
get_total(self)
Get the total number number of commands in the history.
int
get_max_length(self)
Get the maximum length of the history.
 
set_max_length(self, n)
Set the maximum length of the history.
 
add_item(self, line)
Add (append) a line to the history buffer.
 
remove_item(self, i)
Remove a line from the history buffer.
 
clear_history(self)
Clear the history buffer.
list
get_history_list(self)
Get a copy of the history buffer.
 
remove_matches(self, regexp_string)
Remove all history items that match a regular expression.
 
cut_back_to(self, index)
Cut the history back to the specified index, removing all entries more recent than that index.
 
replace_history(self, commands)
Replace the entire contents of the history with another set of values
 
save_history_file(self, path)
Save the history to a file.
 
load_history_file(self, path)
Load the history buffer with the contents of a file, completely replacing the in-memory history with the file's contents.

Inherited from object: __delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __str__

Class Variables
  maxLength = property(__get_max_length, __set_max_length, doc= ...
Properties

Inherited from object: __class__

Method Details

__init__(self)
(Constructor)

 
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
Overrides: object.__init__
(inherited documentation)

show(self, out=sys.stdout)

 
Dump the history to a file-like object (defaulting to standard output).
Parameters:
  • out (file) - Where to dump the history.

get_last_matching_item(self, command_name)

 
Get the most recently entered item that matches command_name at the beginning.
Parameters:
  • command_name (str) - The string to match against the commands in the history
Returns: str
the matching string, or None

get_last_item(self)

 
Get the most recent item in the history.
Returns: str
The most recent command, or None

get_item(self, index)

 
Get an item from the history.
Parameters:
  • index (int) - 0-based index of the item to get. The larger the index value, the more recent the entry
Returns: str
the item at that index
Raises:
  • IndexError - Index out of range

set_completer_delims(self, s)

 
Set the completer delimiters--the characters that delimit tokens that are eligible for completion.
Parameters:
  • s (str) - The delimiters

get_completer_delims(self)

 
Get the completer delimiters--the characters that delimit tokens that are eligible for completion.
Returns: str
the delimiters

total(self)

 
The total number number of commands in the history. Identical to calling get_total().
Decorators:
  • @property

get_total(self)

 
Get the total number number of commands in the history. Identical to the total property.
Returns: int
the number of commands in the history

get_max_length(self)

 
Get the maximum length of the history. This isn't the maximum number of entries in the in-memory history buffer; instead, it's the maximum number of entries that will be saved to the history file. Subclasses must provide an implementation of this method.
Returns: int
the maximum saved size of the history
Decorators:
  • @abstract

set_max_length(self, n)

 
Set the maximum length of the history. This isn't the maximum number of entries in the in-memory history buffer; instead, it's the maximum number of entries that will be saved to the history file. Subclasses must provide an implementation of this method.
Parameters:
  • n (int) - the maximum saved size of the history
Decorators:
  • @abstract

add_item(self, line)

 
Add (append) a line to the history buffer. Subclasses must provide an implementation of this method.
Parameters:
  • line (str) - the command to append to the history
Decorators:
  • @abstract

remove_item(self, i)

 
Remove a line from the history buffer. Subclasses must provide an implementation of this method.
Parameters:
  • i (int) - the 0-based index of the item to be removed
Decorators:
  • @abstract

clear_history(self)

 
Clear the history buffer. Subclasses must provide an implementation of this method.
Decorators:
  • @abstract

get_history_list(self)

 
Get a copy of the history buffer.
Returns: list
a list of commands from the history

remove_matches(self, regexp_string)

 
Remove all history items that match a regular expression.
Parameters:
  • regexp_string (str) - the uncompiled regular expression to match
Raises:

cut_back_to(self, index)

 
Cut the history back to the specified index, removing all entries more recent than that index.
Parameters:
  • index (int) - the index of the command that should become the last command in the history
Raises:
  • IndexError - index out of range

replace_history(self, commands)

 
Replace the entire contents of the history with another set of values
Parameters:
  • commands (list) - List of strings to put in the history after clearing it of any existing entries

save_history_file(self, path)

 
Save the history to a file. The file is overwritten with the contents of the history buffer.
Parameters:
  • path (str) - Path to the history file to receive the output.
Raises:
  • IOError - Unable to open file

load_history_file(self, path)

 
Load the history buffer with the contents of a file, completely replacing the in-memory history with the file's contents.
Parameters:
  • path (str) - Path to the history file to read
Raises:
  • IOError - Unable to open file

Class Variable Details

maxLength

Value:
property(__get_max_length, __set_max_length, doc= "The maximum length \
of the history")