def set_value(obj,key,value,overwrite = True):
    key_fragments = key.split('.')
    current_dict = obj
    last_dict = None
    last_key = None
    for key_fragment in key_fragments:
        try:
            if not key_fragment in current_dict:
                current_dict[key_fragment] = {}
        except __HOLE__:
            if last_dict:
                last_dict[last_key] = {key_fragment : {}}
                current_dict = last_dict[last_key]
            else:
                raise
        last_dict = current_dict
        last_key = key_fragment
        current_dict = current_dict[key_fragment]

    if (not overwrite) and key_fragments[-1] in last_dict:
        return last_dict[key_fragments[-1]]

    last_dict[key_fragments[-1]] = value
    return last_dict[key_fragments[-1]]
dataset/ETHPy150Open adewes/blitzdb/blitzdb/helpers.py/set_value