def _add_links_for_datatype_references(datatype, fk_to_project, link_to_delete, existing_dt_links): # If we found a datatype that has links, we need to link those as well to the linked project # so they can be also copied linked_datatype_paths = [] h5_file = h5.h5_file_for_index(datatype) h5.gather_all_references_by_index(h5_file, linked_datatype_paths) for h5_path in linked_datatype_paths: if existing_dt_links is not None and h5_path in existing_dt_links: continue gid = H5File.get_metadata_param(h5_path, 'gid') dt_index = h5.load_entity_by_gid(uuid.UUID(gid)) new_link = Links(dt_index.id, fk_to_project) dao.store_entity(new_link) dao.remove_entity(Links, link_to_delete) return linked_datatype_paths
def _get_create_date_for_sorting(h5_file): create_date_str = str(H5File.get_metadata_param(h5_file, 'Create_date'), 'utf-8') create_date = string2date(create_date_str, date_format='datetime:%Y-%m-%d %H:%M:%S.%f') return create_date
def _is_empty_file(h5_file): return H5File.get_metadata_param(h5_file, 'Create_date') is None