99from .tools .doc_inherit import allow_inherit_docstring
1010
1111
12- class _baseobj (object ):
13- pass
14-
15-
16- class baseobject (_baseobj ):
12+ class BaseObject (object ):
1713 _format = None
1814
19- def format (self ):
20- return self ._format
21-
22- @property
23- def document (self ):
24- """ Returns the Document object in which this object is contained """
25- if self .parent is None :
26- return None
27- return self .parent .document
28-
29- def get_terminology_equivalent (self ):
15+ def __hash__ (self ):
3016 """
31- Returns the equivalent object in an terminology (should there be one
32- defined) or None
17+ Allow all odML objects to be hash-able.
3318 """
34- return None
19+ return id ( self )
3520
3621 def __eq__ (self , obj ):
3722 """
@@ -40,9 +25,6 @@ def __eq__(self, obj):
4025 unique within a document.
4126 """
4227 # cannot compare totally different stuff
43- if not isinstance (obj , _baseobj ):
44- return False
45-
4628 if not isinstance (self , obj .__class__ ):
4729 return False
4830
@@ -60,6 +42,23 @@ def __ne__(self, obj):
6042 """
6143 return not self == obj
6244
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+
6362 def clean (self ):
6463 """
6564 Stub that doesn't do anything for this class
@@ -77,12 +76,6 @@ def clone(self, children=True):
7776 obj = copy .copy (self )
7877 return obj
7978
80- def __hash__ (self ):
81- """
82- Allow all odML objects to be hash-able.
83- """
84- return id (self )
85-
8679
8780class SmartList (list ):
8881
@@ -167,12 +160,21 @@ def append(self, *obj_tuple):
167160
168161
169162@allow_inherit_docstring
170- class sectionable ( baseobject ):
163+ class Sectionable ( BaseObject ):
171164 def __init__ (self ):
172165 from odml .section import BaseSection
173166 self ._sections = SmartList (BaseSection )
174167 self ._repository = None
175168
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+
176178 @property
177179 def document (self ):
178180 """
@@ -249,15 +251,6 @@ def remove(self, section):
249251 self ._sections .remove (section )
250252 section ._parent = None
251253
252- def __getitem__ (self , key ):
253- return self ._sections [key ]
254-
255- def __len__ (self ):
256- return len (self ._sections )
257-
258- def __iter__ (self ):
259- return self ._sections .__iter__ ()
260-
261254 def itersections (self , recursive = True , yield_self = False ,
262255 filter_func = lambda x : True , max_depth = None ):
263256 """
@@ -565,7 +558,7 @@ def clone(self, children=True):
565558 to another document
566559 """
567560 from odml .section import BaseSection
568- obj = super (sectionable , self ).clone (children )
561+ obj = super (Sectionable , self ).clone (children )
569562 obj ._parent = None
570563 obj ._sections = SmartList (BaseSection )
571564 if children :
0 commit comments