Skip to content

Commit

Permalink
refactor: Simplify high level calls
Browse files Browse the repository at this point in the history
  • Loading branch information
ewuerger committed Oct 19, 2023
1 parent c7e88ea commit 891740c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
6 changes: 2 additions & 4 deletions capella2polarion/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,14 +232,12 @@ def model_elements(
ctx.obj["ELEMENTS"]["Diagram"] = [
diag for diag in ctx.obj["ELEMENTS"]["Diagram"] if diag.uuid in duuids
]
work_items = elements.element.create_work_items(ctx.obj)
ctx.obj["WORK_ITEMS"] = {wi.uuid_capella: wi for wi in work_items}

elements.element.create_work_items(ctx.obj)
elements.delete_work_items(ctx.obj)
elements.post_work_items(ctx.obj)

work_items = elements.element.create_work_items(ctx.obj)
ctx.obj["WORK_ITEMS"] = {wi.uuid_capella: wi for wi in work_items}
elements.element.create_work_items(ctx.obj)
elements.patch_work_items(ctx.obj)

elements.make_model_elements_index(ctx.obj)
Expand Down
5 changes: 3 additions & 2 deletions capella2polarion/elements/element.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ def create_work_items(
"%r are missing in the capella2polarion configuration",
", ".join(missing_types),
)
ctx["WORK_ITEMS"] = {wi.uuid_capella: wi for wi in work_items}
return work_items


Expand Down Expand Up @@ -212,8 +213,8 @@ def _handle_exchanges(
list[polarion_api.WorkItemLink],
]
CUSTOM_LINKS: dict[str, CustomLinkMaker] = {
"description_reference": _handle_description_reference_links, # type: ignore[dict-item]
"diagram_elements": _handle_diagram_reference_links, # type: ignore[dict-item]
"description_reference": _handle_description_reference_links,
"diagram_elements": _handle_diagram_reference_links,
"input_exchanges": functools.partial(_handle_exchanges, attr="inputs"),
"output_exchanges": functools.partial(_handle_exchanges, attr="outputs"),
}

0 comments on commit 891740c

Please sign in to comment.