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

Class History

source code

object --+
         |
        History
Known Subclasses:

Base class for history implementations. All concrete history implementations must extend this class.
Instance Methods [hide private]
 
__init__(self)
x.__init__(...) initializes x; see help(type(x)) for signature
source code
 
show(self, out=sys.stderr)
Dump the history to a file-like object (defaulting to standard output).
source code
str
get_last_matching_item(self, command_name)
Get the most recently entered item that matches command_name at the beginning.
source code
str
get_last_item(self)
Get the most recent item in the history.
source code
str
get_item(self, index)
Get an item from the history.
source code
 
set_completer_delims(self, s)
Set the completer delimiters--the characters that delimit tokens that are eligible for completion.
source code
str
get_completer_delims(self)
Get the completer delimiters--the characters that delimit tokens that are eligible for completion.
source code
int
get_total(self)
Get the total number number of commands in the history.
source code
 
__set_max_length(self, n) source code
 
__get_max_length(self) source code
int
get_max_length(*__args, **__kw)
Get the maximum length of the history.
source code
 
set_max_length(*__args, **__kw)
Set the maximum length of the history.
source code
 
add_item(*__args, **__kw)
Add (append) a line to the history buffer.
source code
 
remove_item(*__args, **__kw)
Remove a line from the history buffer.
source code
 
clear_history(*__args, **__kw)
Clear the history buffer.
source code
list
get_history_list(self)
Get a copy of the history buffer.
source code
 
remove_matches(self, regexp_string)
Remove all history items that match a regular expression.
source code
 
cut_back_to(self, index)
Cut the history back to the specified index, removing all entries more recent than that index.
source code
 
replace_history(self, commands)
Replace the entire contents of the history with another set of values
source code
 
save_history_file(self, path)
Save the history to a file.
source code
 
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.
source code

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

Properties [hide private]
  total
The total number number of commands in the history.
  maxLength
The maximum length of the history

Inherited from object: __class__

Method Details [hide private]

__init__(self)
(Constructor)

source code 

x.__init__(...) initializes x; see help(type(x)) for signature

Overrides: object.__init__
(inherited documentation)

show(self, out=sys.stderr)

source code 
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)

source code 
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)

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

get_item(self, index)

source code 
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)

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

get_completer_delims(self)

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

get_total(self)

source code 
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(*__args, **__kw)

source code 
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(*__args, **__kw)

source code 
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(*__args, **__kw)

source code 
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(*__args, **__kw)

source code 
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(*__args, **__kw)

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

get_history_list(self)

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

remove_matches(self, regexp_string)

source code 
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)

source code 
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)

source code 
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)

source code 
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)

source code 
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

Property Details [hide private]

total

The total number number of commands in the history. Identical to calling get_total().
Get Method:
unreachable.total(self) - The total number number of commands in the history.

maxLength

The maximum length of the history
Get Method:
__get_max_length(self)
Set Method:
__set_max_length(self, n)