109109 'Adafruit_Python_Extended_Bus'
110110]
111111
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 ):
113113 """runs the various library checking functions"""
114114 pylint_info = pypi .get ("/pypi/pylint/json" )
115115 if pylint_info and pylint_info .ok :
@@ -491,29 +491,24 @@ def print_issue_overview(*insights):
491491 )
492492 output_handler (hacktober_changes )
493493
494- if __name__ == "__main__" :
494+ def main ( verbosity = 1 , output_filename = None , validator = None , error_depth = 5 ) :
495495 validator_kwarg_list = {}
496496 startup_message = [
497497 "Running CircuitPython Library checks..." ,
498498 "Report Date: {}" .format (datetime .datetime .now ().strftime ("%d %B %Y, %I:%M%p" ))
499499 ]
500- cmd_line_args = cmd_line_parser .parse_args ()
501-
502- verbosity = cmd_line_args .verbose
503500
504- if cmd_line_args .output_file :
505- output_filename = cmd_line_args .output_file
501+ if output_filename :
506502 startup_message .append (" - Report output will be saved to: {}" .format (output_filename ))
507503
508504 validators = []
509505 validator_names = []
510- if cmd_line_args .validator :
511- error_depth = cmd_line_args .error_depth
506+ if validator :
512507 startup_message .append (" - Depth for listing libraries with errors: {}" .format (error_depth ))
513508
514- if cmd_line_args . validator != "all" :
509+ if validator != "all" :
515510 validators = []
516- for func in cmd_line_args . validator .split ("," ):
511+ for func in validator .split ("," ):
517512 func_name = func .strip ()
518513 try :
519514 if not func_name .startswith ("validate" ):
@@ -553,7 +548,7 @@ def print_issue_overview(*insights):
553548 output_handler ()
554549 #print(validators)
555550 run_library_checks (validators , bundle_submodules , latest_pylint ,
556- validator_kwarg_list )
551+ validator_kwarg_list , error_depth )
557552 except :
558553 if output_filename is not None :
559554 exc_type , exc_val , exc_tb = sys .exc_info ()
@@ -572,3 +567,12 @@ def print_issue_overview(*insights):
572567 with open (output_filename , 'w' ) as f :
573568 for line in file_data :
574569 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