From f4fbde4dd1356b1029a93adac2c1c2ea3a47a38b Mon Sep 17 00:00:00 2001 From: Michael Harbarth Date: Thu, 21 Nov 2024 09:58:29 +0100 Subject: [PATCH] chore: Make constants upper case --- capella2polarion/converters/document_renderer.py | 4 ++-- capella2polarion/converters/polarion_html_helper.py | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/capella2polarion/converters/document_renderer.py b/capella2polarion/converters/document_renderer.py index 1bd8d2e..d932ff7 100644 --- a/capella2polarion/converters/document_renderer.py +++ b/capella2polarion/converters/document_renderer.py @@ -167,7 +167,7 @@ def __heading(self, level: int, text: str, session: RenderingSession): session.headings.append(polarion_api.WorkItem(id=hid, title=text)) return ( f"' + f'id="{polarion_html_helper.WI_ID_PREFIX}{hid}">' f"" ) return f"{text}" @@ -586,7 +586,7 @@ def _extract_section_areas( current_area_id is None and element.tag == "div" and ( - matches := polarion_html_helper.wi_id_regex.match( + matches := polarion_html_helper.WI_ID_REGEX.match( element.get("id", "") ) ) diff --git a/capella2polarion/converters/polarion_html_helper.py b/capella2polarion/converters/polarion_html_helper.py index e9c10a0..1d26a05 100644 --- a/capella2polarion/converters/polarion_html_helper.py +++ b/capella2polarion/converters/polarion_html_helper.py @@ -12,9 +12,9 @@ from capellambse import model as m from lxml import html -wi_id_prefix = "polarion_wiki macro name=module-workitem;params=id=" -h_regex = re.compile("h[0-9]") -wi_id_regex = re.compile(f"{wi_id_prefix}([A-Z|a-z|0-9]*-[0-9]+)") +WI_ID_PREFIX = "polarion_wiki macro name=module-workitem;params=id=" +H_REGEX = re.compile("h[0-9]") +WI_ID_REGEX = re.compile(f"{WI_ID_PREFIX}([A-Z|a-z|0-9]*-[0-9]+)") TEXT_WORK_ITEM_ID_FIELD = "__C2P__id" TEXT_WORK_ITEM_TYPE = "text" @@ -148,7 +148,7 @@ def extract_headings( html_content: str | list[html.HtmlElement | str], ) -> list[str]: """Return a list of work item IDs for all headings in the given content.""" - return extract_work_items(html_content, h_regex) + return extract_work_items(html_content, H_REGEX) def extract_work_items( @@ -165,7 +165,7 @@ def extract_work_items( if (tag_regex is not None and tag_regex.fullmatch(element.tag)) or ( tag_regex is None and element.tag == "div" ): - if matches := wi_id_regex.match(element.get("id")): + if matches := WI_ID_REGEX.match(element.get("id")): work_item_ids.append(matches.group(1)) return work_item_ids