Skip to content

Commit 8310035

Browse files
committed
[Section] Add create_section method
1 parent 4ce2e1b commit 8310035

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

odml/section.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -582,3 +582,17 @@ def reorder(self, new_index):
582582
"Section has no parent, cannot reorder in parent list.")
583583

584584
return self._reorder(self.parent.sections, new_index)
585+
586+
def create_section(self, name, type="undefined", oid=None):
587+
"""
588+
Creates a new subsection that is a child of this section.
589+
590+
:param name: The name of the section to create.
591+
:param type: The type of the section.
592+
:param oid: object id, UUID string as specified in RFC 4122. If no id
593+
is provided, an id will be generated and assigned.
594+
:return: The new section.
595+
"""
596+
sec = BaseSection(name=name, type=type, oid=oid)
597+
sec.parent = self
598+
return sec

0 commit comments

Comments
 (0)