CommandManager#

class sunpy.database.commands.CommandManager[source]#

Bases: object

The CommandManager saves all executed and reverted commands to act as an undo-redo-manager. All executed commands are saved in the list attribute undo_commands and all undone commands are saved in the list attribute redo_commands. It is not recommended to alter these stacks directly; instead, use the methods push_undo_command, pop_undo_command, push_redo_command, and pop_redo_command, respectively.

Methods Summary

clear_histories()

Clears all entries from the undo and redo history.

do(command)

Execute the given command (a subclass of DatabaseOperation).

pop_redo_command()

Remove the last command from the redo command stack and return it.

pop_undo_command()

Remove the last command from the undo command stack and return it.

push_redo_command(command)

Push the given command to the redo command stack.

push_undo_command(command)

Push the given command to the undo command stack.

redo([n])

Redo the last n commands which have been undone using the undo method.

undo([n])

Undo the last n commands.

Methods Documentation

clear_histories()[source]#

Clears all entries from the undo and redo history. If one or both of the histories are already empty, no exception is raised.

do(command)[source]#

Execute the given command (a subclass of DatabaseOperation). Exceptions raised from the command are not caught. The passed argument may also be an iterable of commands. In this case, every command of the iterable is executed and only one entry is saved in the undo history.

pop_redo_command()[source]#

Remove the last command from the redo command stack and return it. If the command stack is empty, sunpy.database.commands.EmptyCommandStackError is raised.

pop_undo_command()[source]#

Remove the last command from the undo command stack and return it. If the command stack is empty, sunpy.database.commands.EmptyCommandStackError is raised.

push_redo_command(command)[source]#

Push the given command to the redo command stack.

push_undo_command(command)[source]#

Push the given command to the undo command stack.

redo(n=1)[source]#

Redo the last n commands which have been undone using the undo method. The default is to redo only the last command which has been undone using the undo method. If there is no command that can be redone because n is too big or because no command has been undone yet, sunpy.database.commands.EmptyCommandStackError is raised.

undo(n=1)[source]#

Undo the last n commands. The default is to undo only the last command. If there is no command that can be undone because n is too big or because no command has been executed yet, sunpy.database.commands.EmptyCommandStackError is raised.