@@ -61,7 +61,7 @@ def ensure_all_dirs_scanned(self, ctlr=None):
6161 len (dirs ))
6262 except :
6363 pass # eat any errors about reporting progress
64- self .ensure_dir_scanned (dir , ctlr = ctlr , reporter = lambda msg : None )
64+ self .ensure_dir_scanned (dir , ctlr = ctlr )
6565 scanned .add (dir )
6666 finally :
6767 # report that we have stopped scanning
@@ -79,20 +79,27 @@ def ensure_dir_scanned(self, dir, ctlr=None, reporter=None):
7979 if dir not in self ._have_ensured_scanned_from_dir_cache :
8080 if reporter is None :
8181 reporter = self .lang_zone .db .event_reporter
82- if not callable (reporter ):
83- reporter = None
8482 res_index = self .lang_zone .load_index (dir , "res_index" , {})
8583 importables = self ._importables_from_dir (dir )
8684 importable_values = [i [0 ] for i in importables .values ()
8785 if i [0 ] is not None ]
86+ removed_values = set (res_index .keys ()).difference (importable_values )
87+ current = 0
88+ total = len (importable_values ) + len (removed_values )
8889 for base in importable_values :
8990 if ctlr and ctlr .is_aborted ():
9091 log .debug ("ctlr aborted" )
9192 return
93+ current += 1
9294 if base not in res_index :
93- if reporter :
94- reporter ("scanning %s files in '%s'" % (self .lang , dir ))
95- reporter = None # don't report again
95+ if reporter and hasattr (reporter , "onScanFile" ):
96+ try :
97+ reporter .onScanFile ("Scanning %s file '%s'" % (self .lang , join (dir , base )),
98+ dir ,
99+ current ,
100+ total )
101+ except :
102+ pass # eat any errors about reporting progress
96103 try :
97104 buf = self .mgr .buf_from_path (join (dir , base ),
98105 lang = self .lang )
@@ -106,14 +113,19 @@ def ensure_dir_scanned(self, dir, ctlr=None, reporter=None):
106113 buf .scan_if_necessary ()
107114
108115 # Remove scanned paths that don't exist anymore.
109- removed_values = set (res_index .keys ()).difference (importable_values )
110116 for base in removed_values :
111117 if ctlr and ctlr .is_aborted ():
112118 log .debug ("ctlr aborted" )
113119 return
114- if reporter :
115- reporter ("scanning %s files in '%s'" % (self .lang , dir ))
116- reporter = None # don't report again
120+ current += 1
121+ if reporter and hasattr (reporter , "onScanFile" ):
122+ try :
123+ reporter .onScanFile ("Scanning %s file '%s'" % (self .lang , join (dir , base )),
124+ dir ,
125+ current ,
126+ total )
127+ except :
128+ pass # eat any errors about reporting progress
117129 basename = join (dir , base )
118130 self .lang_zone .remove_path (basename )
119131
0 commit comments