summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ours.xml4
-rw-r--r--xmldiff.py83
2 files changed, 83 insertions, 4 deletions
diff --git a/ours.xml b/ours.xml
index 30da73a..fa8d2b5 100644
--- a/ours.xml
+++ b/ours.xml
@@ -3641,8 +3641,8 @@ and can be activated by a short circuit in the motor cable.
and can be activated by a short circuit in the motor cable.
- Check motor cable.</user_manual_desc>
<rnd_desc>dTjc warning</rnd_desc>
- <aux_codes/>
<cause_list/>
+ <aux_codes/>
</warning>
</event_type>
</event>
@@ -7578,8 +7578,8 @@ Make sure that the drive can decelerate the load within the time defined for ram
• Check that the drive can in fact accomplish the deceleration along the ramp defined.
Make sure that the limit for ramp time monitoring of the FSO module exceeds the actual drive ramp time. The parameter vary depending on the safety function. For the SS1 function it is 200.38 SS1 delay for STO.</user_manual_desc>
<rnd_desc/>
- <aux_codes/>
<cause_list/>
+ <aux_codes/>
</warning>
</event_type>
</event>
diff --git a/xmldiff.py b/xmldiff.py
index 9812515..d0a5b08 100644
--- a/xmldiff.py
+++ b/xmldiff.py
@@ -5,8 +5,8 @@ import xml.etree.ElementTree
ours = xml.etree.ElementTree.parse('ours.xml').getroot().find('events')
theirs = xml.etree.ElementTree.parse('theirs.xml').getroot().find('events')
-ours_set = set([x.find('handle').text for x in ours.findall('event')])
-theirs_set = set([x.find('handle').text for x in theirs.findall('event')])
+ours_set = set([x.find('handle').text for x in ours])
+theirs_set = set([x.find('handle').text for x in theirs])
only_ours = ours_set.difference(theirs_set)
only_theirs = theirs_set.difference(ours_set)
@@ -23,3 +23,82 @@ print ' ' + str(len(theirs)) + ' events in total'
print ' ' + str(len(only_theirs)) + ' only here'
print 'in both: ' + str(len(ev_intersection))
+print
+
+def ensurekey(dictionary, key, init):
+ if key not in dictionary:
+ dictionary[key] = init()
+
+def add(dictionary, key, value, index):
+ ensurekey(dictionary, key, lambda: [None, None])
+ dictionary[key][index] = value
+
+# Collect every event on either side
+byHandle = {}
+for e in ours:
+ add(byHandle, e.find('handle').text, e, 0)
+
+for e in theirs:
+ add(byHandle, e.find('handle').text, e, 1)
+
+# 0: only ours, 1: only theirs, 2: identical
+results = [[], [], []]
+differences = {}
+for key, value in byHandle.items():
+ # event exists only on one side
+ if value[0] is None:
+ results[0].append(key)
+ continue
+ elif value[1] is None:
+ results[1].append(key)
+ continue
+
+ # event exists on both sides, compare each subelement
+ subelements = {}
+ for se in value[0]:
+ add(subelements, se.tag, xml.etree.ElementTree.tostring(se), 0)
+
+ for se in value[1]:
+ add(subelements, se.tag, xml.etree.ElementTree.tostring(se), 1)
+
+ match = True
+ for sekey, sevalue in subelements.items():
+ ensurekey(differences, key, list)
+ if sevalue[0] is None:
+ differences[key].append(sekey + ' only in ours')
+ match = False
+ elif sevalue[1] is None:
+ differences[key].append(sekey + ' only in theirs')
+ match = False
+ elif sevalue[0] != sevalue[1]:
+ differences[key].append(sekey + ' differs')
+ match = False
+
+ if match:
+ results[2].append(key)
+
+# Print results in groups
+print 'Elements only in ours (' + str(len(results[0])) + '):'
+for e in results[0]:
+ print ' ' + e
+
+print
+print 'Elements only in theirs (' + str(len(results[1])) + '):'
+for e in results[1]:
+ print ' ' + e
+
+print
+print 'Elements identical in both (' + str(len(results[2])) + '):'
+for e in results[2]:
+ print ' ' + e
+
+print
+print 'Elements with differences (' + str(len([l for k, l in differences.items() if len(differences[k]) > 0])) + '):'
+for e, d in differences.items():
+ if len(d) < 1:
+ continue
+
+ print ' ' + e
+ for s in d:
+ print(' ' + s)
+ print