From 6e0431bd6768cffdb2a8f5a83c1a873029f2973c Mon Sep 17 00:00:00 2001 From: Jan Range Date: Tue, 13 Feb 2024 10:36:38 +0100 Subject: [PATCH] display files as counts if over threshold --- dvuploader/dvuploader.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/dvuploader/dvuploader.py b/dvuploader/dvuploader.py index 79adba1..b032a9d 100644 --- a/dvuploader/dvuploader.py +++ b/dvuploader/dvuploader.py @@ -59,6 +59,7 @@ def upload( print("\n") info = "\n".join( [ + f"Server: [bold]{dataverse_url}[/bold]", # type: ignore f"PID: [bold]{persistent_id}[/bold]", # type: ignore f"Files: {len(self.files)}", ] @@ -207,6 +208,9 @@ def _check_duplicates( table.add_column("Action") to_remove = [] + over_threshold = len(self.files) > 50 + n_new_files = 0 + n_skip_files = 0 for file in self.files: has_same_hash = any( @@ -214,11 +218,13 @@ def _check_duplicates( ) if has_same_hash and file.checksum: + n_skip_files += 1 table.add_row( file.fileName, "[bright_black]Same hash", "[bright_black]Skip" ) to_remove.append(file) else: + n_new_files += 1 table.add_row( file.fileName, "[spring_green3]New", "[spring_green3]Upload" ) @@ -231,6 +237,14 @@ def _check_duplicates( self.files.remove(file) console = Console() + + if over_threshold: + table = Table(title="[bold white]🔎 Checking dataset files") + + table.add_column("New", style="spring_green3", no_wrap=True) + table.add_column("Skipped", style="bright_black", no_wrap=True) + table.add_row(str(n_new_files), str(n_skip_files)) + console.print(table) @staticmethod