109
109
'Adafruit_Python_Extended_Bus'
110
110
]
111
111
112
- def run_library_checks (validators , bundle_submodules , latest_pylint , kw_args ):
112
+ def run_library_checks (validators , bundle_submodules , latest_pylint , kw_args , error_depth ):
113
113
"""runs the various library checking functions"""
114
114
pylint_info = pypi .get ("/pypi/pylint/json" )
115
115
if pylint_info and pylint_info .ok :
@@ -491,29 +491,24 @@ def print_issue_overview(*insights):
491
491
)
492
492
output_handler (hacktober_changes )
493
493
494
- if __name__ == "__main__" :
494
+ def main ( verbosity = 1 , output_filename = None , validator = None , error_depth = 5 ) :
495
495
validator_kwarg_list = {}
496
496
startup_message = [
497
497
"Running CircuitPython Library checks..." ,
498
498
"Report Date: {}" .format (datetime .datetime .now ().strftime ("%d %B %Y, %I:%M%p" ))
499
499
]
500
- cmd_line_args = cmd_line_parser .parse_args ()
501
-
502
- verbosity = cmd_line_args .verbose
503
500
504
- if cmd_line_args .output_file :
505
- output_filename = cmd_line_args .output_file
501
+ if output_filename :
506
502
startup_message .append (" - Report output will be saved to: {}" .format (output_filename ))
507
503
508
504
validators = []
509
505
validator_names = []
510
- if cmd_line_args .validator :
511
- error_depth = cmd_line_args .error_depth
506
+ if validator :
512
507
startup_message .append (" - Depth for listing libraries with errors: {}" .format (error_depth ))
513
508
514
- if cmd_line_args . validator != "all" :
509
+ if validator != "all" :
515
510
validators = []
516
- for func in cmd_line_args . validator .split ("," ):
511
+ for func in validator .split ("," ):
517
512
func_name = func .strip ()
518
513
try :
519
514
if not func_name .startswith ("validate" ):
@@ -553,7 +548,7 @@ def print_issue_overview(*insights):
553
548
output_handler ()
554
549
#print(validators)
555
550
run_library_checks (validators , bundle_submodules , latest_pylint ,
556
- validator_kwarg_list )
551
+ validator_kwarg_list , error_depth )
557
552
except :
558
553
if output_filename is not None :
559
554
exc_type , exc_val , exc_tb = sys .exc_info ()
@@ -572,3 +567,12 @@ def print_issue_overview(*insights):
572
567
with open (output_filename , 'w' ) as f :
573
568
for line in file_data :
574
569
f .write (str (line ) + "\n " )
570
+
571
+ if __name__ == "__main__" :
572
+ cli_args = cmd_line_parser .parse_args ()
573
+ main (
574
+ verbosity = cli_args .verbose ,
575
+ output_filename = cli_args .output_file ,
576
+ validator = cli_args .validator ,
577
+ error_depth = cli_args .error_depth
578
+ )
0 commit comments