From 49d38b9386f9fd3e6f36880ed6d48733cb33bc01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miroslav=20Such=C3=BD?= Date: Thu, 16 Jan 2025 11:49:53 +0100 Subject: [PATCH] add length to progress bar MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit so progress bar shows real progress Signed-off-by: Miroslav Suchý --- CHANGELOG.rst | 3 +++ src/scancode/cli.py | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 7cc1c61632..972eed25e3 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -38,6 +38,9 @@ v33.0.0 (next next, roadmap) - Update ABOUT files to adapt the ABOUT File Specification. See https://github.com/aboutcode-org/scancode-toolkit/issues/4181 +- Progress bar now shows length. You can estimate the duration now. + See https://github.com/aboutcode-org/scancode-toolkit/issues/3342 + v32.4.0 - 2025-06-26 -------------------- diff --git a/src/scancode/cli.py b/src/scancode/cli.py index 9369fe7d91..293932aca9 100644 --- a/src/scancode/cli.py +++ b/src/scancode/cli.py @@ -1252,6 +1252,8 @@ def scan_codebase( # NOTE: we never scan directories resources = ((r.location, r.path) for r in codebase.walk() if r.is_file) + if progress_manager: + resources = list(resources) use_threading = processes >= 0 runner = partial( @@ -1287,6 +1289,8 @@ def scan_codebase( if progress_manager: scans = progress_manager(scans) + # times two because of #3344 + scans.length = len(resources)*2 # hack to avoid using a context manager if hasattr(scans, '__enter__'): scans.__enter__()