Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/tutorius
diff options
context:
space:
mode:
Diffstat (limited to 'tutorius')
-rw-r--r--tutorius/actions.py6
-rw-r--r--tutorius/core.py32
-rw-r--r--tutorius/properties.py12
-rw-r--r--tutorius/store.py2
4 files changed, 18 insertions, 34 deletions
diff --git a/tutorius/actions.py b/tutorius/actions.py
index 89e71ae..cd34976 100644
--- a/tutorius/actions.py
+++ b/tutorius/actions.py
@@ -18,14 +18,10 @@ This module defines Actions that can be done and undone on a state
"""
from gettext import gettext as _
-from sugar.tutorius import gtkutils, addon
-from dialog import TutoriusDialog
-import overlayer
-from sugar.tutorius.editor import WidgetIdentifier
+from sugar.tutorius import addon
from sugar.tutorius.services import ObjectStore
from sugar.tutorius.properties import *
from sugar.graphics import icon
-import gtk.gdk
class DragWrapper(object):
"""Wrapper to allow gtk widgets to be dragged around"""
diff --git a/tutorius/core.py b/tutorius/core.py
index d034c30..4376315 100644
--- a/tutorius/core.py
+++ b/tutorius/core.py
@@ -89,18 +89,6 @@ class Tutorial (object):
self.state_machine.set_state(name)
-
-## # Currently unused -- equivalent function is in each state
-## def _eventfilter_state_done(self, eventfilter):
-## """
-## Callback handler for eventfilter to notify
-## when we must go to the next state.
-## """
-## #XXX Tests should be run here normally
-##
-## #Swith to the next state pointed by the eventfilter
-## self.set_state(eventfilter.get_next_state())
-
def _prepare_activity(self):
"""
Prepare the activity for the tutorial by loading the saved state and
@@ -202,15 +190,13 @@ class State(object):
# These functions are used to simplify the creation of states
def add_action(self, new_action):
"""
- Adds an action to the state (only if it wasn't added before)
+ Adds an action to the state
@param new_action The new action to execute when in this state
@return True if added, False otherwise
"""
- if new_action not in self._actions:
- self._actions.append(new_action)
- return True
- return False
+ self._actions.append(new_action)
+ return True
# remove_action - We did not define names for the action, hence they're
# pretty hard to remove on a precise basis
@@ -256,7 +242,7 @@ class State(object):
"""
self._event_filters = []
- def is_identical(self, otherState):
+ def __eq__(self, otherState):
"""
Compares two states and tells whether they contain the same states with the
same actions and event filters.
@@ -284,7 +270,7 @@ class State(object):
found = False
# For each action in the other state, try to match it with this one.
for otherAct in otherState._actions:
- if act.is_identical(otherAct):
+ if act == otherAct:
found = True
break
if found == False:
@@ -299,7 +285,7 @@ class State(object):
# the current filter. We just need to find one with the right
# properties and values.
for otherEvent in otherState._event_filters:
- if event.is_identical(otherEvent):
+ if event == otherEvent:
found = True
break
if found == False:
@@ -578,7 +564,7 @@ class FiniteStateMachine(State):
out_string += st.name + ", "
return out_string
- def is_identical(self, otherFSM):
+ def __eq__(self, otherFSM):
"""
Compares the elements of two FSM to ensure and returns true if they have the
same set of states, containing the same actions and the same event filters.
@@ -603,7 +589,7 @@ class FiniteStateMachine(State):
# For every action in the other FSM, try to match it with the
# current one.
for otherAct in otherFSM._actions:
- if act.is_identical(otherAct):
+ if act == otherAct:
found = True
break
if found == False:
@@ -626,7 +612,7 @@ class FiniteStateMachine(State):
return False
# If two states with the same name exist, then we want to make sure
# they are also identical
- if not state.is_identical(other_state):
+ if not state == other_state:
return False
# If we made it here, then all the states in this FSM could be matched to an
diff --git a/tutorius/properties.py b/tutorius/properties.py
index 2afe119..4c34511 100644
--- a/tutorius/properties.py
+++ b/tutorius/properties.py
@@ -95,7 +95,7 @@ class TPropContainer(object):
"""
return object.__getattribute__(self, "_props").keys()
- def is_identical(self, otherContainer):
+ def __eq__(self, otherContainer):
"""
Compare this property container to the other one and returns True only if
the every property of the first one can be found in the other container, with
@@ -108,6 +108,10 @@ class TPropContainer(object):
# Make sure both have the same number of properties
if len(self._props) != len(otherContainer._props):
return False
+
+ if not(type(self) == type(otherContainer)):
+ return False
+
# For every property in this container
for prop in self._props.keys():
found = False
@@ -131,12 +135,12 @@ class TPropContainer(object):
# If this is just an embedded / decorated container, then we want to
# make sure the sub component are identical.
elif this_type == "addon":
- if not self._props[prop].is_identical(otherContainer._props[prop]):
+ if not (self._props[prop] == otherContainer._props[prop]):
return False
found = True
break
else:
- if self._props[prop]== otherContainer._props[prop]:
+ if self._props[prop] == otherContainer._props[prop]:
found = True
break
# If we arrive here, then we couldn't find any property in the second
@@ -161,7 +165,7 @@ class TPropContainer(object):
# Attempt to match it with every property in the other list
for other_container in otherList:
# If the containers are identical,
- if container.is_identical(other_container):
+ if container == other_container:
# We found a matching container. We don't need to search in the
# second list anymore, so we break
found = True
diff --git a/tutorius/store.py b/tutorius/store.py
index d66bb81..480c81b 100644
--- a/tutorius/store.py
+++ b/tutorius/store.py
@@ -91,8 +91,6 @@ class StoreProxy(object):
state. After a successful logon, the operation requiring a login will
be successful.
- @param username
- @param password
@return True if the login was successful, False otherwise
"""
raise NotImplementedError("login() not implemented yet")