18 """ Generates the reprenstation of the file designed by filename
19 in memory. Build a tree.
21 :param filename: name of the file to parse
22 :returns: the tree representing the file
24 parser = xml.sax.make_parser()
26 parser.setContentHandler(handler)
27 parser.parse(open(filename))
29 root_node = handler.get_root()
30 if root_node.format_version !=
"4":
37 """ ContentHandler to parse the flow diagram fld file
41 xml.sax.handler.ContentHandler.__init__(self)
49 if name ==
'FlowDiagram':
50 new_node = node_flow_diagram.FlowDiagram(
52 elif name ==
'BoxInstance':
53 new_node = node_box_instance.BoxInstance(
55 elif name ==
'ParameterValue':
56 new_node = node_parameter_value.ParameterValue(
58 elif name ==
'PluginContent':
59 new_node = node_plugin_content.PluginContent(
68 parent_node = self.
_nodes.pop()
69 parent_node.attach_attribute(name, new_node)
70 parent_node.add_child(new_node)
71 self.
_nodes.append(parent_node)
73 self.
_nodes.append(new_node)
76 """ this beacon can embed anything, raw string as well as
79 new_node = node_plugin_content.PluginSubNode(name, attrs)
80 parent_node = self.
_nodes.pop()
81 parent_node.add_subnode(new_node)
82 parent_node.add_child(new_node)
83 self.
_nodes.append(parent_node)
85 self.
_nodes.append(new_node)
87 parent_node = self.
_nodes.pop()
88 parent_node.attach_attribute(name,
90 self.
_nodes.append(parent_node)
95 if (name ==
'BoxInstance'
96 or name ==
'FlowDiagram'
97 or name ==
'ParameterValue'):
100 elif name ==
'PluginContent':
105 current_subnode = self.
_nodes.pop()
107 current_subnode.add_content(self.
_buffer)