Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormike <michael.jmontcalm@gmail.com>2009-10-12 21:16:08 (GMT)
committer mike <michael.jmontcalm@gmail.com>2009-10-12 21:16:08 (GMT)
commit8ffa6e6e714a560d17e13f909625f143338e785b (patch)
tree65e4cfe7f5be82566f82dcd1ef78a72336b707c6
parent762835ca504b2c1a4425e115742fc41dee1f3a1b (diff)
LP 439980 : Renaming nodes for XMLSerializer, Moving properties tests to /tmp, Removing commented code in filters
-rw-r--r--tests/propertiestests.py10
-rw-r--r--tutorius/bundler.py22
-rw-r--r--tutorius/filters.py108
-rw-r--r--tutorius/store.py2
4 files changed, 20 insertions, 122 deletions
diff --git a/tests/propertiestests.py b/tests/propertiestests.py
index 389671d..03e7814 100644
--- a/tests/propertiestests.py
+++ b/tests/propertiestests.py
@@ -501,12 +501,18 @@ class TEnumPropertyTest(unittest.TestCase):
try_wrong_values(self.obj)
class TFilePropertyTest(unittest.TestCase):
+ root_folder = "/tmp/tutorius"
+
def setUp(self):
+ try:
+ os.mkdir(self.root_folder)
+ except:
+ pass
# Create some sample, unique files for the tests
- self.temp_filename1 = "sample_file1_" + str(uuid.uuid1()) + ".txt"
+ self.temp_filename1 = os.path.join(self.root_folder, "sample_file1_" + str(uuid.uuid1()) + ".txt")
self.temp_file1 = file(self.temp_filename1, "w")
self.temp_file1.close()
- self.temp_filename2 = "sample_file2_" + str(uuid.uuid1()) + ".txt"
+ self.temp_filename2 = os.path.join(self.root_folder, "sample_file2_" + str(uuid.uuid1()) + ".txt")
self.temp_file2 = file(self.temp_filename2, "w")
self.temp_file2.close()
diff --git a/tutorius/bundler.py b/tutorius/bundler.py
index 9cbd917..56bbf3e 100644
--- a/tutorius/bundler.py
+++ b/tutorius/bundler.py
@@ -48,8 +48,8 @@ INI_XML_FSM_PROPERTY = "FSM_FILENAME"
INI_FILENAME = "meta.ini"
TUTORIAL_FILENAME = "tutorial.xml"
NODE_COMPONENT = "Component"
-NODE_SUBCOMPONENT = "SubComponent"
-NODE_SUBCOMPONENTLIST = "SubComponentList"
+NODE_SUBCOMPONENT = "property"
+NODE_SUBCOMPONENTLIST = "listproperty"
class TutorialStore(object):
@@ -159,9 +159,9 @@ class XMLSerializer(Serializer):
e.g.
<Component Class="OnceWrapper">
- <SubComponent property="addon">
+ <property name="addon">
<Component Class="BubbleMessage" message="'Hi!'" position="[12,32]"/>
- </SubComponent>
+ </property>
</Component>
When reloading this node, we should look up the property name for the parent
@@ -177,7 +177,7 @@ class XMLSerializer(Serializer):
that represents another component.
"""
subCompNode = doc.createElement(NODE_SUBCOMPONENT)
- subCompNode.setAttribute("property", parent_attr_name)
+ subCompNode.setAttribute("name", parent_attr_name)
subNode = self._create_component_node(comp, doc)
@@ -193,10 +193,10 @@ class XMLSerializer(Serializer):
e.g.
<Component Class="ChainAction">
- <SubComponentList property="actions">
+ <listproperty name="actions">
<Component Class="BubbleMessage" message="'Hi!'" position="[15,35]"/>
<Component Class="DialogMessage" message="'Multi-action!'" position="[45,10]"/>
- </SubComponentList>
+ </listproperty>
</Component>
When reloading this node, we should look up the property name for the parent
@@ -209,7 +209,7 @@ class XMLSerializer(Serializer):
@returns A NODE_SUBCOMPONENTLIST node with the property attribute
"""
subCompListNode = doc.createElement(NODE_SUBCOMPONENTLIST)
- subCompListNode.setAttribute("property", parent_attr_name)
+ subCompListNode.setAttribute("name", parent_attr_name)
for comp in comp_list:
compNode = self._create_component_node(comp, doc)
@@ -402,7 +402,7 @@ class XMLSerializer(Serializer):
Loads all the subcomponent node below the given node and inserts them with
the right property name inside the properties dictionnary.
- @param node The parent node that contains one or many SubComponent nodes.
+ @param node The parent node that contains one or many property nodes.
@param properties A dictionnary where the subcomponent property names
and the instantiated components will be stored
@returns Nothing. The properties dict will contain the property->comp mapping.
@@ -410,7 +410,7 @@ class XMLSerializer(Serializer):
subCompList = self._get_direct_descendants_by_tag_name(node, NODE_SUBCOMPONENT)
for subComp in subCompList:
- property_name = subComp.getAttribute("property")
+ property_name = subComp.getAttribute("name")
internal_comp_node = self._get_direct_descendants_by_tag_name(subComp, NODE_COMPONENT)[0]
internal_comp = self._load_xml_component(internal_comp_node)
properties[str(property_name)] = internal_comp
@@ -426,7 +426,7 @@ class XMLSerializer(Serializer):
"""
listOf_subCompListNode = self._get_direct_descendants_by_tag_name(node, NODE_SUBCOMPONENTLIST)
for subCompListNode in listOf_subCompListNode:
- property_name = subCompListNode.getAttribute("property")
+ property_name = subCompListNode.getAttribute("name")
subCompList = []
for subCompNode in self._get_direct_descendants_by_tag_name(subCompListNode, NODE_COMPONENT):
subComp = self._load_xml_component(subCompNode)
diff --git a/tutorius/filters.py b/tutorius/filters.py
index fc58562..0055763 100644
--- a/tutorius/filters.py
+++ b/tutorius/filters.py
@@ -94,111 +94,3 @@ class EventFilter(properties.TPropContainer):
if self._callback:
self._callback(self)
-##class TimerEvent(EventFilter):
-## """
-## TimerEvent is a special EventFilter that uses gobject
-## timeouts to trigger a state change after a specified amount
-## of time. It must be used inside a gobject main loop to work.
-## """
-## def __init__(self,next_state,timeout_s):
-## """Constructor.
-##
-## @param next_state default EventFilter param, passed on to EventFilter
-## @param timeout_s timeout in seconds
-## """
-## super(TimerEvent,self).__init__(next_state)
-## self._timeout = timeout_s
-## self._handler_id = None
-##
-## def install_handlers(self, callback, **kwargs):
-## """install_handlers creates the timer and starts it"""
-## super(TimerEvent,self).install_handlers(callback, **kwargs)
-## #Create the timer
-## self._handler_id = gobject.timeout_add_seconds(self._timeout, self._timeout_cb)
-##
-## def remove_handlers(self):
-## """remove handler removes the timer"""
-## super(TimerEvent,self).remove_handlers()
-## if self._handler_id:
-## try:
-## #XXX What happens if this was already triggered?
-## #remove the timer
-## gobject.source_remove(self._handler_id)
-## except:
-## pass
-##
-## def _timeout_cb(self):
-## """
-## _timeout_cb triggers the eventfilter callback.
-##
-## It is necessary because gobject timers only stop if the callback they
-## trigger returns False
-## """
-## self.do_callback()
-## return False #Stops timeout
-##
-##class GtkWidgetTypeFilter(EventFilter):
-## """
-## Event Filter that listens for keystrokes on a widget
-## """
-## def __init__(self, next_state, object_id, text=None, strokes=None):
-## """Constructor
-## @param next_state default EventFilter param, passed on to EventFilter
-## @param object_id object tree-ish identifier
-## @param text resulting text expected
-## @param strokes list of strokes expected
-##
-## At least one of text or strokes must be supplied
-## """
-## super(GtkWidgetTypeFilter, self).__init__(next_state)
-## self._object_id = object_id
-## self._text = text
-## self._captext = ""
-## self._strokes = strokes
-## self._capstrokes = []
-## self._widget = None
-## self._handler_id = None
-##
-## def install_handlers(self, callback, **kwargs):
-## """install handlers
-## @param callback default EventFilter callback arg
-## """
-## super(GtkWidgetTypeFilter, self).install_handlers(callback, **kwargs)
-## logger.debug("~~~GtkWidgetTypeFilter install")
-## activity = ObjectStore().activity
-## if activity is None:
-## logger.error("No activity")
-## raise RuntimeWarning("no activity in the objectstore")
-##
-## self._widget = find_widget(activity, self._object_id)
-## if self._widget:
-## self._handler_id= self._widget.connect("key-press-event",self.__keypress_cb)
-## logger.debug("~~~Connected handler %d on %s" % (self._handler_id,self._object_id) )
-##
-## def remove_handlers(self):
-## """remove handlers"""
-## super(GtkWidgetTypeFilter, self).remove_handlers()
-## #if an event was connected, disconnect it
-## if self._handler_id:
-## self._widget.handler_disconnect(self._handler_id)
-## self._handler_id=None
-##
-## def __keypress_cb(self, widget, event, *args):
-## """keypress callback"""
-## logger.debug("~~~keypressed!")
-## key = event.keyval
-## keystr = event.string
-## logger.debug("~~~Got key: " + str(key) + ":"+ keystr)
-## self._capstrokes += [key]
-## #TODO Treat other stuff, such as arrows
-## if key == gtk.keysyms.BackSpace:
-## self._captext = self._captext[:-1]
-## else:
-## self._captext = self._captext + keystr
-##
-## logger.debug("~~~Current state: " + str(self._capstrokes) + ":" + str(self._captext))
-## if not self._strokes is None and self._strokes in self._capstrokes:
-## self.do_callback()
-## if not self._text is None and self._text in self._captext:
-## self.do_callback()
-
diff --git a/tutorius/store.py b/tutorius/store.py
index dfd6fca..d66bb81 100644
--- a/tutorius/store.py
+++ b/tutorius/store.py
@@ -30,7 +30,7 @@ class StoreProxy(object):
@return The list of category names stored on the server.
"""
- raise NotImplementerError("get_categories() not implemented")
+ raise NotImplementedError("get_categories() not implemented")
def get_tutorials(self, keywords=None, category=None, startIndex=0, numResults=10, sortBy='name'):
"""