Skip to content

Commit

Permalink
refactor: Apply requested change from review to patch_work_items
Browse files Browse the repository at this point in the history
  • Loading branch information
ewuerger committed Dec 12, 2023
1 parent 987298f commit e638978
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
6 changes: 1 addition & 5 deletions capella2polarion/elements/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,7 @@ def patch_work_items(ctx: dict[str, t.Any]) -> None:
objects = ctx["MODEL"].diagrams

obj = objects.by_uuid(uuid)
work_item: serialize.CapellaWorkItem
if (work_item := ctx["WORK_ITEMS"][uuid]) is None:
continue
work_item: serialize.CapellaWorkItem = ctx["WORK_ITEMS"][uuid]
old_work_item: serialize.CapellaWorkItem = ctx["POLARION_WI_MAP"][uuid]

links = element.create_links(obj, ctx)
Expand All @@ -161,8 +159,6 @@ def patch_work_items(ctx: dict[str, t.Any]) -> None:

for uuid in uuids:
new_work_item: serialize.CapellaWorkItem = ctx["WORK_ITEMS"][uuid]
if (new_work_item := ctx["WORK_ITEMS"][uuid]) is None:
continue
old_work_item = ctx["POLARION_WI_MAP"][uuid]
if old_work_item.id in back_links:
element.create_grouped_back_link_fields(
Expand Down
10 changes: 5 additions & 5 deletions capella2polarion/elements/serialize.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,14 +221,14 @@ def replace_markup(
uuid = match.group(1)
try:
ctx["MODEL"].by_uuid(uuid)
if pid := ctx["POLARION_ID_MAP"].get(uuid):
referenced_uuids.append(uuid)
return POLARION_WORK_ITEM_URL.format(pid=pid)
logger.warning("Found reference to non-existing work item: %r", uuid)
return match.group(default_group)
except KeyError:
logger.error("Found link to non-existing model element: %r", uuid)
return strike_through(match.group(default_group))
if pid := ctx["POLARION_ID_MAP"].get(uuid):
referenced_uuids.append(uuid)
return POLARION_WORK_ITEM_URL.format(pid=pid)
logger.warning("Found reference to non-existing work item: %r", uuid)
return match.group(default_group)


def include_pre_and_post_condition(
Expand Down

0 comments on commit e638978

Please sign in to comment.