def test_object_merge_recursively_merges_dicts(): edit = {"things": {"stuff": 1}} add = {"things": {"new": 2}} utils.object_merge(add, edit) assert edit == {"things": {"stuff": 1, "new": 2}}
def test_object_merge_merges_lists(): edit = [1, 3] add = [2] utils.object_merge(add, edit) assert edit == [2, 1, 3]
def test_object_merge_keeps_original_dict_keys(): edit = {"thing": 3} add = {"thing": 1} utils.object_merge(add, edit) assert edit == {"thing": 3}
def test_obect_merge_merges_dicts(): edit = {"thing": "stuff"} add = {"test": "add"} utils.object_merge(add, edit) assert edit == {"thing": "stuff", "test": "add"}
def get_variables_data(variables_files): variables_data = load_cfg_file(variables_files[0]) # Merge multiple config files if len(variables_files) > 1: for var_file in variables_files[1:]: merged_file_data = load_cfg_file(var_file) object_merge(merged_file_data, variables_data) # Check if there's any variables we need to prompt for for section, data in variables_data.items(): for var_name, var_value in data.items(): if var_value == "{prompt}": variables_data[section][var_name] = prompter.prompt( "Enter value for parameter '{}' in section '{}':".format( var_name, section)) return variables_data
def get_variables_data(variables_files): variables_data = load_cfg_file(variables_files[0]) # Merge multiple config files if len(variables_files) > 1: for var_file in variables_files[1:]: merged_file_data = load_cfg_file(var_file) variables_data = object_merge(variables_data, merged_file_data) # Check if there's any variables we need to prompt for for section, data in variables_data.items(): for var_name, var_value in data.items(): if var_value == "{prompt}": variables_data[section][var_name] = prompter.prompt( "Enter value for parameter '{}' in section '{}':".format(var_name, section) ) return variables_data