changeset 1520:8bc2e824f155

Fix various bug of code for parsing finite state machines.
author Thinker K.F. Li <thinker@codemud.net>
date Fri, 19 Aug 2011 16:00:49 +0800
parents 74635b07a83a
children 6d74f835f3b4
files pyink/domview.py
diffstat 1 files changed, 7 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/pyink/domview.py	Tue May 17 12:17:15 2011 +0800
+++ b/pyink/domview.py	Fri Aug 19 16:00:49 2011 +0800
@@ -80,6 +80,7 @@
         pass
 
     def reparse(self):
+        node = self.node
         condition = node.getAttribute('condition')
         target = node.getAttribute('target')
         try:
@@ -258,7 +259,7 @@
     @staticmethod
     def parse_state(node):
         state = State(node)
-        state.parse()
+        state.reparse()
         
         return state
 
@@ -393,7 +394,8 @@
     #
     def parse_states(self):
         comp_node = self._get_comp_node()
-        assert (not comp_node) or comp_node.name() == 'ns0:component'
+        assert (not comp_node) or comp_node.name() in ('ns0:component',
+                                                       'svg:metadata')
         
         states_nodes = [node
                         for node in comp_node.childList()
@@ -409,9 +411,9 @@
             pass
         
         state_nodes = [child
-                       for child in states_node.childList
+                       for child in states_node.childList()
                        if child.name() == 'ns0:state']
-        states = [State.parse_state(node) for state_node in state_nodes]
+        states = [State.parse_state(state_node) for state_node in state_nodes]
         self.fsm_states = dict([(state.name, state) for state in states])
 
         self.fsm_states_node = states_node
@@ -638,6 +640,7 @@
         scenes_node = self._scenes_node
         timeline = Timeline(scenes_node)
         comp.timelines = [timeline]
+        comp.parse_states()
 
         self._components.append(comp)
         self._comp_names.add('main')