Skip to content

Commit

Permalink
Merge pull request #1743 from materialsproject/dev
Browse files Browse the repository at this point in the history
fix contribs copy
  • Loading branch information
tschaume authored Apr 9, 2024
2 parents 6d7d62c + 45fdd31 commit 0829b80
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions mpcontribs-client/mpcontribs/client/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2166,14 +2166,16 @@ def submit_contributions(
contrib_copy = {}
for k in fields:
if k in contrib:
flat = {}
for kk, vv in flatten(contrib[k], reducer="dot").items():
if isinstance(vv, bool):
flat[kk] = "Yes" if vv else "No"
elif isinstance(vv, str):
flat[kk] = vv

contrib_copy[k] = deepcopy(unflatten(flat, splitter="dot"))
if isinstance(contrib[k], dict):
flat = {}
for kk, vv in flatten(contrib[k], reducer="dot").items():
if isinstance(vv, bool):
flat[kk] = "Yes" if vv else "No"
elif isinstance(vv, str) and vv:
flat[kk] = vv
contrib_copy[k] = deepcopy(unflatten(flat, splitter="dot"))
else:
contrib_copy[k] = deepcopy(contrib[k])

contribs[project_name].append(contrib_copy)

Expand Down

0 comments on commit 0829b80

Please sign in to comment.