Skip to content

Commit adeaca1

Browse files
authored
Merge pull request #188 from Pennycook/feature/finder-progress
Add progress tracker for identifying source files
2 parents 6bcfbbc + 3db34b2 commit adeaca1

File tree

1 file changed

+29
-3
lines changed

1 file changed

+29
-3
lines changed

codebasin/finder.py

+29-3
Original file line numberDiff line numberDiff line change
@@ -163,12 +163,38 @@ 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+
# Build up a list of potential source files.
167+
def _potential_file_generator(codebase):
168+
for directory in codebase._directories:
169+
yield from Path(directory).rglob("*")
170+
171+
potential_files = []
172+
for f in tqdm(
173+
_potential_file_generator(codebase),
174+
desc="Scanning current directory",
175+
unit=" files",
176+
leave=False,
177+
disable=not show_progress,
178+
):
179+
potential_files.append(f)
180+
181+
# Identify which files are in the code base.
182+
filenames = set()
183+
for f in tqdm(
184+
potential_files,
185+
desc="Identifying source files",
186+
unit=" files",
187+
leave=False,
188+
disable=not show_progress,
189+
):
190+
if f in codebase:
191+
filenames.add(f)
169192
for p in configuration:
170193
for e in configuration[p]:
171194
filenames.add(e["file"])
195+
196+
# Build a tree for each unique file for all platforms.
197+
state = ParserState(summarize_only)
172198
for f in tqdm(
173199
filenames,
174200
desc="Parsing",

0 commit comments

Comments
 (0)