Esempio n. 1
0
def get_config(config_path):
    if os.path.exists(config_path):
        json_config = json.load(open(config_path))
    else:
        json_config = {}
    json_config2 = copy.deepcopy(json_config)
    json_config, string = make_settings.fix(json_config)
    file_name = os.path.basename(config_path)
    json_config = json.loads(json.dumps(make_settings.config(
        **json_config), default=lambda o: o.__dict__))
    hashed = DeepHash(json_config)[json_config]
    hashed2 = DeepHash(json_config2)[json_config2]
    if hashed != hashed2:
        update_config(json_config, file_name=file_name)
    if not json_config:
        input(
            f"The .settings\\{file_name} file has been created. Fill in whatever you need to fill in and then press enter when done.\n")
        json_config = json.load(open(config_path))
    return json_config, json_config2
Esempio n. 2
0
def get_config(config_path):
    if os.path.exists(config_path):
        json_config = ujson.load(open(config_path))
    else:
        json_config = {}
    json_config2 = copy.deepcopy(json_config)
    json_config = make_settings.fix(json_config)
    file_name = os.path.basename(config_path)
    json_config = ujson.loads(json.dumps(make_settings.config(
        **json_config), default=lambda o: o.__dict__))
    updated = False
    if json_config != json_config2:
        updated = True
        filepath = os.path.join(".settings", "config.json")
        export_data(json_config, filepath)
    if not json_config:
        input(
            f"The .settings\\{file_name} file has been created. Fill in whatever you need to fill in and then press enter when done.\n")
        json_config = ujson.load(open(config_path))
    return json_config, updated