diff --git a/qim3d/io/_downloader.py b/qim3d/io/_downloader.py index 8946e919d22589e98c13bccff7394264ce6a987b..1de7bcd91062fc20f35d987be01719da20cf028d 100644 --- a/qim3d/io/_downloader.py +++ b/qim3d/io/_downloader.py @@ -19,7 +19,7 @@ class Downloader: folder_name (str or os.PathLike): Folder class with the name of the folder in <https://data.qim.dk/> Methods: - file_directory(): Prints the downloadable files from the QIM data repository. + list_files(): Prints the downloadable files from the QIM data repository. Syntax for downloading and loading a file is `qim3d.io.Downloader().{folder_name}.{file_name}(load_file=True)` @@ -53,7 +53,7 @@ class Downloader: import qim3d downloader = qim3d.io.Downloader() - downloader.file_directory() + downloader.list_files() data = downloader.Cowry_Shell.Cowry_DOWNSAMPLED(load_file=True) qim3d.viz.slicer_orthogonal(data, color_map="magma") @@ -66,33 +66,26 @@ class Downloader: for idx, folder in enumerate(folders): exec(f"self.{folder} = self._Myfolder(folder)") - def file_directory(self): + def list_files(self): """Generate and print formatted folder, file, and size information.""" url_dl = "https://archive.compute.dtu.dk/download/public/projects/viscomp_data_repository" folders = _extract_names() - - table_header = f"{'Folder name':<20} | {'File name':<105} | {'File size':<15}" - table_separator = "-" * len(table_header) - log.info(table_header) - log.info(table_separator) for folder in folders: + log.info(f'\n{ouf.boxtitle(folder, return_str=True)}') files = _extract_names(folder) - formatted_files = [] - formatted_sizes = [] - + for file in files: url = os.path.join(url_dl, folder, file).replace("\\", "/") file_size = _get_file_size(url) - formatted_files.append(f"`{file[:-len(file.split('.')[-1])-1].replace('%20', '_')}`") - formatted_sizes.append(_format_file_size(file_size)) - - file_list_str = ", ".join(formatted_files) - size_list_str = ", ".join(formatted_sizes) + formatted_file = f"{file[:-len(file.split('.')[-1])-1].replace('%20', '_')}" + formatted_size = _format_file_size(file_size) + path_string = f'{folder}.{formatted_file}' - log.info(f"{'`' + folder + '`':<20} | {file_list_str:<105} | {size_list_str:<15}") + log.info(f'{path_string:<50}({formatted_size})') + class _Myfolder: """Class for extracting the files from each folder in the Downloader class.