Commits

Ned Batchelder committed c95a922

Refactor some report plumbing. There's a simpler way...

  • Participants
  • Parent commits b6256f8

Comments (0)

Files changed (2)

File coverage/cmdline.py

 
 import getopt, sys
 
-from coverage.annotate import AnnotateReporter
-from coverage.html import HtmlReporter
-from coverage.summary import SummaryReporter
 from coverage.execfile import run_python_file
 
 USAGE = r"""
             omit = omit.split(',')
         
         if settings.get('report'):
-            reporter = SummaryReporter(
-                                self.coverage, show_missing, ignore_errors
-                                )
-            reporter.report(args, omit_prefixes=omit)
+            self.coverage.report(morfs=args, show_missing=show_missing, ignore_errors=ignore_errors, omit_prefixes=omit)
         if settings.get('annotate'):
-            reporter = AnnotateReporter(self.coverage, ignore_errors)
-            reporter.report(args, directory, omit_prefixes=omit)
+            self.coverage.annotate(morfs=args, directory=directory, ignore_errors=ignore_errors, omit_prefixes=omit)
         if settings.get('html'):
-            reporter = HtmlReporter(self.coverage, ignore_errors)
-            reporter.report(args, directory, omit_prefixes=omit)
+            self.coverage.html_report(morfs=args, directory=directory, ignore_errors=ignore_errors, omit_prefixes=omit)
 
         return OK
     

File coverage/control.py

 from coverage.codeunit import code_unit_factory
 from coverage.data import CoverageData
 from coverage.files import FileLocator
+from coverage.html import HtmlReporter
 from coverage.misc import format_lines, CoverageException
 from coverage.summary import SummaryReporter
 
             statements, excluded, missing, format_lines(statements, missing)
             )
 
-    def report(self, morfs, show_missing=True, ignore_errors=False, file=None):
+    def report(self, morfs, show_missing=True, ignore_errors=False, file=None, omit_prefixes=None):
         """Write a summary report to `file`.
         
         Each module in `morfs` is listed, with counts of statements, executed
         
         """
         reporter = SummaryReporter(self, show_missing, ignore_errors)
-        reporter.report(morfs, outfile=file)
+        reporter.report(morfs, outfile=file, omit_prefixes=omit_prefixes)
 
-    def annotate(self, morfs, directory=None, ignore_errors=False):
+    def annotate(self, morfs, directory=None, ignore_errors=False, omit_prefixes=None):
         """Annotate a list of modules.
         
         Each module in `morfs` is annotated.  The source is written to a new
         """
         reporter = AnnotateReporter(self, ignore_errors)
         reporter.report(morfs, directory)
+
+    def html_report(self, morfs, directory=None, ignore_errors=False, omit_prefixes=None):
+        """Generate an HTML report.
+        
+        """
+        reporter = HtmlReporter(self, ignore_errors)
+        reporter.report(morfs, outfile=file, omit_prefixes=omit_prefixes)