diff options
author | Cole Robinson <crobinso@redhat.com> | 2014-01-25 14:41:55 -0500 |
---|---|---|
committer | Cole Robinson <crobinso@redhat.com> | 2014-01-25 17:20:29 -0500 |
commit | 5c762a98519d5935bcf87f7258002da433352a20 (patch) | |
tree | c7265de0f05f28dbf6c63ea70334f3c55ab45da9 | |
parent | 329ebe074649b648adf93f37746e721c5737214e (diff) | |
download | virt-manager-5c762a98519d5935bcf87f7258002da433352a20.tar.gz |
simplify remove_ node args
-rw-r--r-- | virtinst/xmlbuilder.py | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/virtinst/xmlbuilder.py b/virtinst/xmlbuilder.py index fa0b931d..9562d540 100644 --- a/virtinst/xmlbuilder.py +++ b/virtinst/xmlbuilder.py @@ -200,6 +200,7 @@ def _remove_xpath_node(ctx, xpath, dofree=True, unlinkroot=True): Remove an XML node tree if it has no content """ curxpath = xpath + root_node = ctx.contextNode() while curxpath: is_orig = (curxpath == xpath) @@ -226,7 +227,7 @@ def _remove_xpath_node(ctx, xpath, dofree=True, unlinkroot=True): white.unlinkNode() white.freeNode() - if not unlinkroot and node == ctx: + if not unlinkroot and node == root_node: # Don't unlink the root node. This is usually a programming error, # but the error usually cascades to a different spot and is hard # to pin down. With this we usually get invalid XML which is @@ -625,6 +626,10 @@ class XMLProperty(property): """ if root_node is None: root_node = xmlbuilder._xmlstate.xml_node + ctx = xmlbuilder._xmlstate.xml_ctx + else: + ctx = _make_xml_context(root_node) + xpath = self._make_xpath(xmlbuilder) node = _get_xpath_node(xmlbuilder._xmlstate.xml_ctx, xpath) clearlist = self._build_clear_list(xmlbuilder, node) @@ -635,11 +640,9 @@ class XMLProperty(property): node_map += [(node, setval, xpath)] for node, val, use_xpath in node_map: - if node: - use_xpath = node.nodePath() - if val is None or val is False: - _remove_xpath_node(root_node, use_xpath, unlinkroot=False) + print "remove", use_xpath + _remove_xpath_node(ctx, use_xpath, unlinkroot=False) continue if not node: |