#!/usr/bin/env python

##
## this goes through the _trial_temp/coverage files looking for
## "txtorcon" ones and counts the covered and uncovered lines (not
## counting comments, etc) and spits out percentages.
##
## FIXME surely trial et al have a way to do this, but I didn't find
## one yet
##

import os

covered = 0
uncovered = 0

thedir = './_trial_temp/coverage'
for file in os.listdir(thedir):
    file = os.path.join(thedir,file)
    if 'txtorcon' in file and 'test' not in file:
        this_cover = 0
        this_uncover = 0
        for line in open(file,'r').readlines():
            if len(line) < 6:
                continue
            elif line[:6] == '>>>>>>':
                uncovered += 1
                this_uncover += 1
            elif line[5] == ':':
                int(line[:5])
                covered += 1
                this_cover += 1
        this_cover = (float(this_cover)-this_uncover)/this_cover * 100.0
        print '%65s: %03d of %03d (%02.1f%%)' % (file, this_cover, (this_uncover+this_cover), this_cover)

print "  covered:",covered
print "uncovered:",uncovered
coverage = (float(covered)-uncovered)/covered * 100.0
print "%02.2f%% test coverage" % coverage

@@ -874,27 +874,21 @@
    t
-his_cover = (float(
+otal_lines = 
 this
@@ -893,18 +893,19 @@
 is_cover
-)-
+ + 
 this_unc
@@ -912,20 +912,66 @@
 over
-)/this_cover
+%0A        cover_percent = (float(this_cover) / total_lines)
  * 1
@@ -1048,43 +1048,34 @@
 , (t
-his_uncover+this_cover), this_cover
+otal_lines), cover_percent
 )%0A%0Ap

fix problem with per-file breakdown of test-coverage