File tree Expand file tree Collapse file tree 3 files changed +27
-4
lines changed
Expand file tree Collapse file tree 3 files changed +27
-4
lines changed Original file line number Diff line number Diff line change @@ -506,11 +506,17 @@ class BinaryDirectory:
506506 use_compilation_database : bool = False
507507
508508 _file_list : list [Path ] = field (repr = False , default_factory = list )
509+ _exclusion_stats : dict [Exclusion , int ] = field (
510+ repr = False , default_factory = dict
511+ )
509512
510513 class CompilationDatabaseNotFoundError (FileNotFoundError ):
511514 """Could not find the compilation database."""
512515
513516 def __post_init__ (self ):
517+ for ex in self .exclusions :
518+ self ._exclusion_stats [ex ] = 0
519+
514520 self ._file_list .extend (self ._find_files ())
515521
516522 @cached_property
@@ -521,6 +527,11 @@ def compilation_database(self):
521527 info ("Found compilation database: {}" , compdb )
522528 return compdb
523529
530+ @property
531+ def exclusion_stats (self ) -> dict [Exclusion , int ]:
532+ """Mapping of ``Exclusion`` to match count."""
533+ return dict (self ._exclusion_stats )
534+
524535 def changed_files (self ) -> Iterator [Path ]:
525536 """Yield files that were changed/created since last run."""
526537 files = self ._file_list
@@ -575,6 +586,7 @@ def _find_files(self) -> Iterator[Path]:
575586 file ,
576587 exclusion .pattern ,
577588 )
589+ self ._exclusion_stats [exclusion ] += 1
578590 continue
579591
580592 if is_readable_elf_file (file ):
Original file line number Diff line number Diff line change @@ -383,11 +383,17 @@ def index(
383383 exit (1 )
384384
385385 log (
386- f"Files indexed: { stats .num_files_indexed } "
387- f"(out of { stats .num_files_changed } changed files)"
386+ "Files indexed: {} (out of {} changed files)" ,
387+ stats .num_files_indexed ,
388+ stats .num_files_changed ,
388389 )
389- log (f"Files removed from index: { stats .num_files_deleted } " )
390- log (f"Symbols indexed: { stats .num_symbols_indexed } " )
390+ log ("Files removed from index: {}" , stats .num_files_deleted )
391+ log ("Symbols indexed: {}" , stats .num_symbols_indexed )
392+
393+ if stats .exclusion_stats :
394+ log ("Exclusion pattern stats:" )
395+ for ex , count in stats .exclusion_stats .items ():
396+ log (" {!r}: {}" , ex .pattern , count )
391397
392398
393399class SearchOutputFormatParamType (click .Choice ):
Original file line number Diff line number Diff line change @@ -885,6 +885,10 @@ class IndexingStats:
885885 num_files_deleted : int = 0
886886 num_symbols_indexed : int = 0
887887
888+ exclusion_stats : dict [Exclusion , int ] = field (
889+ repr = False , default_factory = dict
890+ )
891+
888892
889893@contextmanager
890894def sigint_catcher () -> Iterator [Callable [[], bool ]]:
@@ -1190,6 +1194,7 @@ def index_binary_directory(
11901194
11911195 stats .num_files_changed = len (changed_files )
11921196 stats .num_files_deleted = len (deleted_files )
1197+ stats .exclusion_stats .update (bdir .exclusion_stats )
11931198
11941199 def log_unindex_file (path , is_deleted ):
11951200 if dry_run and path in existing_files :
You can’t perform that action at this time.
0 commit comments