Skip to content

Commit

Permalink
chore: Make constants upper case
Browse files Browse the repository at this point in the history
  • Loading branch information
micha91 committed Nov 21, 2024
1 parent 3c92328 commit 957f74f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion capella2polarion/converters/document_renderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ def __heading(self, level: int, text: str, session: RenderingSession):
session.headings.append(polarion_api.WorkItem(id=hid, title=text))
return (
f"<h{level} "
f'id="{polarion_html_helper.wi_id_prefix}{hid}">'
f'id="{polarion_html_helper.WI_ID_PREFIX}{hid}">'
f"</h{level}>"
)
return f"<h{level}>{text}</h{level}>"
Expand Down
10 changes: 5 additions & 5 deletions capella2polarion/converters/polarion_html_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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(
Expand All @@ -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

Expand Down

0 comments on commit 957f74f

Please sign in to comment.