80 """ compare 2 dicts of components
81 dicts are of the form:
82 { 'comp_type' : <name of component>,
83 'cxx_type' : <C++ type of the component>,
84 'props' : { 'property-name' : 'property-value', }
88 ref_keys =
set(ref.keys())
89 chk_keys =
set(chk.keys())
91 common_keys = ref_keys & chk_keys
92 ref_only_keys = ref_keys - chk_keys
93 chk_only_keys = chk_keys - ref_keys
95 print (
"::: components in both files: [%5s]" % (len(common_keys),))
96 print (
"::: components in ref only: [%5s]" % (len(ref_only_keys),))
97 if len(ref_only_keys)>0:
100 print (
"::: components in chk only: [%5s]" % (len(chk_only_keys),))
101 if len(chk_only_keys)>0:
106 for comp_name
in common_keys:
107 comp_ref = ref[comp_name]
108 comp_chk = chk[comp_name]
112 if ref_props != chk_props:
113 diff.append((comp_name, ref_props, chk_props,
115 chk=comp_chk[
'props'])))
118 print (
"::: components with different properties: [%5s]" % (len(diff),))
119 for name, ref_props, chk_props, diff_props
in diff:
120 print (
"::: - component: [%s]" % (name,))
121 for prop_name, prop_value
in diff_props.iteritems():
122 ref_value = prop_value[0]
123 chk_value = prop_value[1]
124 if isinstance(ref_value, list):
125 ref_value =
sorted(ref_value)
126 if isinstance(chk_value, list):
127 chk_value =
sorted(chk_value)
129 if isinstance(ref_value, list)
and isinstance(chk_value, list):
130 dref_value =
set(ref_value) -
set(chk_value)
131 dchk_value =
set(chk_value) -
set(ref_value)
134 print (
"-%s: %r" %(prop_name, ref_value,))
135 print (
"+%s: %r" %(prop_name, chk_value,))
138 if (len(ref_only_keys) > 0
or
139 len(chk_only_keys) > 0
or