"KeyError" occurs in update_node_attr
Adewzen opened this issue · comments
Adewzen commented
"KeyError" occurs in 'update_node_attr' when matching tags with multiple attributes with same value. Code tries to rename attribute to one already used.
XML1:
<?xml version="1.0" encoding="UTF-8"?>
<cop:UiConnectionConfig xmlns:cop="http://www.example.com/Schemas/2009/10/cop">
<cop:General>
<cop:HTTPS enabled="true" Port="8181" ClientAuthentication="false" OverrideSSL="false"/>
<cop:HttpSsoSaml enabled="true" Port="6643" ClientAuthentication="false" OverrideSSL="false">
<cop:SsoSamlConfiguration/>
</cop:HttpSsoSaml>
</cop:General>
<cop:DMZ>
<cop:HttpSsoSaml enabled="false" Port="6643" SecurityTerminationEnabled="false"/>
</cop:DMZ>
</cop:UiConnectionConfig>
XML2:
<?xml version="1.0" encoding="UTF-8"?>
<cop:UiConnectionConfig xmlns:cop="http://www.example.com/Schemas/2009/10/cop">
<cop:General>
<cop:HTTPS enabled="true" Port="8181" ClientAuthentication="false" OverrideSSL="false"/>
<cop:HttpSsoSaml enabled="false" Port="6643" ClientAuthentication="false" OverrideSSL="false"/>
</cop:General>
<cop:DMZ>
<cop:HttpSsoSaml enabled="false" Port="6643" SecurityTerminationEnabled="false"/>
</cop:DMZ>
</cop:UiConnectionConfig>
Traceback:
Traceback (most recent call last):
File "*****/PycharmProjects/cyctools/comapre_sites.py", line 135, in <module>
res = main.diff_files(r'C:\Users\jnezveda\tmp\UiConnectionConfig1.xml', r'C:\Users\jnezveda\tmp\UiConnectionConfig2.xml')
File "*****\PycharmProjects\cyctools\venv\lib\site-packages\xmldiff\main.py", line 51, in diff_files
diff_options=diff_options, formatter=formatter)
File "*****\PycharmProjects\cyctools\venv\lib\site-packages\xmldiff\main.py", line 39, in _diff
formatter=formatter)
File "*****\PycharmProjects\cyctools\venv\lib\site-packages\xmldiff\main.py", line 28, in diff_trees
return list(diffs)
File "*****\PycharmProjects\cyctools\venv\lib\site-packages\xmldiff\diff.py", line 438, in diff
for action in self.update_node_attr(lnode, rnode):
File "*****\PycharmProjects\cyctools\venv\lib\site-packages\xmldiff\diff.py", line 260, in update_node_attr
new_keys.remove(rk)
KeyError: 'SecurityTerminationEnabled'
Sakshi commented
When will this be merged? I am facing similar issue
Lennart Regebro commented
I had trouble deciding of this was the right fix or not, but just remembered that the right fix is one that fixes the issue. :-) If this has side effects I'll deal with that later, this has been in limbo too long.
Sakshi commented
thanks for merging but can you also release this change so can be used from pip.