Пример #1
0
def verify_user_config(userload, defaultdict):
    for key in userload:
        if key in defaultdict:
            for subkey in userload[key]:
                if subkey in defaultdict[key]:
                    pass
                else:
                    raise fluidException(subkey)
        else:
            raise fluidException(key)

    for key in userload:
        for subkey in userload[key]:
            defaultdict[key][subkey] = userload[key][subkey]
    return defaultdict
Пример #2
0
def load_config(config_file):
    try:
        if not os.path.isfile(config_file):
            raise fluidException('File "{0}" not found.'.format(config_file))

        tmp_dict = {}
        config_load = fluid_load(config_file)

        for sub in config_load:
            sub_file = uni.Path(config_file.parent, config_load[sub])
            if not os.path.isfile(sub_file):
                raise fluidException('File "{0}" not found.'.format(sub_file))
            tmp_dict[sub] = {}
            subconfig_load = fluid_load(sub_file)
            for x in subconfig_load:
                tmp_dict[sub][x] = subconfig_load[x]

    except Exception as exc:
        print(exc)
        print("Unable to load config file.")
        tmp_dict = {}

    return tmp_dict