Download Install Tutorial Docs FAQ Tools WikiLicense Team IRC Planet Involvement Shop Book

Changeset 554

Show
Ignore:
Timestamp:
08/25/05 03:37:16
Author:
fumanchu
Message:

Improved covercp's annotated file output: blank lines have been reinstated, but blank or other non-statement lines are marked "not covered" if the next valid statement line is marked "not covered".

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/cherrypy/lib/covercp.py

    r551 r554  
    285285            if not _skip_file(path, exclude) and not os.path.isdir(path): 
    286286                _graft(path, tree) 
    287     print tree 
    288287    return tree 
    289288 
     
    331330    def annotated_file(self, filename, statements, excluded, missing): 
    332331        source = open(filename, 'r') 
    333         lineno = 0 
    334         while 1: 
    335             line = source.readline() 
    336             if line == '': 
    337                 break 
    338             line = line[:-1] 
    339             lineno = lineno + 1 
    340             if line == '': 
    341                 yield ' ' 
    342                 continue 
     332        buffer = [] 
     333        for lineno, line in enumerate(source.readlines()): 
     334            lineno += 1 
     335            line = line.strip("\n\r") 
     336            empty_the_buffer = True 
    343337            if lineno in excluded: 
    344338                template = TEMPLATE_LOC_EXCLUDED 
    345339            elif lineno in missing: 
    346340                template = TEMPLATE_LOC_NOT_COVERED 
     341            elif lineno in statements: 
     342                template = TEMPLATE_LOC_COVERED 
    347343            else: 
    348                 template = TEMPLATE_LOC_COVERED 
    349             yield template % (lineno, cgi.escape(line)) 
     344                empty_the_buffer = False 
     345                buffer.append((lineno, line)) 
     346            if empty_the_buffer: 
     347                for lno, pastline in buffer: 
     348                    yield template % (lno, cgi.escape(pastline)) 
     349                buffer = [] 
     350                yield template % (lineno, cgi.escape(line)) 
    350351     
    351352    def report(self, name): 

Hosted by WebFaction

Log in as guest/cpguest to create tickets