Open dmuhamedagic opened 2 years ago
Perhaps just to do: try: .... except KeyError: pass
Well, we definitely need a better error message there, but that is at least a warning, because that means your patching doesn't match your source file.
(or if it does it's a bug)
With delete-attribute such as this one: [delete-attribute, /domain/devices/disk[2]/driver[1], cache] xmlpatch throws the KeyError exception if the referenced attribute doesn't exist in the element: Traceback (most recent call last): File "/usr/bin/xmlpatch", line 11, in
load_entry_point('xmldiff==2.4', 'console_scripts', 'xmlpatch')()
File "/usr/lib/python3/dist-packages/xmldiff/main.py", line 171, in patch_command
result = patch_file(args.patchfile, args.xmlfile)
File "/usr/lib/python3/dist-packages/xmldiff/main.py", line 148, in patch_file
tree = patch_tree(actions, tree)
File "/usr/lib/python3/dist-packages/xmldiff/main.py", line 124, in patch_tree
return patcher.patch(actions, tree)
File "/usr/lib/python3/dist-packages/xmldiff/patch.py", line 15, in patch
self.handle_action(action, result)
File "/usr/lib/python3/dist-packages/xmldiff/patch.py", line 22, in handle_action
method(action, tree)
File "/usr/lib/python3/dist-packages/xmldiff/patch.py", line 55, in _handle_DeleteAttrib
del tree.xpath(action.node)[0].attrib[action.name]
File "src/lxml/etree.pyx", line 2421, in lxml.etree._Attrib.delitem
File "src/lxml/apihelpers.pxi", line 582, in lxml.etree._delAttribute
KeyError: 'cache'