def has_path()

in CWMetricsToOpenSearch/es_sink/transport_utils.py [0:0]


def has_path(dic, path_elts):
    '''Given dict dic, and path path_elts, successively dereference the keys
       from path_elts, returning True. Returns False if the path is not in the
       dictionary'''
    if not isinstance(dic, dict) and path_elts:
        return False
    if not path_elts:
        return True
    if path_elts[0] in dic:
        return has_path(dic[path_elts[0]],
                        path_elts[1:])
    return False