1212class BaseObject (object ):
1313 _format = None
1414
15- def format (self ):
16- return self ._format
17-
18- @property
19- def document (self ):
20- """ Returns the Document object in which this object is contained """
21- if self .parent is None :
22- return None
23- return self .parent .document
24-
25- def get_terminology_equivalent (self ):
15+ def __hash__ (self ):
2616 """
27- Returns the equivalent object in an terminology (should there be one
28- defined) or None
17+ Allow all odML objects to be hash-able.
2918 """
30- return None
19+ return id ( self )
3120
3221 def __eq__ (self , obj ):
3322 """
@@ -53,6 +42,23 @@ def __ne__(self, obj):
5342 """
5443 return not self == obj
5544
45+ def format (self ):
46+ return self ._format
47+
48+ @property
49+ def document (self ):
50+ """ Returns the Document object in which this object is contained """
51+ if self .parent is None :
52+ return None
53+ return self .parent .document
54+
55+ def get_terminology_equivalent (self ):
56+ """
57+ Returns the equivalent object in an terminology (should there be one
58+ defined) or None
59+ """
60+ return None
61+
5662 def clean (self ):
5763 """
5864 Stub that doesn't do anything for this class
@@ -70,12 +76,6 @@ def clone(self, children=True):
7076 obj = copy .copy (self )
7177 return obj
7278
73- def __hash__ (self ):
74- """
75- Allow all odML objects to be hash-able.
76- """
77- return id (self )
78-
7979
8080class SmartList (list ):
8181
@@ -166,6 +166,15 @@ def __init__(self):
166166 self ._sections = SmartList (BaseSection )
167167 self ._repository = None
168168
169+ def __getitem__ (self , key ):
170+ return self ._sections [key ]
171+
172+ def __len__ (self ):
173+ return len (self ._sections )
174+
175+ def __iter__ (self ):
176+ return self ._sections .__iter__ ()
177+
169178 @property
170179 def document (self ):
171180 """
@@ -242,15 +251,6 @@ def remove(self, section):
242251 self ._sections .remove (section )
243252 section ._parent = None
244253
245- def __getitem__ (self , key ):
246- return self ._sections [key ]
247-
248- def __len__ (self ):
249- return len (self ._sections )
250-
251- def __iter__ (self ):
252- return self ._sections .__iter__ ()
253-
254254 def itersections (self , recursive = True , yield_self = False ,
255255 filter_func = lambda x : True , max_depth = None ):
256256 """
0 commit comments