@@ -19,6 +19,7 @@ def __init__(self, coverage):
1919 self .config = self .coverage .config
2020 self .branches = coverage .get_data ().has_arcs ()
2121 self .outfile = None
22+ self .output_format = self .config .format or "text"
2223 self .fr_analysis = []
2324 self .skipped_count = 0
2425 self .empty_count = 0
@@ -159,6 +160,15 @@ def report(self, morfs, outfile=None):
159160 if not self .total .n_files and not self .skipped_count :
160161 raise NoDataError ("No data to report." )
161162
163+ if self .output_format == "total" :
164+ self .write (self .total .pc_covered_str )
165+ else :
166+ self .tabular_report ()
167+
168+ return self .total .n_statements and self .total .pc_covered
169+
170+ def tabular_report (self ):
171+ """Writes tabular report formats."""
162172 # Prepare the header line and column sorting.
163173 header = ["Name" , "Stmts" , "Miss" ]
164174 if self .branches :
@@ -221,15 +231,12 @@ def report(self, morfs, outfile=None):
221231 file_suffix = 's' if self .empty_count > 1 else ''
222232 end_lines .append (f"\n { self .empty_count } empty file{ file_suffix } skipped." )
223233
224- text_format = self .config .format or "text"
225- if text_format == "markdown" :
234+ if self .output_format == "markdown" :
226235 formatter = self ._report_markdown
227236 else :
228237 formatter = self ._report_text
229238 formatter (header , lines_values , total_line , end_lines )
230239
231- return self .total .n_statements and self .total .pc_covered
232-
233240 def report_one_file (self , fr , analysis ):
234241 """Report on just one file, the callback from report()."""
235242 nums = analysis .numbers
0 commit comments