Skip to content

Commit 2417687

Browse files
committed
[base/section] Always set section type
Section type should always be set and now is set by default to type='n.s.'. This behaviour is introduced to Section.__init__ and is changed in the base method 'create_section' from type='undefined' to type='n.s.' to ensure equal behaviour.
1 parent 5b56d9f commit 2417687

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

odml/base.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -654,14 +654,19 @@ def get_repository(self):
654654
"""
655655
return self._repository
656656

657-
def create_section(self, name, type="undefined", oid=None):
657+
def create_section(self, name, type="n.s.", oid=None):
658658
"""
659659
Creates a new subsection that is a child of this section.
660660
661-
:param name: The name of the section to create.
662-
:param type: The type of the section.
661+
:param name: The name of the section to create. If the name is not
662+
provided, the uuid of the Property is assigned as its name.
663+
Section name is a required attribute.
664+
:param type: String providing a grouping description for similar Sections.
665+
Section type is a required attribute and will be set to the string
666+
'n.s.' by default.
663667
:param oid: object id, UUID string as specified in RFC 4122. If no id
664668
is provided, an id will be generated and assigned.
669+
665670
:return: The new section.
666671
"""
667672
from odml.section import BaseSection

odml/section.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,10 @@ class BaseSection(base.Sectionable):
2727
2828
:param name: string providing the name of the Section. If the name is not
2929
provided, the uuid of the Property is assigned as its name.
30+
Section name is a required attribute.
3031
:param type: String providing a grouping description for similar Sections.
32+
Section type is a required attribute and will be set to the string
33+
'n.s.' by default.
3134
:param parent: the parent object of the new Section. If the object is not
3235
an odml.Section or an odml.Document, a ValueError is raised.
3336
:param definition: String describing the definition of the Section.
@@ -49,7 +52,7 @@ class BaseSection(base.Sectionable):
4952

5053
_format = fmt.Section
5154

52-
def __init__(self, name=None, type=None, parent=None,
55+
def __init__(self, name=None, type="n.s.", parent=None,
5356
definition=None, reference=None,
5457
repository=None, link=None, include=None, oid=None):
5558

0 commit comments

Comments
 (0)