diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 5c8d02ae..06b612d5 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -25,8 +25,8 @@ repos: - id: end-of-file-fixer - id: fix-byte-order-marker - id: trailing-whitespace - - repo: https://github.com/psf/black - rev: 23.3.0 + - repo: https://github.com/psf/black-pre-commit-mirror + rev: 23.9.1 hooks: - id: black - repo: https://github.com/PyCQA/isort @@ -34,7 +34,7 @@ repos: hooks: - id: isort - repo: https://github.com/PyCQA/docformatter - rev: v1.7.2 + rev: v1.7.5 hooks: - id: docformatter additional_dependencies: @@ -47,7 +47,7 @@ repos: additional_dependencies: - pydocstyle[toml] - repo: https://github.com/pre-commit/mirrors-mypy - rev: v1.3.0 + rev: v1.5.1 hooks: - id: mypy additional_dependencies: @@ -97,10 +97,10 @@ repos: - --comment-style - "..| |" - repo: https://github.com/fsfe/reuse-tool - rev: v1.1.2 + rev: v2.1.0 hooks: - id: reuse - repo: https://github.com/qoomon/git-conventional-commits - rev: v2.6.4 + rev: v2.6.5 hooks: - id: conventional-commits diff --git a/capella2polarion/elements/serialize.py b/capella2polarion/elements/serialize.py index 64d94bc6..7138f69b 100644 --- a/capella2polarion/elements/serialize.py +++ b/capella2polarion/elements/serialize.py @@ -111,7 +111,7 @@ def _generic_work_item( ) -> CapellaWorkItem: xtype = ctx["POLARION_TYPE_MAP"].get(obj.uuid, type(obj).__name__) raw_description = getattr(obj, "description", markupsafe.Markup("")) - uuids, value = _sanitize_description(raw_description, ctx) + uuids, value = _sanitize_description(obj, raw_description, ctx) ctx.setdefault("DESCR_REFERENCES", {})[obj.uuid] = uuids return CapellaWorkItem( type=helpers.resolve_element_type(xtype), @@ -124,7 +124,7 @@ def _generic_work_item( def _sanitize_description( - descr: markupsafe.Markup, ctx: dict[str, t.Any] + obj: common.GenericElement, descr: markupsafe.Markup, ctx: dict[str, t.Any] ) -> tuple[list[str], markupsafe.Markup]: referenced_uuids: list[str] = [] replaced_markup = RE_DESCR_LINK_PATTERN.sub( @@ -146,7 +146,11 @@ def repair_images(node: etree._Element) -> None: b64_img = base64.b64encode(img.read()).decode("utf8") node.attrib["src"] = f"data:{mime_type};base64,{b64_img}" except FileNotFoundError: - logger.error("Inline image can't be found from %r", file_path) + logger.error( + "Inline image can't be found from %r for %r", + file_path, + obj._short_repr_(), + ) repaired_markup = chelpers.process_html_fragments( replaced_markup, repair_images