Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(xmlupload): don't loose elements when stashing standoff properties (DEV-3151) #870

Merged
merged 2 commits into from
Mar 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 12 additions & 2 deletions src/dsp_tools/commands/xmlupload/stash/stash_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,14 @@ def make(items: list[StandoffStashItem]) -> StandoffStash | None:
Returns:
StandoffStash | None: A StandoffStash object or None, if an empty list was passed.
"""

def _get_res_id(x: StandoffStashItem) -> str:
return x.res_id

if not items:
return None
grouped_objects = {k: list(vals) for k, vals in groupby(items, key=lambda x: x.res_id)}
items = sorted(items, key=_get_res_id)
grouped_objects = {k: list(vals) for k, vals in groupby(items, key=_get_res_id)}
return StandoffStash(grouped_objects)


Expand Down Expand Up @@ -68,9 +73,14 @@ def make(items: list[LinkValueStashItem]) -> LinkValueStash | None:
Returns:
LinkValueStash | None: A LinkValueStash object or None, if an empty list was passed.
"""

def _get_res_id(x: LinkValueStashItem) -> str:
return x.res_id

if not items:
return None
grouped_objects = {k: list(vals) for k, vals in groupby(items, key=lambda x: x.res_id)}
items = sorted(items, key=_get_res_id)
grouped_objects = {k: list(vals) for k, vals in groupby(items, key=_get_res_id)}
return LinkValueStash(grouped_objects)


Expand Down