45
45
_start_time = ""
46
46
_executed_path = ""
47
47
SRC_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" ]
49
49
50
50
51
51
def run_dependency (path_to_analyze , output_file_with_path , params = "" ):
@@ -307,7 +307,7 @@ def init(output_path="", make_outdir=True):
307
307
return os .path .isdir (_output_dir ), output_root_dir , result_log
308
308
309
309
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 ,
311
311
hide_progressbar = False , keep_raw_data = False , num_cores = - 1 , correct_mode = True , correct_fpath = "" , ui_mode = False ):
312
312
global _executed_path , _start_time
313
313
@@ -317,7 +317,18 @@ def run_main(mode, path_arg, dep_arguments, output_file_or_dir, file_format, url
317
317
src_path = ""
318
318
_executed_path = os .getcwd ()
319
319
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 :
321
332
CUSTOMIZED_FORMAT = {'excel' : '.xlsx' , 'html' : '.html' , 'json' : '.json' , 'yaml' : '.yaml' }
322
333
if isinstance (path_arg , list ) and len (path_arg ) == 2 :
323
334
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
342
353
logger .error (msg )
343
354
sys .exit (1 )
344
355
try :
345
- if mode == "compare" :
356
+ if "compare" in mode_list :
346
357
if before_comp_f == '' or after_comp_f == '' :
347
358
logger .error ("before and after files are necessary." )
348
359
return False
@@ -362,20 +373,14 @@ def run_main(mode, path_arg, dep_arguments, output_file_or_dir, file_format, url
362
373
run_dep = False
363
374
run_prechecker = False
364
375
remove_downloaded_source = False
365
- mode_list = []
366
376
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 ):
375
378
run_src = True
376
379
run_bin = True
377
380
run_dep = True
378
381
run_prechecker = False
382
+ if "prechecker" in mode_list or "reuse" in mode_list :
383
+ run_prechecker = True
379
384
else :
380
385
if "prechecker" in mode_list or "reuse" in mode_list :
381
386
run_prechecker = True
@@ -385,14 +390,10 @@ def run_main(mode, path_arg, dep_arguments, output_file_or_dir, file_format, url
385
390
run_src = True
386
391
if "dependency" in mode_list or "dep" in mode_list :
387
392
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 )
392
393
393
394
if run_dep or run_src or run_bin or run_prechecker :
394
395
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 )
396
397
397
398
if not hide_progressbar :
398
399
timer = TimerThread ()
0 commit comments