Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

patch for type_check for docx #51

Merged
merged 3 commits into from
May 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 6 additions & 7 deletions src/migmose/parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +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]
from docx.text.paragraph import Paragraph # 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

Expand Down Expand Up @@ -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):
Expand All @@ -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.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"
Expand Down