@@ -23,10 +23,6 @@ def __eq__(self, obj):
23
23
Do a deep comparison of this object and its odml properties.
24
24
The 'id' attribute of an object is excluded, since it is
25
25
unique within a document.
26
- SmartList attributes of 'sections' and 'properties' are
27
- handled specially: We want to make sure that the lists'
28
- objects are properly compared without changing the order
29
- of the individual lists.
30
26
"""
31
27
# cannot compare totally different stuff
32
28
if not isinstance (self , obj .__class__ ):
@@ -35,14 +31,6 @@ def __eq__(self, obj):
35
31
for key in self ._format :
36
32
if key == "id" or key == "oid" :
37
33
continue
38
- elif (isinstance (getattr (self , key ), SmartList ) and
39
- sorted (getattr (self , key ), key = lambda x : x .name ) !=
40
- sorted (getattr (obj , key ), key = lambda x : x .name )):
41
- # This special case was introduced only due to the fact
42
- # that RDF files will be loaded with randomized list
43
- # order. With any other file format the list order
44
- # remains unchanged.
45
- return False
46
34
elif getattr (self , key ) != getattr (obj , key ):
47
35
return False
48
36
@@ -143,6 +131,28 @@ def __contains__(self, key):
143
131
if (hasattr (obj , "name" ) and obj .name == key ) or key == obj :
144
132
return True
145
133
134
+ def __eq__ (self , obj ):
135
+ """
136
+ SmartList attributes of 'sections' and 'properties' are
137
+ handled specially: We want to make sure that the lists'
138
+ objects are properly compared without changing the order
139
+ of the individual lists.
140
+ """
141
+ # This special case was introduced only due to the fact
142
+ # that RDF files will be loaded with randomized list
143
+ # order. With any other file format the list order
144
+ # remains unchanged.
145
+ if sorted (self , key = lambda x : x .name ) != sorted (obj , key = lambda x : x .name ):
146
+ return False
147
+
148
+ return True
149
+
150
+ def __ne__ (self , obj ):
151
+ """
152
+ Use the __eq__ function to determine if both objects are equal
153
+ """
154
+ return not self == obj
155
+
146
156
def index (self , obj ):
147
157
"""
148
158
Find obj in list
0 commit comments