本文整理汇总了Python中pyasm.common.Xml.remove_child方法的典型用法代码示例。如果您正苦于以下问题:Python Xml.remove_child方法的具体用法?Python Xml.remove_child怎么用?Python Xml.remove_child使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyasm.common.Xml
的用法示例。
在下文中一共展示了Xml.remove_child方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: PageNavContainerWdg
# 需要导入模块: from pyasm.common import Xml [as 别名]
# 或者: from pyasm.common.Xml import remove_child [as 别名]
#.........这里部分代码省略.........
<element name="left_nav">
<display class="tactic.ui.panel.SideBarPanelWdg">
<auto_size>True</auto_size>
</display>
</element>
<element name="main_body">
<display class="tactic.ui.startup.MainWdg"/>
<web/>
</element>
</application>
</config>
'''
return config
def set_state(self, panel_name, widget_class, options, values):
'''this is called by side_bar.js mostly'''
# set the class name
display_node = self.config_xml.get_node("config/application/element[@name='%s']/display" % (panel_name) )
self.config_xml.set_attribute(display_node, "class", widget_class)
# remove all the old options
#display_node = self.config_xml.get_node("config/application/element[@name='%s']/display" % panel_name )
for child_node in self.config_xml.get_children(display_node):
self.config_xml.remove_child(display_node, child_node)
# set the options
for name, value in options.items():
node = self.config_xml.get_node("config/application/element[@name='%s']/display/%s" % (panel_name, name) )
if isinstance( value, basestring ):
#print("WARNING: set application: skipping [%s] with value [%s]" % (name, value))
#continue
element = self.config_xml.create_text_element(name, value)
self.config_xml.append_child(display_node, element)
elif isinstance( value, dict): # if it is a dictionary
# TODO: run recursively.. supports 2 level only now
sub_element = self.config_xml.create_element(name)
self.config_xml.append_child(display_node, element)
for name2, value2 in value.items():
if isinstance(value2, dict):
sub_element2 = self.config_xml.create_element(name2)
self.config_xml.append_child(sub_element, sub_element2)
for name3, value3 in value2.items():
element = self.config_xml.create_text_element(name3, value3)
self.config_xml.append_child(sub_element2, element)
else:
element = self.config_xml.create_text_element(name2, value2)
self.config_xml.append_child(sub_element, element)
# web value node
value_node = self.config_xml.get_node("config/application/element[@name='%s']/web" % (panel_name) )
if value_node != None:
for child_node in self.config_xml.get_children(value_node):
self.config_xml.remove_child(value_node, child_node)