Commit 83b211c9 authored by Markus Scheidgen's avatar Markus Scheidgen
Browse files

Fixed dos handling in aim parser. Allow to open subsections of closed parents.

parent c261771d
Pipeline #66502 passed with stages
in 16 minutes and 38 seconds
Subproject commit 4157d084e43ec08ad2f4975a276e89fa51dcd535
Subproject commit 5bfbdf09cbd0e9a2934467bdeca569296952ee06
Subproject commit 0d5765ded1e24c5dd22be98c21d6c9284d06ec51
Subproject commit d41ed9c3e636b1638e904b6459262a610c62dad2
Subproject commit c161aa0f8649f8431cf3ad6e0afc509000460161
Subproject commit b3159851a99a4ff6a5ee13dbe204cc0a72aff81e
......@@ -91,7 +91,7 @@ class AbstractParserBackend(metaclass=ABCMeta):
pass
@abstractmethod
def openSection(self, metaName):
def openSection(self, metaName, parent_index=-1):
""" Opens a new section and returns its new unique gIndex. """
pass
......@@ -433,9 +433,9 @@ class LocalBackend(LegacyParserBackend, metaclass=DelegatingMeta):
super().finishedParsingSession(*args, **kwargs)
self._delegate.finishedParsingSession(*args, **kwargs)
def openSection(self, metaName: str) -> int:
def openSection(self, metaName: str, parent_index: int = -1) -> int:
if self._open_context is None:
return self._delegate.openSection(metaName)
return self._delegate.openSection(metaName, parent_index=parent_index)
else:
assert self._context_section is not None
......
......@@ -185,6 +185,42 @@ class TestLocalBackend(object):
assert len(runs[0]['section_method']) == 2
assert len(runs[1]['section_method']) == 1
def test_open_section_of_specific_parent(self, backend: LocalBackend, no_warn):
run_index = backend.openSection('section_run')
scc_index = backend.openSection('section_single_configuration_calculation')
backend.closeSection('section_single_configuration_calculation', scc_index)
dos_index = backend.openSection('section_dos', parent_index=scc_index)
backend.closeSection('section_dos', dos_index)
backend.closeSection('section_run', run_index)
runs = backend.data['section_run']
assert len(runs) == 1
run = runs[0]
assert len(run['section_single_configuration_calculation']) == 1
assert 'section_dos' in run['section_single_configuration_calculation'][0]
assert len(run['section_single_configuration_calculation'][0]['section_dos']) == 1
def test_open_section_of_specific_parent2(self, backend: LocalBackend, no_warn):
run_index = backend.openSection('section_run')
scc_index = backend.openSection('section_single_configuration_calculation')
backend.closeSection('section_single_configuration_calculation', scc_index)
backend.closeSection(
'section_single_configuration_calculation',
backend.openSection('section_single_configuration_calculation'))
dos_index = backend.openSection('section_dos', parent_index=scc_index)
backend.closeSection('section_dos', dos_index)
backend.closeSection('section_run', run_index)
runs = backend.data['section_run']
assert len(runs) == 1
run = runs[0]
assert len(run['section_single_configuration_calculation']) == 2
assert 'section_dos' in run['section_single_configuration_calculation'][0]
assert len(run['section_single_configuration_calculation'][0]['section_dos']) == 1
assert 'section_dos' not in run['section_single_configuration_calculation'][1]
def test_context(self, backend: LocalBackend, no_warn):
backend.openSection('section_run')
backend.openSection('section_method')
......
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