]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
figleaf_htmlizer: more rearranging, behavior should still be unchanged
authorBrian Warner <warner@allmydata.com>
Thu, 12 Feb 2009 03:05:15 +0000 (20:05 -0700)
committerBrian Warner <warner@allmydata.com>
Thu, 12 Feb 2009 03:05:15 +0000 (20:05 -0700)
src/allmydata/util/figleaf_htmlizer.py

index 85639941593a12b3c5b9a0ef70ed56999b36efd0..289ebe857f877cc18d2ab8ab8ad9770d5c86da86 100644 (file)
@@ -142,44 +142,16 @@ class Renderer:
                        % (len(pcnts), len(pcnt_90),
                           len(pcnt_75), len(pcnt_50)))
 
-        def emit_table(items, show_totals):
-            index_fp.write('<table border=1><tr><th>Filename</th>'
-                           '<th># lines</th><th># covered</th>'
-                           '<th># uncovered</th>'
-                           '<th>% covered</th></tr>\n')
-            if show_totals:
-                index_fp.write('<tr><td><b>totals:</b></td>'
-                               '<td><b>%d</b></td>'
-                               '<td><b>%d</b></td>'
-                               '<td><b>%d</b></td>'
-                               '<td><b>%.1f%%</b></td>'
-                               '</tr>'
-                               '<tr></tr>\n'
-                               % (summary_lines, summary_cover,
-                                  (summary_lines - summary_cover),
-                                  summary_pcnt,))
-
-            for filename, stuff in items:
-                (n_lines, n_covered, percent_covered, display_filename) = stuff
-                html_outfile = self.make_html_filename(display_filename)
-
-                index_fp.write('<tr><td><a href="./%s">%s</a></td>'
-                               '<td>%d</td><td>%d</td><td>%d</td><td>%.1f</td>'
-                               '</tr>\n'
-                               % (html_outfile, display_filename, n_lines,
-                                  n_covered, (n_lines - n_covered),
-                                  percent_covered,))
-
-        index_fp.write('</table>\n')
-
         # sorted by number of lines that aren't covered
         index_fp.write('<h3>Sorted by Lines Uncovered</h3>\n')
-        emit_table(info_dict_items, True)
+        self.emit_table(index_fp, info_dict_items, True,
+                        summary_lines, summary_cover, summary_pcnt)
 
         # sorted by module name
         index_fp.write('<h3>Sorted by Module Name (alphabetical)</h3>\n')
         info_dict_items.sort()
-        emit_table(info_dict_items, False)
+        self.emit_table(index_fp, info_dict_items, False,
+                        summary_lines, summary_cover, summary_pcnt)
 
         index_fp.close()
 
@@ -243,6 +215,37 @@ class Renderer:
 
         return (n_lines, n_covered, pcnt, display_filename)
 
+    def emit_table(self, index_fp, items, show_totals,
+                   summary_lines, summary_cover, summary_pcnt):
+        index_fp.write('<table border=1><tr><th>Filename</th>'
+                       '<th># lines</th><th># covered</th>'
+                       '<th># uncovered</th>'
+                       '<th>% covered</th></tr>\n')
+        if show_totals:
+            index_fp.write('<tr><td><b>totals:</b></td>'
+                           '<td><b>%d</b></td>'
+                           '<td><b>%d</b></td>'
+                           '<td><b>%d</b></td>'
+                           '<td><b>%.1f%%</b></td>'
+                           '</tr>'
+                           '<tr></tr>\n'
+                           % (summary_lines, summary_cover,
+                              (summary_lines - summary_cover),
+                              summary_pcnt,))
+
+        for filename, stuff in items:
+            (n_lines, n_covered, percent_covered, display_filename) = stuff
+            html_outfile = self.make_html_filename(display_filename)
+
+            index_fp.write('<tr><td><a href="./%s">%s</a></td>'
+                           '<td>%d</td><td>%d</td><td>%d</td><td>%.1f</td>'
+                           '</tr>\n'
+                           % (html_outfile, display_filename, n_lines,
+                              n_covered, (n_lines - n_covered),
+                              percent_covered,))
+
+        index_fp.write('</table>\n')
+
     def make_html_filename(self, orig):
         return orig + ".html"