1111
1212
1313class TablePrinterBase (PrinterBase , abc .ABC ):
14+ def __init__ (self , * args , ** kwargs ) -> None :
15+ super ().__init__ (* args , ** kwargs )
16+ self .text_printer = TextPrinter (self .ctx , self .console , self .console_err )
17+
1418 def print_result (self , result : CliResult ) -> None :
15- TextPrinter ( self .ctx , self . console , self . console_err ) .print_result (result )
19+ self .text_printer .print_result (result )
1620
1721 def print_error (self , error : CliError ) -> None :
18- TextPrinter ( self .ctx , self . console , self . console_err ) .print_error (error )
22+ self .text_printer .print_error (error )
1923
2024 def print_scan_results (
2125 self , local_scan_results : list ['LocalScanResult' ], errors : Optional [dict [str , 'CliError' ]] = None
@@ -26,16 +30,8 @@ def print_scan_results(
2630
2731 self ._print_results (local_scan_results )
2832
29- if not errors :
30- return
31-
32- self .console .print (self .FAILED_SCAN_MESSAGE )
33- for scan_id , error in errors .items ():
34- self .console .print (f'- { scan_id } : ' , end = '' )
35- self .print_error (error )
36-
37- def _is_git_repository (self ) -> bool :
38- return self .ctx .info_name in {'commit_history' , 'pre_commit' , 'pre_receive' } and 'remote_url' in self .ctx .obj
33+ self .print_scan_results_summary (local_scan_results )
34+ self .text_printer .print_report_urls_and_errors (local_scan_results , errors )
3935
4036 @abc .abstractmethod
4137 def _print_results (self , local_scan_results : list ['LocalScanResult' ]) -> None :
@@ -44,19 +40,3 @@ def _print_results(self, local_scan_results: list['LocalScanResult']) -> None:
4440 def _print_table (self , table : 'Table' ) -> None :
4541 if table .get_rows ():
4642 self .console .print (table .get_table ())
47-
48- def _print_report_urls (
49- self ,
50- local_scan_results : list ['LocalScanResult' ],
51- aggregation_report_url : Optional [str ] = None ,
52- ) -> None :
53- report_urls = [scan_result .report_url for scan_result in local_scan_results if scan_result .report_url ]
54- if not report_urls and not aggregation_report_url :
55- return
56- if aggregation_report_url :
57- self .console .print (f'Report URL: { aggregation_report_url } ' )
58- return
59-
60- self .console .print ('Report URLs:' )
61- for report_url in report_urls :
62- self .console .print (f'- { report_url } ' )
0 commit comments