def annotated_file(self, filename, statements, excluded, missing):
        """Annotate given file with coverage information."""
        with open(filename, 'r') as source:
            lines = source.readlines()
        buffer = []
        for lineno, line in enumerate(lines):
            lineno += 1
            line = line.strip('\n\r')
            empty_the_buffer = True
            if lineno in excluded:
                template = TEMPLATE_LOC_EXCLUDED
            elif lineno in missing:
                template = TEMPLATE_LOC_NOT_COVERED
            elif lineno in statements:
                template = TEMPLATE_LOC_COVERED
            else:
                empty_the_buffer = False
                buffer.append((lineno, line))
            if empty_the_buffer:
                for lno, pastline in buffer:
                    yield template % (lno, html.escape(pastline))
                buffer = []
                yield template % (lineno, html.escape(line))
Annotate given file with coverage information.
cherrypy/lib/covercp.py