@@ -200,20 +200,24 @@ def file_names_filter(f_name, names):
200200
201201
202202def main (sources , add = True , dry_run = True , check_style = True , single_source = False , source_filter = None ,
203- ignore_filter = None ):
203+ ignore_filter = None , count = False ):
204204 files = glob .glob ("{}**/*.java" .format (sources ), recursive = True )
205- if ignore_filter :
205+ if ignore_filter and not count :
206206 files = list (filter (lambda f : not file_names_filter (f , ignore_filter ), files ))
207- if source_filter :
207+ if source_filter and not count :
208208 files = list (filter (lambda f : file_names_filter (f , source_filter ), files ))
209209
210+ cnt = 0
210211 for java_file in files :
211212 with open (java_file , 'r+' ) as SRC :
212213 source = SRC .read ()
213214 if add :
214215 messages , shared = get_messages (source , PTRN_MESSAGE )
215216 if len (messages ) > 0 :
216- # if sum(map(lambda m: 0 if m.is_with_gil else 1, messages)) == 0:
217+ if count :
218+ cnt += 1
219+ continue
220+
217221 if 'GilNode gil' in source :
218222 print ("[skipping] {}" .format (java_file ))
219223 continue
@@ -245,7 +249,10 @@ def main(sources, add=True, dry_run=True, check_style=True, single_source=False,
245249 else :
246250 print ("removal of the GIL not yet supported" )
247251 return
248- if check_style :
252+
253+ if count :
254+ print ("TO PROCESS: {} files" .format (cnt ))
255+ if check_style and not count :
249256 # running the checkstyle gate (twice)
250257 for i in range (2 ):
251258 os .system ("mx python-gate --tags style,python-license" )
@@ -255,6 +262,7 @@ def main(sources, add=True, dry_run=True, check_style=True, single_source=False,
255262 parser = argparse .ArgumentParser ()
256263 parser .add_argument ("--dry_run" , help = "do not write any changes, stop after the first file transform" ,
257264 action = "store_true" )
265+ parser .add_argument ("--count" , help = "count how many files may need the GIL" , action = "store_true" )
258266 parser .add_argument ("--remove" , help = "remove the GIL" , action = "store_true" )
259267 parser .add_argument ("--no_style" , help = "do not run the style checker" , action = "store_true" )
260268 parser .add_argument ("--single" , help = "stop after modifying the first source" , action = "store_true" )
@@ -264,4 +272,4 @@ def main(sources, add=True, dry_run=True, check_style=True, single_source=False,
264272 args = parser .parse_args ()
265273
266274 main (args .sources , add = not args .remove , dry_run = args .dry_run , check_style = not args .no_style ,
267- single_source = args .single , source_filter = args .filter , ignore_filter = args .ignore )
275+ single_source = args .single , source_filter = args .filter , ignore_filter = args .ignore , count = args . count )
0 commit comments