| |
- __builtin__.object
-
- Action
-
- Step
class Action(__builtin__.object) |
|
This class represents a list of actions, where an action is
recursively defined as a container of other actions.
Custom actions *must* implement the following methods:
- 'on_reset' method to reset internal variables
Custom actions can find these methods usefull:
- Use get_return_value() to get previous step return value
- Call 'seek' to move through the actions steps
- Call done() when finished
@ATTRIBS
(str) name : mnemonic name for the action
(list) steps : set of sub-actions which composes the action
(int) stepi : index for the next step in self.steps member |
|
Methods defined here:
- __init__(self, name, *steps)
- @PARAMS
(str) name : mnemonic name for the action
(list) steps : set of sub-actions which composes the action
- __str__(self)
- Shows the step name and the next step
- done(self)
- Call this when action has finished.
- get_action_by_id(self, actname)
- Get action using his 'name'.
@PARAMS
(str) actname : 'name' attribute of the action to search
@RETURN
| SUCCESS : (int) action index in self.steps
| FAILURE : (None)
- get_next_step(self)
- Get the next step.
@RETURN
(Action) next step.
@NOTES
In particular, should return a 'Step' instance.
- get_return_value(self)
- Gets return value from previous action, if any.
@RETURN
| SUCCESS : return value (it could be None as well)
| FAILURE : (None)
- is_done(self)
- Query action execution state.
@RETURN
| True : action has ended
- is_waiting(self)
- Query action state.
@RETURN
| True : sub-action is being executed so action is stalled
| False : action is being executed
- on_reset(self, oldstep=None)
- This method is invoked when 'reset' function is called.
A custom action should reset its internal variables to initial state
to be able to be executed again in the future.
This method is also called when entering a sub-action to reset
sub-action state. In this case 'oldstep' optional parameter is set;
it can be used to fetch additional data from previous step by
'get_return_value'.
@PARAMS
| (None) oldstep - manual 'reset' method call
| (Action) oldstep - previously executed step
- reset(self, oldstep=None)
- Recursively resets all the actions to be ready to new calls.
@PARAMS
| (None) oldstep : this should be None when called for resetting
the action.
| (Step) oldstep : this should be last executed Step when called
for entering the sub-action
@NOTES
This functions invokes 'on_reset' method for each action.
- seek(self, stepi)
- Set next action to perform.
This function is very usefull for implementing loops. One could
use an attribute as a test, call 'seek' as continue instruction and
'done' to stop.
@PARAMS
(int) stepi : index of the action in self.steps
- step(self)
- Performs a step in the action.
@RETURN
An optional return value can be returned by the step.
@NOTES
The same return value is saved and can be retrieved by
'get_return_value' method.
Data descriptors defined here:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
|
class Step(Action) |
|
This class implements a particular Action composed by a single
function. |
|
- Method resolution order:
- Step
- Action
- __builtin__.object
Methods defined here:
- __init__(self, name, func)
- @PARAMS
(str) name : mnemonic name for the step
func : callback function to call on step
- __str__(self)
- Shows step name
- get_next_step(self)
- Step is not a collection.
- on_reset(self, oldstep=None)
- on_reset function does nothin on a Step.
- reset(self, oldstep)
- Reset function does nothin on a Step.
- step(self)
- Calls the callback function and returns optional return value.
Methods inherited from Action:
- done(self)
- Call this when action has finished.
- get_action_by_id(self, actname)
- Get action using his 'name'.
@PARAMS
(str) actname : 'name' attribute of the action to search
@RETURN
| SUCCESS : (int) action index in self.steps
| FAILURE : (None)
- get_return_value(self)
- Gets return value from previous action, if any.
@RETURN
| SUCCESS : return value (it could be None as well)
| FAILURE : (None)
- is_done(self)
- Query action execution state.
@RETURN
| True : action has ended
- is_waiting(self)
- Query action state.
@RETURN
| True : sub-action is being executed so action is stalled
| False : action is being executed
- seek(self, stepi)
- Set next action to perform.
This function is very usefull for implementing loops. One could
use an attribute as a test, call 'seek' as continue instruction and
'done' to stop.
@PARAMS
(int) stepi : index of the action in self.steps
Data descriptors inherited from Action:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
| |