17 """ Generates the representation of the file designed by filename
18 in memory. Build a tree.
20 :param filename: name of the file to parse
21 :returns: the tree representing the file
23 parser = xml.sax.make_parser()
25 parser.setContentHandler(handler)
26 parser.parse(open(filename))
28 root_node = handler.get_root()
29 if root_node.format_version !=
"4":
36 """ ContentHandler to parse the animation file
40 xml.sax.handler.ContentHandler.__init__(self)
46 if name ==
'Animation':
47 new_node = node_animation.Animation(
49 elif name ==
'ActuatorList':
50 new_node = node_actuator_list.ActuatorList(
52 elif name ==
'ActuatorCurve':
53 new_node = node_actuator_curve.ActuatorCurve(
56 new_node = node_actuator_key.ActuatorKey(
64 parent_node = self.
_nodes.pop()
65 parent_node.attach_attribute(name, new_node)
66 parent_node.add_child(new_node)
67 self.
_nodes.append(parent_node)
69 self.
_nodes.append(new_node)
71 raise Exception(
"The node %s is unknown" % name)