Skip to content

Commit c5e1845

Browse files
committed
[Section] Move create_section method to base
1 parent 9cff15e commit c5e1845

2 files changed

Lines changed: 16 additions & 15 deletions

File tree

odml/base.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -615,3 +615,19 @@ def get_repository(self):
615615
parent) or None
616616
"""
617617
return self._repository
618+
619+
def create_section(self, name, type="undefined", oid=None):
620+
"""
621+
Creates a new subsection that is a child of this section.
622+
623+
:param name: The name of the section to create.
624+
:param type: The type of the section.
625+
:param oid: object id, UUID string as specified in RFC 4122. If no id
626+
is provided, an id will be generated and assigned.
627+
:return: The new section.
628+
"""
629+
from odml.section import BaseSection
630+
sec = BaseSection(name=name, type=type, oid=oid)
631+
sec.parent = self
632+
633+
return sec

odml/section.py

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -583,21 +583,6 @@ def reorder(self, new_index):
583583

584584
return self._reorder(self.parent.sections, new_index)
585585

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-
599-
return sec
600-
601586
def create_property(self, name, value=None, dtype=None, oid=None):
602587
"""
603588
Create a new property that is a child of this section.

0 commit comments

Comments
 (0)