Skip to content

Commit 340ae86

Browse files
committed
closes #9: create v2 html by default
1 parent 6eba964 commit 340ae86

File tree

3 files changed

+24
-10
lines changed

3 files changed

+24
-10
lines changed

libcpychecker/html/__init__.py

Whitespace-only changes.

libcpychecker/html/make_html.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#!/usr/bin/env python
22
"""Make our data into HTML!"""
3+
from __future__ import print_function
34

45
# Copyright 2012 Buck Golemon <buck@yelp.com>
56
#
@@ -17,7 +18,7 @@
1718
# along with this program. If not, see
1819
# <http://www.gnu.org/licenses/>.
1920

20-
import capi
21+
from . import capi
2122

2223
from lxml.html import (
2324
tostring, fragment_fromstring as parse, builder as E
@@ -29,24 +30,23 @@
2930

3031
from copy import deepcopy
3132
from itertools import islice
32-
from json import load
3333

3434
class HtmlPage(object):
3535
"""Represent one html page."""
36-
def __init__(self, codefile, jsonfile):
36+
def __init__(self, codefile, data):
3737
self.codefile = codefile
38-
self.data = load(jsonfile)
38+
self.data = data
3939

4040
def __str__(self):
4141
html = tostring(self.__html__())
4242
return '<!DOCTYPE html>\n' + html
4343

4444
def __html__(self):
45-
return E.HTML( self.head(), self.body() )
45+
return E.HTML(self.head(), self.body())
4646

4747
def head(self):
4848
"""The HEAD of the html document"""
49-
head = E.HEAD(
49+
head = E.HEAD(
5050
E.META({
5151
'http-equiv': 'Content-Type',
5252
'content': 'text/html; charset=utf-8'
@@ -86,7 +86,7 @@ def code(self):
8686
open('pygments_c.css', 'w').write(formatter.get_style_defs())
8787

8888
# Use pygments to convert it all to HTML:
89-
code = parse(highlight(self.raw_code(), CLexer(), formatter))
89+
code = parse(highlight(self.raw_code(), CLexer(), formatter))
9090

9191
# linkify the python C-API functions
9292
for name in code.xpath('//span[@class="n"]'):
@@ -210,7 +210,7 @@ def states(self):
210210
)
211211
break
212212
else:
213-
annotations.insert(0,
213+
annotations.insert(0,
214214
E.LI({'data-line': str(line)}, note)
215215
)
216216

@@ -271,9 +271,11 @@ def main(argv):
271271
"""our entry point"""
272272
if len(argv) < 3:
273273
return "Please provide code and json filenames."
274+
275+
from json import load
274276
codefile = open(argv[1])
275-
jsonfile = open(argv[2])
276-
print(HtmlPage(codefile, jsonfile))
277+
data = load(open(argv[2]))
278+
print(HtmlPage(codefile, data))
277279

278280
if __name__ == '__main__':
279281
from sys import argv as ARGV

libcpychecker/refcounts.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4383,6 +4383,18 @@ def check_refcounts(fun, dump_traces=False, show_traces=False,
43834383
('graphical error report for function %r written out to %r'
43844384
% (fun.decl.name, filename)))
43854385

4386+
filename_v2 = ('%s.%s-refcount-errors.v2.html'
4387+
% (gcc.get_dump_base_name(), fun.decl.name))
4388+
4389+
from libcpychecker.html.make_html import HtmlPage
4390+
data = rep.to_json(fun)
4391+
srcfile = open(fun.start.file)
4392+
htmlfile = open(filename_v2, 'w')
4393+
htmlfile.write(str(HtmlPage(srcfile, data)))
4394+
htmlfile.close()
4395+
srcfile.close()
4396+
4397+
43864398
if show_timings:
43874399
end_cpusecs = time.clock()
43884400
gcc.inform(fun.start, 'Finished analyzing reference-counting within %s' % fun.decl.name)

0 commit comments

Comments
 (0)