DebugClients/Python3/coverage/annotate.py

changeset 29
391dc0bc4ae5
parent 0
de9c2efb9d02
child 3495
fac17a82b431
--- a/DebugClients/Python3/coverage/annotate.py	Thu Jan 07 12:31:11 2010 +0000
+++ b/DebugClients/Python3/coverage/annotate.py	Thu Jan 07 13:13:31 2010 +0000
@@ -6,11 +6,11 @@
 
 class AnnotateReporter(Reporter):
     """Generate annotated source files showing line coverage.
-    
+
     This reporter creates annotated copies of the measured source files. Each
     .py file is copied as a .py,cover file, with a left-hand margin annotating
     each line::
-    
+
         > def h(x):
         -     if 0:   #pragma: no cover
         -         pass
@@ -18,31 +18,34 @@
         !         a = 1
         >     else:
         >         a = 2
-          
+
         > h(2)
 
     Executed lines use '>', lines not executed use '!', lines excluded from
     consideration use '-'.
-    
+
     """
 
     def __init__(self, coverage, ignore_errors=False):
         super(AnnotateReporter, self).__init__(coverage, ignore_errors)
         self.directory = None
-        
+
     blank_re = re.compile(r"\s*(#|$)")
     else_re = re.compile(r"\s*else\s*:\s*(#|$)")
 
     def report(self, morfs, directory=None, omit_prefixes=None):
         """Run the report."""
         self.report_files(self.annotate_file, morfs, directory, omit_prefixes)
-        
-    def annotate_file(self, cu, statements, excluded, missing):
+
+    def annotate_file(self, cu, analysis):
         """Annotate a single file.
-        
+
         `cu` is the CodeUnit for the file to annotate.
-        
+
         """
+        if not cu.relative:
+            return
+
         filename = cu.filename
         source = cu.source_file()
         if self.directory:
@@ -52,6 +55,10 @@
             dest_file = filename + ",cover"
         dest = open(dest_file, 'w')
 
+        statements = analysis.statements
+        missing = analysis.missing
+        excluded = analysis.excluded
+
         lineno = 0
         i = 0
         j = 0
@@ -70,7 +77,7 @@
             if self.blank_re.match(line):
                 dest.write('  ')
             elif self.else_re.match(line):
-                # Special logic for lines containing only 'else:'.  
+                # Special logic for lines containing only 'else:'.
                 if i >= len(statements) and j >= len(missing):
                     dest.write('! ')
                 elif i >= len(statements) or j >= len(missing):

eric ide

mercurial