def parse_tree(self, node):
"""
Method to parse ElementTree to ConfigurationElement Tree
:param node:
:return:
"""
for key in node.attrib:
self.attributes[key] = node.attrib[key]
self.attributes['xml_tag'] = node.tag
# self.attributes['xml_element'] = node
for child in node:
try:
if not child.attrib['name'] in self.children:
child_config = ConfigurationElement(child.attrib['name'])
child_config.parse_data(child, root=False)
self.children[child.attrib['name']] = child_config
else:
self.children[child.attrib['name']].parse_tree(child)
except KeyError:
print_error("No name attribute for node " + child.tag + ". Tree with root "
"at node " + child.tag + " not parsed.")
configuration_element_class.py 文件源码
python
阅读 16
收藏 0
点赞 0
评论 0
评论列表
文章目录