# CommandManager¶

class sunpy.database.commands.CommandManager[source] [edit on github]

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] [edit on github]

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] [edit on github]

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] [edit on github]

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] [edit on github]

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] [edit on github]

Push the given command to the redo command stack.

push_undo_command(command)[source] [edit on github]

Push the given command to the undo command stack.

redo(n=1)[source] [edit on github]

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] [edit on github]

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.