def __start_element(self, name, attrs): if name == "tree": return if name == "node": state = NodeState.from_str(attrs["state"]) node_name = attrs["name"] self.__curr_node = self.__curr_node.add_child(node_name, state)
def __print_node(self, level, node): prefix_str = "<node name=\"{}\" state=\"{}\"".format( node.get_name(), NodeState.to_str(node.get_state())) children = node.get_children() if children: self.__print(level, "{}>".format(prefix_str)) for child in node.get_children(): self.__print_node(level+1, child) self.__print(level, "</node>") else: self.__print(level, "{}/>".format(prefix_str))
def __print_node(self, level, node): prefix_str = "<node name=\"{}\" state=\"{}\"".format( node.get_name(), NodeState.to_str(node.get_state())) children = node.get_children() if children: self.__print(level, "{}>".format(prefix_str)) for child in node.get_children(): self.__print_node(level + 1, child) self.__print(level, "</node>") else: self.__print(level, "{}/>".format(prefix_str))