From 71607d44323e8226a7a6254ef19061cfbe9d9efe Mon Sep 17 00:00:00 2001 From: DeltaDaniel <139119540+DeltaDaniel@users.noreply.github.com> Date: Mon, 6 May 2024 10:22:16 +0200 Subject: [PATCH 1/3] fixed parsing functions for type_checker --- src/migmose/parsing.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/migmose/parsing.py b/src/migmose/parsing.py index 286332d..989e50e 100644 --- a/src/migmose/parsing.py +++ b/src/migmose/parsing.py @@ -13,7 +13,6 @@ from docx.document import Document # type: ignore[import] from docx.oxml import CT_Tbl # type: ignore[import] from docx.table import Table, _Cell # type: ignore[import] -from docx.text.paragraph import Paragraph # type: ignore[import] from loguru import logger from maus.edifact import EdifactFormat @@ -96,7 +95,7 @@ def preliminary_output_as_json(table: list[str], message_format: EdifactFormat, logger.info(f"Created and wrote to {file_path}") -def get_paragraphs_up_to_diagram(parent: Union[Document, _Cell]) -> Generator[Union[Paragraph, Table], None, None]: +def get_paragraphs_up_to_diagram(parent: Union[Document, _Cell]) -> Generator[Table, None, None]: """Goes through paragraphs and tables""" # pylint: disable=protected-access if isinstance(parent, Document): @@ -116,7 +115,7 @@ def parse_raw_nachrichtenstrukturzeile(input_path: Path) -> list[str]: parses raw nachrichtenstrukturzeile from a table. returns list of raw lines """ # pylint: disable=protected-access - doc = docx.Document(input_path) + doc = docx.Document(str(input_path)) docx_objects = get_paragraphs_up_to_diagram(doc) mig_tables = [] nachrichtenstruktur_header = "Status\tMaxWdh\n\tZähler\tNr\tBez\tSta\tBDEW\tSta\tBDEW\tEbene\tInhalt" From 081fcdd7bbe95d54cc57d1d6139632cd79e87ee1 Mon Sep 17 00:00:00 2001 From: Daniel <139119540+DeltaDaniel@users.noreply.github.com> Date: Mon, 6 May 2024 10:42:05 +0200 Subject: [PATCH 2/3] Update src/migmose/parsing.py Co-authored-by: konstantin --- src/migmose/parsing.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/migmose/parsing.py b/src/migmose/parsing.py index 989e50e..d998538 100644 --- a/src/migmose/parsing.py +++ b/src/migmose/parsing.py @@ -115,7 +115,7 @@ def parse_raw_nachrichtenstrukturzeile(input_path: Path) -> list[str]: parses raw nachrichtenstrukturzeile from a table. returns list of raw lines """ # pylint: disable=protected-access - doc = docx.Document(str(input_path)) + doc = docx.Document(str(input_path.absolute())) docx_objects = get_paragraphs_up_to_diagram(doc) mig_tables = [] nachrichtenstruktur_header = "Status\tMaxWdh\n\tZähler\tNr\tBez\tSta\tBDEW\tSta\tBDEW\tEbene\tInhalt" From 5e3a66033fe3fbece387c1b934845997b66ca651 Mon Sep 17 00:00:00 2001 From: DeltaDaniel <139119540+DeltaDaniel@users.noreply.github.com> Date: Mon, 6 May 2024 10:46:24 +0200 Subject: [PATCH 3/3] removed type ignores --- requirements.txt | 2 +- src/migmose/parsing.py | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/requirements.txt b/requirements.txt index e822537..814fadc 100644 --- a/requirements.txt +++ b/requirements.txt @@ -30,7 +30,7 @@ pydantic==2.7.1 # via migmose (pyproject.toml) pydantic-core==2.18.2 # via pydantic -python-docx==1.1.0 +python-docx==1.1.2 # via migmose (pyproject.toml) typing-extensions==4.11.0 # via diff --git a/src/migmose/parsing.py b/src/migmose/parsing.py index d998538..8227c1d 100644 --- a/src/migmose/parsing.py +++ b/src/migmose/parsing.py @@ -9,10 +9,10 @@ from typing import Generator, Union import click -import docx # type: ignore[import] -from docx.document import Document # type: ignore[import] -from docx.oxml import CT_Tbl # type: ignore[import] -from docx.table import Table, _Cell # type: ignore[import] +import docx +from docx.document import Document +from docx.oxml import CT_Tbl +from docx.table import Table, _Cell from loguru import logger from maus.edifact import EdifactFormat