@@ -54,7 +54,6 @@ class BaseSection(base.Sectionable):
5454 """
5555
5656 type = None
57- reference = None # the *import* property
5857 _link = None
5958 _include = None
6059 _merged = None
@@ -328,7 +327,8 @@ def parent(self):
328327 def parent (self , new_parent ):
329328 if new_parent is None and self ._parent is None :
330329 return
331- elif new_parent is None and self ._parent is not None :
330+
331+ if new_parent is None and self ._parent is not None :
332332 self ._parent .remove (self )
333333 self ._parent = None
334334 elif self ._validate_parent (new_parent ):
@@ -341,7 +341,8 @@ def parent(self, new_parent):
341341 "odml.Section.parent: passed value is not of consistent type!"
342342 "\n odml.Document or odml.Section expected" )
343343
344- def _validate_parent (self , new_parent ):
344+ @staticmethod
345+ def _validate_parent (new_parent ):
345346 """
346347 Checks whether a provided object is a valid odml.Section or odml.Document..
347348
@@ -521,16 +522,16 @@ def extend(self, obj_list):
521522 # Make sure only Sections and Properties with unique names will be added.
522523 for obj in obj_list :
523524 if not isinstance (obj , BaseSection ) and not isinstance (obj , BaseProperty ):
524- raise ValueError ( "odml.Section.extend: "
525- "Can only extend sections and properties." )
525+ msg = "odml.Section.extend: Can only extend sections and properties. "
526+ raise ValueError ( msg )
526527
527- elif isinstance (obj , BaseSection ) and obj .name in self .sections :
528- raise KeyError ( "odml.Section.extend: "
529- "Section with name '%s' already exists." % obj . name )
528+ if isinstance (obj , BaseSection ) and obj .name in self .sections :
529+ msg = "odml.Section.extend: Section with name '%s' already exists." % obj . name
530+ raise KeyError ( msg )
530531
531- elif isinstance (obj , BaseProperty ) and obj .name in self .properties :
532- raise KeyError ( "odml.Section.extend: "
533- "Property with name '%s' already exists." % obj . name )
532+ if isinstance (obj , BaseProperty ) and obj .name in self .properties :
533+ msg = "odml.Section.extend: Property with name '%s' already exists." % obj . name
534+ raise KeyError ( msg )
534535
535536 for obj in obj_list :
536537 self .append (obj )
@@ -613,13 +614,14 @@ def contains(self, obj):
613614 if isinstance (obj , BaseSection ):
614615 return super (BaseSection , self ).contains (obj )
615616
616- elif isinstance (obj , BaseProperty ):
617+ if isinstance (obj , BaseProperty ):
617618 for i in self ._props :
618619 if obj .name == i .name :
619620 return i
620- else :
621- raise ValueError ("odml.Section.contains:"
622- "Section or Property object expected." )
621+
622+ return None
623+
624+ raise ValueError ("odml.Section.contains: Section or Property object expected." )
623625
624626 def merge_check (self , source_section , strict = True ):
625627 """
0 commit comments