@@ -279,13 +279,12 @@ def __repr__( self ):
279279 return '<%s>' % ( self )
280280
281281 def __call__ ( self , machine = None , source = None , path = None , data = None ):
282- return self .execute (
283- truth = self .predicate ( machine = machine , source = source , path = path , data = data ),
284- machine = machine , source = source , path = path , data = data )
282+ truth = self .predicate ( machine = machine , source = source , path = path , data = data )
283+ return self .execute ( truth , machine = machine , source = source , path = path , data = data )
285284
286285 def execute ( self , truth , machine = None , source = None , path = None , data = None ):
287286 target = self .state if truth else None
288- #log.debug( "%s %-13.13s -> %10s w/ data: %r", machine.name_centered(), self, target, data )
287+ #log.debug( "%s %-13.13s -> %10s w/ truth: %r data: %r", machine.name_centered(), self, target, truth , data )
289288 return target
290289
291290
@@ -777,7 +776,7 @@ def transition( self, source, machine=None, path=None, data=None, ending=None ):
777776 """
778777 limited = ending is not None and source .sent >= ending
779778 while not self .terminal or self .greedy :
780- inp = None if limited else source .peek ()# raise TypeError to force stoppage
779+ inp = None if limited else source .peek () # raise TypeError to force stoppage
781780 try :
782781 choice = self .__getitem__ ( inp )
783782 except KeyError :
@@ -792,25 +791,25 @@ def transition( self, source, machine=None, path=None, data=None, ending=None ):
792791 yield machine ,None # 0+ non-transitions...
793792 continue
794793 break # No other transition possible; done
794+ if type ( choice ) is not list :
795+ choice = [ choice ]
795796
796797 # Found the transition or choice list (could be a state, a decide or decide, ...,
797798 # decide[, state]). Evaluate each target state/decide instance, 'til we find a
798799 # state/None. Even decides could end up yielding None, if all decide evaluate to None,
799800 # and no non-None default state .
800- for potential in ( choice if type ( choice ) is list else [ choice ] ) :
801+ for potential in choice :
801802 if potential is None or isinstance ( potential , state ):
802803 target = potential
803804 break
804805 try :
805- #log.debug( "%s <selfdecide> on %s", self.name_centered(), choice )
806+ #log.debug( "%s <selfdecide> on %s", self.name_centered(), potential )
806807 target = potential ( # this decision is made in our parent machine's context
807808 source = source , machine = machine , path = path , data = data )
808809 except Exception as exc :
809- log .warning ( "%s <selfdecide> on %s failed: %r" , self .name_centered (),
810- potential , exc )
810+ log .warning ( "%s <selfdecide> on %s failed: %r" , self .name_centered (), potential , exc )
811811 raise
812- #log.debug( "%s <selfdecide> on %s == %s", self.name_centered(),
813- # potential, target )
812+ #log.debug( "%s <selfdecide> on %s == %s", self.name_centered(), potential, target )
814813 if target :
815814 break
816815
0 commit comments