Commit 2606468e authored by Matthias BUSSONNIER's avatar Matthias BUSSONNIER

move first part of the logic into a wrapping function

this should help to decouple from the filesystem and heuristic in
filenames
parent 9e8cd885
......@@ -59,7 +59,19 @@ class AnnotationCCodeWriter(CCodeWriter):
def save_annotation(self, source_filename, target_filename):
with closing(Utils.open_source_file(source_filename)) as f:
lines = f.readlines()
code_source_file = self.code.get(source_filename, {})
c_file = Utils.decode_filename(os.path.basename(target_filename))
html_filename = os.path.splitext(target_filename)[0] + ".html"
return self._save_annotation(lines, code_source_file , target_filename, c_file, html_filename)
def _save_annotation(self, lines, code_source_file , target_filename, c_file, html_filename):
"""
lines : original cython source code split by lines
code_source_file : generated c code keyed by line number in original file
target filename : name of the file in which to store the generated html
c_file : filename in which the c_code has been written
"""
self.mark_pos(None)
for k, line in enumerate(lines):
......@@ -111,7 +123,6 @@ function toggleDiv(id) {
""")
output_buffer.write(u'<body>\n')
output_buffer.write(u'<p>Generated by Cython %s\n' % Version.watermark)
c_file = Utils.decode_filename(os.path.basename(target_filename))
output_buffer.write(u'<p>Raw output: <a href="%s">%s</a>\n' % (c_file, c_file))
zero_calls = dict((name, 0) for name in
......@@ -125,8 +136,7 @@ function toggleDiv(id) {
pos_comment_marker = u'/* \N{HORIZONTAL ELLIPSIS} */\n'
k = 0
code_source_file = self.code.get(source_filename, {})
print code_source_file
for line in lines:
k += 1
try:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment