Skip to content

Commit c492f79

Browse files
committed
Add progress tracker for identifying source files
If a source directory contains many files (e.g., because a build directory was accidentally included) it can take a long time to identify the source files in the code base. This commit adds a progress tracker with tqdm to make it clear that CBI is doing something and hasn't just stalled. We don't get a progress bar, because the number of files in the code base is not known a priori, but tqdm will print the number of files found so far. Signed-off-by: John Pennycook <[email protected]>
1 parent adba0e7 commit c492f79

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

codebasin/finder.py

+13-3
Original file line numberDiff line numberDiff line change
@@ -163,12 +163,22 @@ def find(
163163
if isinstance(rootdir, Path):
164164
rootdir = str(rootdir)
165165

166-
# Build a tree for each unique file for all platforms.
167-
state = ParserState(summarize_only)
168-
filenames = set(codebase)
166+
# Identify all of the files in the codebase.
167+
filenames = set()
168+
for f in tqdm(
169+
codebase,
170+
desc="Identifying source files",
171+
unit=" files",
172+
leave=False,
173+
disable=not show_progress,
174+
):
175+
filenames.add(f)
169176
for p in configuration:
170177
for e in configuration[p]:
171178
filenames.add(e["file"])
179+
180+
# Build a tree for each unique file for all platforms.
181+
state = ParserState(summarize_only)
172182
for f in tqdm(
173183
filenames,
174184
desc="Parsing",

0 commit comments

Comments
 (0)