diff options
Diffstat (limited to 'tutorius/core.py')
-rw-r--r-- | tutorius/core.py | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/tutorius/core.py b/tutorius/core.py index 15a0c87..d08c136 100644 --- a/tutorius/core.py +++ b/tutorius/core.py @@ -271,7 +271,7 @@ class State(object): if len(self._actions) != len(otherState._actions): return False - if len(self._event_filters) != len(otherState._event_filters): + if len(self._transitions) != len(otherState._transitions): return False for act in self._actions: @@ -287,12 +287,14 @@ class State(object): return False # Do they have the same event filters? - for event in self._event_filters: + for event in self._transitions: + state_name = self._transitions[event] found = False # For every event filter in the other state, try to match it with # the current filter. We just need to find one with the right # properties and values. - for otherEvent in otherState._event_filters: + for otherEvent in otherState._transitions: + other_state_name = otherState._transitions[otherEvent] if event == otherEvent: found = True break @@ -515,10 +517,10 @@ class FiniteStateMachine(State): #TODO : Move this code inside the State itself - we're breaking # encap :P - if st._transitions: - for event, state in st._transitions.items(): - if state == state_name: - del st._transitions[event] + for event in st._transitions.keys(): + state = st._transitions[event] + if state == state_name: + del st._transitions[event] # Remove the state from the dictionary del self._states[state_name] @@ -536,8 +538,9 @@ class FiniteStateMachine(State): next_states = set() - for event, state in state._transitions: - next_states.add(state) + for event in state._transitions.keys(): + state_name_in_dict = state._transitions[event] + next_states.add(state_name_in_dict) return tuple(next_states) @@ -559,7 +562,7 @@ class FiniteStateMachine(State): states = [] # Walk through the list of states for st in self._states.itervalues(): - for event, state in st._transitions: + for event, state in st._transitions.items(): if state == state_name: states.append(state) continue |