diff --git a/.travis.yml b/.travis.yml index 663ca66a..40afcb97 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,4 +4,4 @@ compiler: script: make before_install: - sudo apt-get update -qq - - sudo apt-get install -qq gcc-4.6-plugin-dev python-six python-pygments graphviz + - sudo apt-get install -qq gcc-4.6-plugin-dev python-six python-pygments graphviz python-lxml diff --git a/libcpychecker/html/__init__.py b/libcpychecker/html/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/libcpychecker/html/make_html.py b/libcpychecker/html/make_html.py index e3ec3b50..7e6727a8 100755 --- a/libcpychecker/html/make_html.py +++ b/libcpychecker/html/make_html.py @@ -1,5 +1,6 @@ #!/usr/bin/env python """Make our data into HTML!""" +from __future__ import print_function # Copyright 2012 Buck Golemon # @@ -17,7 +18,7 @@ # along with this program. If not, see # . -import capi +from . import capi from lxml.html import ( tostring, fragment_fromstring as parse, builder as E @@ -29,24 +30,23 @@ from copy import deepcopy from itertools import islice -from json import load class HtmlPage(object): """Represent one html page.""" - def __init__(self, codefile, jsonfile): + def __init__(self, codefile, data): self.codefile = codefile - self.data = load(jsonfile) + self.data = data def __str__(self): html = tostring(self.__html__()) return '\n' + html def __html__(self): - return E.HTML( self.head(), self.body() ) + return E.HTML(self.head(), self.body()) def head(self): """The HEAD of the html document""" - head = E.HEAD( + head = E.HEAD( E.META({ 'http-equiv': 'Content-Type', 'content': 'text/html; charset=utf-8' @@ -86,7 +86,7 @@ def code(self): open('pygments_c.css', 'w').write(formatter.get_style_defs()) # Use pygments to convert it all to HTML: - code = parse(highlight(self.raw_code(), CLexer(), formatter)) + code = parse(highlight(self.raw_code(), CLexer(), formatter)) # linkify the python C-API functions for name in code.xpath('//span[@class="n"]'): @@ -210,7 +210,7 @@ def states(self): ) break else: - annotations.insert(0, + annotations.insert(0, E.LI({'data-line': str(line)}, note) ) @@ -271,9 +271,11 @@ def main(argv): """our entry point""" if len(argv) < 3: return "Please provide code and json filenames." + + from json import load codefile = open(argv[1]) - jsonfile = open(argv[2]) - print(HtmlPage(codefile, jsonfile)) + data = load(open(argv[2])) + print(HtmlPage(codefile, data)) if __name__ == '__main__': from sys import argv as ARGV diff --git a/libcpychecker/refcounts.py b/libcpychecker/refcounts.py index abe034ac..5e654cea 100644 --- a/libcpychecker/refcounts.py +++ b/libcpychecker/refcounts.py @@ -4383,6 +4383,18 @@ def check_refcounts(fun, dump_traces=False, show_traces=False, ('graphical error report for function %r written out to %r' % (fun.decl.name, filename))) + filename_v2 = ('%s.%s-refcount-errors.v2.html' + % (gcc.get_dump_base_name(), fun.decl.name)) + + from libcpychecker.html.make_html import HtmlPage + data = rep.to_json(fun) + srcfile = open(fun.start.file) + htmlfile = open(filename_v2, 'w') + htmlfile.write(str(HtmlPage(srcfile, data))) + htmlfile.close() + srcfile.close() + + if show_timings: end_cpusecs = time.clock() gcc.inform(fun.start, 'Finished analyzing reference-counting within %s' % fun.decl.name)