Home | Trees | Index | Help |
|
---|
Package docutils :: Module statemachine :: Class State |
|
StateWS
State superclass. Contains a list of transitions, and transition methods.
Transition methods all have the same signature. They take 3 parameters:
re
match object. match.string contains the matched input line,
match.start() gives the start index of the match, and
match.end() gives the end index.Transition methods all return a 3-tuple:
Transition methods may raise an EOFError
to cut processing short.
There are two implicit transitions, and corresponding transition methods
are defined: bof()
handles the beginning-of-file, and eof()
handles
the end-of-file. These methods have non-standard signatures and return
values. bof()
returns the initial context and results, and may be used
to return a header string, or do any other processing needed. eof()
should handle any remaining context and wrap things up; it returns the
final processing result.
Typical applications need only subclass State
(or a subclass), set the
patterns
and initial_transitions
class attributes, and provide
corresponding transition methods. The default object initialization will
take care of constructing the list of transitions.
Method Summary | |
---|---|
Initialize a State object; make & add initial transitions. | |
Make and add transitions listed in self.initial_transitions . | |
Add a transition to the start of the transition list. | |
Add a list of transitions to the start of the transition list. | |
Handle beginning-of-file. | |
Handle end-of-file. | |
Make & return a transition tuple based on name . | |
Return a list of transition names and a transition mapping. | |
Called when there is no match from StateMachine.check_line() . | |
A "do nothing" transition method. | |
Remove a transition by name . | |
Initialize this State before running the state machine; called from
self.state_machine.run() . | |
Remove circular references to objects no longer required. |
Class Variable Summary | |
---|---|
NoneType |
initial_transitions = None |
NoneType |
nested_sm = None |
NoneType |
nested_sm_kwargs = None |
NoneType |
patterns = None |
Method Details |
---|
__init__(self,
state_machine,
debug=0)
|
add_initial_transitions(self)Make and add transitions listed inself.initial_transitions . |
add_transition(self, name, transition)Add a transition to the start of the transition list. Parameter Exception: |
add_transitions(self, names, transitions)Add a list of transitions to the start of the transition list. Parameters:
Exceptions: |
bof(self, context)Handle beginning-of-file. Return unchanged Override in subclasses. Parameter |
eof(self, context)Handle end-of-file. Return empty result. Override in subclasses. Parameter |
make_transition(self, name, next_state=None)Make & return a transition tuple based on This is a convenience function to simplify transition creation. Parameters:
Exceptions: |
make_transitions(self, name_list)Return a list of transition names and a transition mapping. Parameter |
no_match(self, context, transitions)Called when there is no match from Return the same values returned by transition methods:
Override in subclasses to catch this event. |
nop(self, match, context, next_state)A "do nothing" transition method. Return unchanged |
remove_transition(self, name)Remove a transition by Exception: |
runtime_init(self)Initialize thisState before running the state machine; called from
self.state_machine.run() . |
unlink(self)Remove circular references to objects no longer required. |
Class Variable Details |
---|
initial_transitions
|
nested_sm
|
nested_sm_kwargs
|
patterns
|
Home | Trees | Index | Help |
|
---|
Generated by Epydoc 2.0 on Tue Jul 22 05:31:39 2003 | http://epydoc.sf.net |