4545_start_time = ""
4646_executed_path = ""
4747SRC_DIR_FROM_LINK_PREFIX = "fosslight_src_dir_"
48- SCANNER_MODE = ["compare" , "reuse" , "prechecker" , "binary" , "bin" , "src" , "source" , "dependency" , "dep" ]
48+ SCANNER_MODE = ["all" , " compare" , "reuse" , "prechecker" , "binary" , "bin" , "src" , "source" , "dependency" , "dep" ]
4949
5050
5151def run_dependency (path_to_analyze , output_file_with_path , params = "" ):
@@ -307,7 +307,7 @@ def init(output_path="", make_outdir=True):
307307 return os .path .isdir (_output_dir ), output_root_dir , result_log
308308
309309
310- def run_main (mode , path_arg , dep_arguments , output_file_or_dir , file_format , url_to_analyze , db_url ,
310+ def run_main (mode_list , path_arg , dep_arguments , output_file_or_dir , file_format , url_to_analyze , db_url ,
311311 hide_progressbar = False , keep_raw_data = False , num_cores = - 1 , correct_mode = True , correct_fpath = "" , ui_mode = False ):
312312 global _executed_path , _start_time
313313
@@ -317,7 +317,18 @@ def run_main(mode, path_arg, dep_arguments, output_file_or_dir, file_format, url
317317 src_path = ""
318318 _executed_path = os .getcwd ()
319319
320- if mode == "compare" :
320+ mode_not_supported = list (set (mode_list ).difference (SCANNER_MODE ))
321+ if mode_not_supported :
322+ logger .error (f"[Error]: An unsupported mode was entered.:{ mode_not_supported } " )
323+ sys .exit (1 )
324+ if len (mode_list ) > 2 :
325+ logger .error ("[Error]: Enter no more than two modes." )
326+ sys .exit (1 )
327+ if ("compare" in mode_list ) and (len (mode_list ) > 1 ) and (mode_list != ["compare" , "compare" ]):
328+ logger .error ("[Error]: Compare mode cannot be run together with other modes." )
329+ sys .exit (1 )
330+
331+ if "compare" in mode_list :
321332 CUSTOMIZED_FORMAT = {'excel' : '.xlsx' , 'html' : '.html' , 'json' : '.json' , 'yaml' : '.yaml' }
322333 if isinstance (path_arg , list ) and len (path_arg ) == 2 :
323334 before_comp_f = path_arg [0 ]
@@ -342,7 +353,7 @@ def run_main(mode, path_arg, dep_arguments, output_file_or_dir, file_format, url
342353 logger .error (msg )
343354 sys .exit (1 )
344355 try :
345- if mode == "compare" :
356+ if "compare" in mode_list :
346357 if before_comp_f == '' or after_comp_f == '' :
347358 logger .error ("before and after files are necessary." )
348359 return False
@@ -362,20 +373,14 @@ def run_main(mode, path_arg, dep_arguments, output_file_or_dir, file_format, url
362373 run_dep = False
363374 run_prechecker = False
364375 remove_downloaded_source = False
365- mode_list = []
366376
367- if mode :
368- mode_list = mode .split (',' )
369- mode_list = [item .strip () for item in mode_list ]
370-
371- if "compare" in mode_list :
372- logger .error ("Compare mode cannot be run together with other modes." )
373- sys .exit (1 )
374- elif "all" in mode_list or (not mode ):
377+ if "all" in mode_list or (not mode_list ):
375378 run_src = True
376379 run_bin = True
377380 run_dep = True
378381 run_prechecker = False
382+ if "prechecker" in mode_list or "reuse" in mode_list :
383+ run_prechecker = True
379384 else :
380385 if "prechecker" in mode_list or "reuse" in mode_list :
381386 run_prechecker = True
@@ -385,14 +390,10 @@ def run_main(mode, path_arg, dep_arguments, output_file_or_dir, file_format, url
385390 run_src = True
386391 if "dependency" in mode_list or "dep" in mode_list :
387392 run_dep = True
388- mode_not_supported = list (set (mode_list ).difference (SCANNER_MODE ))
389- if len (mode_not_supported ) > 0 :
390- logger .error (f"An unsupported mode was entered.:{ mode_not_supported } " )
391- sys .exit (1 )
392393
393394 if run_dep or run_src or run_bin or run_prechecker :
394395 if src_path == "" and url_to_analyze == "" :
395- src_path , dep_arguments , url_to_analyze = get_input_mode (_executed_path , mode )
396+ src_path , dep_arguments , url_to_analyze = get_input_mode (_executed_path , mode_list )
396397
397398 if not hide_progressbar :
398399 timer = TimerThread ()
0 commit comments