Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/tutorius/core.py
diff options
context:
space:
mode:
authormike <michael.jmontcalm@gmail.com>2009-11-04 15:20:30 (GMT)
committer mike <michael.jmontcalm@gmail.com>2009-11-04 15:20:30 (GMT)
commit0db118e6320d157748fad0b4d7a31beebcf5b301 (patch)
tree80fc57cfbb02a82cbcf58f0d0e4e2c41cfa190df /tutorius/core.py
parent58a99dcf76cb1a9f85fa2873f9a2e7b46470ae8b (diff)
parentd50c3cd98d6e99c7311286559136dc1a775a326d (diff)
Merge branch 'master' of git://git.sugarlabs.org/tutorius/mainline
Diffstat (limited to 'tutorius/core.py')
-rw-r--r--tutorius/core.py33
1 files changed, 11 insertions, 22 deletions
diff --git a/tutorius/core.py b/tutorius/core.py
index 15a0c87..bfbe07b 100644
--- a/tutorius/core.py
+++ b/tutorius/core.py
@@ -24,9 +24,9 @@ This module contains the core classes for tutorius
import logging
import os
-from sugar.tutorius.TProbe import ProbeManager
-from sugar.tutorius.dbustools import save_args
-from sugar.tutorius import addon
+from .TProbe import ProbeManager
+from .dbustools import save_args
+from . import addon
logger = logging.getLogger("tutorius")
@@ -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,18 +287,8 @@ class State(object):
return False
# Do they have the same event filters?
- for event in self._event_filters:
- 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:
- if event == otherEvent:
- found = True
- break
- if found == False:
- # We could not find the given event filter in the other state.
- return False
+ if self._transitions != otherState._transitions:
+ return False
# If nothing failed up to now, then every actions and every filters can
# be found in the other state
@@ -515,10 +505,9 @@ 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:
+ if st._transitions[event] == state_name:
+ del st._transitions[event]
# Remove the state from the dictionary
del self._states[state_name]
@@ -536,7 +525,7 @@ class FiniteStateMachine(State):
next_states = set()
- for event, state in state._transitions:
+ for event, state in state._transitions.items():
next_states.add(state)
return tuple(next_states)
@@ -559,7 +548,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