From 852258667b933a3049087403e71549b8a87e08ab Mon Sep 17 00:00:00 2001 From: vicky Date: Tue, 31 May 2022 20:32:31 +0200 Subject: [PATCH] added export doc and logic for structural elements --- src/bootstraparse/modules/context_mngr.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/bootstraparse/modules/context_mngr.py b/src/bootstraparse/modules/context_mngr.py index 8b9038d..d44af3d 100644 --- a/src/bootstraparse/modules/context_mngr.py +++ b/src/bootstraparse/modules/context_mngr.py @@ -45,6 +45,10 @@ class BaseContainer: return {} def export(self, exm): + """ + :type exm: export.ExportManager + :rtype : str + """ start, end = exm(export.ExportRequest(self.type, self.subtype, self.get_optionals(), self.get_others())) output = start + self.get_content(exm) + end @@ -237,7 +241,9 @@ class HyperLinkContainer(BaseContainer): class SeContainer(BaseContainer): type = "structural_elements" - subtype = "div" # TODO: add logic + def export(self, exm): + self.subtype = self[0].content[0] + return super().export(exm) class HeaderContainer(BaseContainer): @@ -370,7 +376,7 @@ class ContextManager: level="CRITICAL" ) try: - container = _to_container[pile_start.label]() # noqa : F821 + container = _to_container[pile_start.label]() # noqa : F821 # TODO: fix bad error handling on missmatched SE except KeyError: log_exception( KeyError(f"Element {self.pile[start].label} not in dictionary of tokens-containers correspondences."),