def _update_nested_dict(original_dict, new_dict):
"""Update the dictionary and its nested dictionary fields.
Note: This was copy-pasted from:
opengrok/xref/submodules/yelp_lib/yelp_lib/containers/dicts.py?r=92297a46#40
The reason is that this revision requires yelp_lib>=11.0.0 but we
can not use this version yelp-main yet (see YELPLIB-65 for details).
It's simpler to just temporarily pull this in.
:param original_dict: Original dictionary
:param new_dict: Dictionary with data to update
"""
# Using our own stack to avoid recursion.
stack = [(original_dict, new_dict)]
while stack:
original_dict, new_dict = stack.pop()
for key, value in new_dict.items():
if isinstance(value, Mapping):
original_dict.setdefault(key, {})
stack.append((original_dict[key], value))
else:
original_dict[key] = value
评论列表
文章目录