pycrossword  0.4
Pure-Python implementation of a crossword puzzle generator and editor
Public Member Functions | Public Attributes | Private Member Functions | List of all members
pycross.utils.undo.Operation Class Reference

Abstract undoable operation (action) with a do/undo callback pair. More...

Public Member Functions

def __init__ (self, command, undocommand, description='', **kwargs)
 Constructor. More...
 
def __call__ (self)
 operator () overload to call Operation::command from the instance directly. More...
 
def undo (self)
 Undoes the executed Operation::command by calling Operation::undocommand. More...
 

Public Attributes

 command
 dict the command that can be undone (see constructor for description) More...
 
 undocommand
 dict the reverse command undoing Operation::command (see constructor for description) More...
 
 description
 str optional description of the command (what is does) More...
 

Private Member Functions

def _do_cmd (self, cmd)
 Util method that executes the Do or the Undo command passing their arguments. More...
 

Detailed Description

Abstract undoable operation (action) with a do/undo callback pair.

Constructor & Destructor Documentation

◆ __init__()

def pycross.utils.undo.Operation.__init__ (   self,
  command,
  undocommand,
  description = '',
**  kwargs 
)

Constructor.

Parameters
commanddict the 'do' command (direct action) constisting of a pointer to a function/method and arguments passed to it. The dictionary keys are as follows:
  • func callable pointer to the 'do' function or other callable object
  • args tuple positional arguments passed to the 'do' function (optional)
  • kwargs dict keyword arguments passed to the 'do' function (optional)
Warning
The first parameter passed to 'func' is always the pointer to this Operation instance. So 'args' and/or 'kwargs' (if present) will start from the second parameter.
Parameters
undocommanddict the 'undo' command (reverse action undoing whatever 'command' does). Its keys are the same as in 'command'.
descriptionstr optional description of the command (what is does). The default is an empty string.
kwargskeyword arguments any extra objects that can be stored in the Operation instance to address in the do / undo callbacks.
Warning
Note that neither 'command' nor 'undocommand' provide means to return a result – their callback functions should therefore return nothing (None)

Member Function Documentation

◆ __call__()

def pycross.utils.undo.Operation.__call__ (   self)

operator () overload to call Operation::command from the instance directly.

◆ _do_cmd()

def pycross.utils.undo.Operation._do_cmd (   self,
  cmd 
)
private

Util method that executes the Do or the Undo command passing their arguments.

Parameters
cmddict either Operation::command or Operation::undocommand

◆ undo()

def pycross.utils.undo.Operation.undo (   self)

Undoes the executed Operation::command by calling Operation::undocommand.

Member Data Documentation

◆ command

pycross.utils.undo.Operation.command

dict the command that can be undone (see constructor for description)

◆ description

pycross.utils.undo.Operation.description

str optional description of the command (what is does)

◆ undocommand

pycross.utils.undo.Operation.undocommand

dict the reverse command undoing Operation::command (see constructor for description)


The documentation for this class was generated from the following file: