@@ -18,43 +18,43 @@ def comment_code_ratio_stats(
1818 Analyzes and reports the comment to code ratio for the given file.
1919 """
2020 if not os .path .exists (file_path ):
21- console .print (f"[bold red]{ get_translation (" error_file_not_found" )} : { file_path } [/bold red]" )
21+ console .print (f"[bold red]{ get_translation (' error_file_not_found' )} : { file_path } [/bold red]" )
2222 raise typer .Exit (code = 1 )
2323 if not os .path .isfile (file_path ):
24- console .print (f"[bold red]{ get_translation (" error_not_a_file" )} : { file_path } [/bold red]" )
24+ console .print (f"[bold red]{ get_translation (' error_not_a_file' )} : { file_path } [/bold red]" )
2525 raise typer .Exit (code = 1 )
2626
2727 try :
2828 with open (file_path , "r" , encoding = "utf-8" ) as f :
2929 content = f .read ()
3030 except Exception as e :
31- console .print (f"[bold red]{ get_translation (" error_reading_file" )} { file_path } : { e } [/bold red]" )
31+ console .print (f"[bold red]{ get_translation (' error_reading_file' )} { file_path } : { e } [/bold red]" )
3232 raise typer .Exit (code = 1 )
3333
3434 results = analyze_comment_code_ratio (content )
3535
3636 if output_format == "json" :
3737 console .print (json .dumps (results , indent = 2 ))
3838 elif output_format == "console" :
39- console .print (f"\n [bold cyan]{ get_translation (" comment_code_ratio_analysis_for" )} [green]{ file_path } [/green]:[/bold cyan]" )
39+ console .print (f"\n [bold cyan]{ get_translation (' comment_code_ratio_analysis_for' )} [green]{ file_path } [/green]:[/bold cyan]" )
4040 summary = results .get ("summary_stats" , {})
4141
42- table_summary = Table (title = get_translation (" summary_statistics" ))
43- table_summary .add_column (get_translation (" metric" ), style = "dim" )
44- table_summary .add_column (get_translation (" value" ), justify = "right" )
45- table_summary .add_row (get_translation (" total_lines" ), str (summary .get ("total_lines_in_file" , 0 )))
46- table_summary .add_row (get_translation (" code_lines" ), str (summary .get ("code_lines" , 0 )))
47- table_summary .add_row (get_translation (" comment_lines" ), str (summary .get ("comment_only_lines" , 0 )))
48- table_summary .add_row (get_translation (" empty_lines" ), str (summary .get ("empty_or_whitespace_lines" , 0 )))
49- table_summary .add_row (get_translation (" comment_code_ratio" ), f"{ summary .get (" comment_to_code_plus_comment_ratio" , 0 ):.2%} " )
42+ table_summary = Table (title = get_translation (' summary_statistics' ))
43+ table_summary .add_column (get_translation (' metric' ), style = "dim" )
44+ table_summary .add_column (get_translation (' value' ), justify = "right" )
45+ table_summary .add_row (get_translation (' total_lines' ), str (summary .get ("total_lines_in_file" , 0 )))
46+ table_summary .add_row (get_translation (' code_lines' ), str (summary .get ("code_lines" , 0 )))
47+ table_summary .add_row (get_translation (' comment_lines' ), str (summary .get ("comment_only_lines" , 0 )))
48+ table_summary .add_row (get_translation (' empty_lines' ), str (summary .get ("empty_or_whitespace_lines" , 0 )))
49+ table_summary .add_row (get_translation (' comment_code_ratio' ), f"{ summary .get (' comment_to_code_plus_comment_ratio' , 0 ):.2%} " )
5050 console .print (table_summary )
5151
5252 line_details = results .get ("line_by_line_analysis" , [])
5353 if line_details :
54- table_details = Table (title = get_translation (" line_by_line_classification" ))
55- table_details .add_column (get_translation (" line_num" ), style = "dim" , width = 6 )
56- table_details .add_column (get_translation (" line_type" ), style = "dim" )
57- table_details .add_column (get_translation (" content_col" ))
54+ table_details = Table (title = get_translation (' line_by_line_classification' ))
55+ table_details .add_column (get_translation (' line_num' ), style = "dim" , width = 6 )
56+ table_details .add_column (get_translation (' line_type' ), style = "dim" )
57+ table_details .add_column (get_translation (' content_col' ))
5858 for line_data in line_details :
5959 table_details .add_row (
6060 str (line_data ["original_line_number" ]),
@@ -63,7 +63,7 @@ def comment_code_ratio_stats(
6363 )
6464 console .print (table_details )
6565 else :
66- console .print (f"[bold red]{ get_translation (" error_invalid_format" )} : { output_format } . { get_translation (" valid_formats_are" )} console, json.[/bold red]" )
66+ console .print (f"[bold red]{ get_translation (' error_invalid_format' )} : { output_format } . { get_translation (' valid_formats_are' )} console, json.[/bold red]" )
6767 raise typer .Exit (code = 1 )
6868
6969if __name__ == "__main__" :
0 commit comments