diff options
author | erick <erick@sugar-dev-erick.(none)> | 2009-10-25 01:17:32 (GMT) |
---|---|---|
committer | erick <erick@sugar-dev-erick.(none)> | 2009-10-25 01:17:32 (GMT) |
commit | 8237d2e33cadc8199349e1b19c9d9d3bdda77de7 (patch) | |
tree | 30bab1bad59997a5b264e19e79eab79e7dca3270 /tutorius | |
parent | 556dc861744de1affc3311c31b744654e966cef9 (diff) | |
parent | 704e35494433a11ecdcf675fff7cfccaa8bbd2ec (diff) |
Merge branch 'master' of git://git.sugarlabs.org/tutorius/mainline into tutorialADT
Diffstat (limited to 'tutorius')
-rw-r--r-- | tutorius/core.py | 20 | ||||
-rw-r--r-- | tutorius/properties.py | 2 |
2 files changed, 6 insertions, 16 deletions
diff --git a/tutorius/core.py b/tutorius/core.py index 15a0c87..b24b80b 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,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 @@ -536,7 +526,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 +549,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 diff --git a/tutorius/properties.py b/tutorius/properties.py index 78e3c2b..cbb2ae3 100644 --- a/tutorius/properties.py +++ b/tutorius/properties.py @@ -104,7 +104,7 @@ class TPropContainer(object): return hash(tuple(map(tuple,sorted(self._props.items(), cmp=lambda x, y: cmp(x[0], y[0]))))) def __eq__(self, e2): - return self._props == e2._props + return isinstance(e2, type(self)) and self._props == e2._props # Adding methods for pickling and unpickling an object with # properties |