_position_data_tracker.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:data_pipeline 作者: Yelp 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号