def remove_identifiers(parameter): """Removes the identifiers (extraneous information) that should not be stored with the other information about the parameter. """ identifiers = ['project', 'component', 'function', 'type'] general_utils.remove_dictionary_keys(parameter, identifiers) return parameter
def remove_database_artifacts(component): """This method exists to remove any artifacts from database storage from the passed component (such as database identifiers) and return the updated component dictionary object. """ new_component = copy.deepcopy(component) identifiers = ['project', '_id'] general_utils.remove_dictionary_keys(new_component, identifiers) return new_component
def add_map(translator): map_fields = [ key for key in list(translator.keys()) if key.startswith('Target') ] translator['map'] = { replace_dots(field): replace_dots(translator[field]) for field in map_fields } general_utils.remove_dictionary_keys(translator, map_fields) return translator
def add_vcs(component, vcs_target): remove_component_keys = ['repository', 'repository_type'] remove_vcs_keys = ['name', 'success'] if not vcs_target['success']: vcs_target['vcs_type'] = None general_utils.remove_dictionary_keys(vcs_target, remove_vcs_keys) component['vcs'] = vcs_target component = update_component_status(component) component = update_component_vcs_status(component) general_utils.remove_dictionary_keys(component, remove_component_keys)
def adjust_name(template): if 'name' not in list(template.keys()): if 'template_file' in list(template.keys()): template['name'] = parse_template_file_name( template['template_file']) else: template['name'] = 'auto_' + general_utils.get_random_string( length=10) general_utils.remove_dictionary_keys(template, ['template_file']) return template
def update_component_vcs(new_vcs): """Makes a deep copy of the current component, overwriting it with a new vcs. """ component_copy = copy.deepcopy(component) component_copy['vcs'] = new_vcs update_component_vcs_status(component_copy, component['vcs']['status']) remove_vcs_keys = ['name', 'success'] remove_component_keys = ['_id'] general_utils.remove_dictionary_keys(component_copy['vcs'], remove_vcs_keys) general_utils.remove_dictionary_keys(component_copy, remove_component_keys) add_dates(component_copy) return component_copy
def adjust_indeces(template): index_properties = { key: template[key] for key in list(template.keys()) if is_index_key(key) } field_tool = generic_model.field_converter_closure( index_properties, index_translator_dictionary) index_properties = list(map(field_tool, index_properties)) template['indeces'] = list( map(generic_model.combine_fields, list(zip(*index_properties)))) general_utils.remove_dictionary_keys( template, list(index_translator_dictionary.keys())) return template
def add_source(translator): source_properties = { key: translator[key] for key in list(translator.keys()) if is_source_key(key) } source_tool = generic_model.field_converter_closure( source_properties, source_translator_dictionary) source_properties = list(map(source_tool, source_properties)) translator['source'] = list( map(generic_model.combine_fields, list(zip(*source_properties))))[0] general_utils.remove_dictionary_keys( translator, list(source_translator_dictionary.keys())) return translator
def adjust_fields(template): if setup: field_properties = { key: template[key] for key in list(template.keys()) if is_field_key(key) } field_tool = generic_model.field_converter_closure( field_properties, field_translator_dictionary) field_properties = list(map(field_tool, field_properties)) template['fields'] = list( map(generic_model.combine_fields, list(zip(*field_properties)))) general_utils.remove_dictionary_keys( template, list(field_translator_dictionary.keys())) elif 'fields' not in list(template.keys()): template['fields'] = [] return template
def add_target(translator): target_properties = { key: translator[key] for key in list(translator.keys()) if is_target_key(key) } if target_properties: target_tool = generic_model.field_converter_closure( target_properties, target_translator_dictionary) target_properties = list(map(target_tool, target_properties)) translator['target'] = list( map(generic_model.combine_fields, list(zip(*target_properties))))[0] general_utils.remove_dictionary_keys( translator, list(target_translator_dictionary.keys())) else: translator['target'] = {} translator['target']['structure'] = template['structure'] translator['target']['template'] = template['name'] return translator
def remove_identifiers(expression): """Removes identifier keys from the expression dictionary. """ remove_expression_keys = ['project', 'component', 'function'] general_utils.remove_dictionary_keys(expression, remove_expression_keys)
def remove_identifiers(component): remove_identifiers = ['project'] general_utils.remove_dictionary_keys(component, remove_identifiers)
def remove_identifiers(workflow): identifiers = ['project'] general_utils.remove_dictionary_keys(workflow, identifiers)
def remove_identifiers(function): identifiers = ['project'] general_utils.remove_dictionary_keys(function, identifiers)
def move_setup_properties(structure): structure['setup'] = {key: structure[key] for key in get_setup_keys()} general_utils.remove_dictionary_keys(structure, get_setup_keys()) return structure
def remove_workflow_identifier(workflow_function): """Simple filter to remove the workflow identifer from the passed function. """ identifiers = ['workflow'] general_utils.remove_dictionary_keys(workflow_function, identifiers) return workflow_function
def move_setup_properties(template): template['setup'] = {key: template[key] for key in get_setup_keys()} general_utils.remove_dictionary_keys(template, get_setup_keys()) return template
def remove_scope_identifier(function_parameter): """Removes the scope identifier (input or output) from the function parameter object. """ identifiers = ['type'] general_utils.remove_dictionary_keys(function_parameter, identifiers) return function_parameter
def cleanup(translator): general_utils.remove_dictionary_keys(translator, get_cleanup_keys()) return translator
def remove_function_identifier(function_parameter): """Removes the function identifier from the function_parameter object. """ identifiers = ['function'] general_utils.remove_dictionary_keys(function_parameter, identifiers) return function_parameter