You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Need add'l logic and tests to make sure that the API methods can handle partial submissions, and elegantly fill in the blanks for non-mandatory fields. I think right now it might be rejecting anything less than a full fish fry feature.
The text was updated successfully, but these errors were encountered:
I've sorted out how to do this, with the generous help of Stack Overflow:
defdeep_merge(d, u):
"""Do a deep merge of one dict into another. This will update d with values in u, but will not delete keys in d not found in u at some arbitrary depth of d. That is, u is deeply merged into d. Args - d, u: dicts Note: this is destructive to d, but not u. Returns: None """stack= [(d,u)]
whilestack:
d,u=stack.pop(0)
fork,vinu.items():
ifnotisinstance(v, collections.Mapping):
# u[k] is not a dict, nothing to merge, so just set it,# regardless if d[k] *was* a dictd[k] =velse:
# note: u[k] is a dict# get d[k], defaulting to a dict, if it doesn't previously# existdv=d.setdefault(k, {})
ifnotisinstance(dv, collections.Mapping):
# d[k] is not a dict, so just set it to u[k],# overriding whatever it wasd[k] =velse:
# both d[k] and u[k] are dicts, push them on the stack# to mergestack.append((dv, v))
Need add'l logic and tests to make sure that the API methods can handle partial submissions, and elegantly fill in the blanks for non-mandatory fields. I think right now it might be rejecting anything less than a full fish fry feature.
The text was updated successfully, but these errors were encountered: