Commit b3159851 authored by Markus Scheidgen's avatar Markus Scheidgen

Added parent_index for openSection in local backend.

parent c161aa0f
......@@ -86,10 +86,10 @@ class LocalBackend(object):
(ik.name, superSectionNames))
self.dataManagers[ik.name] = DataManager(ik, self.sectionManagers[superSectionNames[0]])
def openSection(self, metaName):
def openSection(self, metaName, parent_index: int = -1):
"""opens a new section and returns its new unique gIndex"""
manager = self.sectionManagers[metaName]
newIndex = manager.openSection(self)
newIndex = manager.openSection(self, parent_index=parent_index)
self.__openSections.add((metaName, newIndex))
return newIndex
......@@ -613,12 +613,12 @@ class SectionManager(object):
self.debug = debug
self.openSections = []
def openSection(self, backend):
def openSection(self, backend, parent_index: int = -1):
newGIndex = self.lastSectionGIndex + 1
self.openSectionWithGIndex(backend, newGIndex)
self.openSectionWithGIndex(backend, newGIndex, parent_index=parent_index)
return newGIndex
def openSectionWithGIndex(self, backend, gIndex):
def openSectionWithGIndex(self, backend, gIndex, parent_index: int = -1):
self.lastSectionGIndex = gIndex
references = []
parents = []
......@@ -626,7 +626,8 @@ class SectionManager(object):
for parentName in self.parentSectionNames:
pSect = backend.sectionManagers.get(parentName)
try:
parentSection = pSect.openSections[pSect.lastSectionGIndex]
parent_section_index = pSect.lastSectionGIndex if parent_index == -1 else parent_index
parentSection = pSect.openSections[parent_section_index]
except IndexError:
pass
except KeyError:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment