Update of /cvsroot/docstring/dps/dps
In directory usw-pr-cvs1:/tmp/cvs-serv16546/dps/dps
Modified Files:
statemachine.py
Log Message:
- Added support for TransitionCorrection exception.
Index: statemachine.py
===================================================================
RCS file: /cvsroot/docstring/dps/dps/statemachine.py,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -d -r1.13 -r1.14
*** statemachine.py 25 Jan 2002 23:58:36 -0000 1.13
--- statemachine.py 18 Apr 2002 02:56:54 -0000 1.14
***************
*** 28,31 ****
--- 28,32 ----
- `TransitionMethodNotFound`
- `UnexpectedIndentationError`
+ - `TransitionCorrection`: Raised to switch to another transition.
Functions:
***************
*** 105,115 ****
__docformat__ = 'restructuredtext'
- __all__ = ['StateMachine', 'StateMachineWS', 'SearchStateMachine',
- 'SearchStateMachineWS', 'State', 'StateWS',
- 'UnknownStateError', 'DuplicateStateError',
- 'UnknownTransitionError', 'DuplicateTransitionError',
- 'TransitionPatternNotFound', 'TransitionMethodNotFound',
- 'UnexpectedIndentationError', 'string2lines', 'extractindented']
-
import sys, re, string
--- 106,109 ----
***************
*** 357,378 ****
"""
if self.debug:
! print >>sys.stderr, ('\nStateMachine.matchtransition: state "%s",'
! ' transitions "%s"' %
! (state.__class__.__name__,
! [t for t in state.transitionorder]))
for name in state.transitionorder:
! pattern, method, nextstate = state.transitions[name]
! if self.debug:
! print >>sys.stderr, ('\nStateMachine.matchtransition: '
! 'Trying transition "%s" in state "%s".' %
! (name, state.__class__.__name__))
! match = self.match(pattern)
! if match:
if self.debug:
! print >>sys.stderr, ('\nStateMachine.matchtransition: '
! 'Matched transition "%s" in state '
! '"%s".' % (name,
! state.__class__.__name__))
! return method(match, context, nextstate)
else:
return context, None, [] # no match
--- 351,378 ----
"""
if self.debug:
! print >>sys.stderr, (
! '\nStateMachine.matchtransition: state="%s", transitions=%r.'
! % (state.__class__.__name__, state.transitionorder))
for name in state.transitionorder:
! while 1:
! pattern, method, nextstate = state.transitions[name]
if self.debug:
! print >>sys.stderr, (
! '\nStateMachine.matchtransition: Trying transition '
! '"%s" in state "%s".'
! % (name, state.__class__.__name__))
! match = self.match(pattern)
! if match:
! if self.debug:
! print >>sys.stderr, (
! '\nStateMachine.matchtransition: Matched '
! 'transition "%s" in state "%s".'
! % (name, state.__class__.__name__))
! try:
! return method(match, context, nextstate)
! except TransitionCorrection, detail:
! name = str(detail)
! continue # try again with new transition name
! break
else:
return context, None, [] # no match
***************
*** 983,986 ****
--- 983,993 ----
class TransitionMethodNotFound(Exception): pass
class UnexpectedIndentationError(Exception): pass
+
+
+ class TransitionCorrection(Exception):
+
+ """
+ Raise from within a transition method to switch to another transition.
+ """
|