def get_dot(dic, key, default=None):
    """ Similar to dict.get(), but key is given with dot (eg. foo.bar) and
    result is evaluated in generous way. That is, get_dot(dic, 'foo.bar.vaz')
    will return dic['foo']['bar'] if both dic['foo'] and dic['foo']['baz'] exists,
    but return default if any of them does not exists.
    """
    keys = key.split('.')
    res = dic
    for k in keys:
        if not isinstance(res, dict):
            return default
        elif k in res:
            res = res[k]
        else:
            return default
    return res