def annotate(self, pos, item):
self.annotations.append((pos, item))
- def save_annotation(self, filename):
+ def save_annotation(self, source_filename, target_filename):
self.mark_pos(None)
- f = Utils.open_source_file(filename)
+ f = Utils.open_source_file(source_filename)
lines = f.readlines()
for k in range(len(lines)):
line = lines[k]
f.close()
all = []
for pos, item in self.annotations:
- if pos[0] == filename:
+ if pos[0] == source_filename:
start = item.start()
size, end = item.end()
if size:
all.append((pos, start))
- all.append(((filename, pos[1], pos[2]+size), end))
+ all.append(((source_filename, pos[1], pos[2]+size), end))
else:
all.append((pos, start+end))
line = lines[line_no]
lines[line_no] = line[:col] + item + line[col:]
- f = codecs.open("%s.html" % filename, "w", encoding="UTF-8")
+ html_filename = os.path.splitext(target_filename)[0] + ".html"
+ f = codecs.open(html_filename, "w", encoding="UTF-8")
f.write(u'<html>\n')
f.write(u"""
<head>
""")
f.write(u'<body>\n')
f.write(u'<p>Generated by Cython %s on %s\n' % (Version.version, time.asctime()))
- c_file = Utils.encode_filename(os.path.basename(filename)[:-3] + 'c')
+ c_file = Utils.encode_filename(os.path.basename(target_filename))
f.write(u'<p>Raw output: <a href="%s">%s</a>\n' % (c_file, c_file))
k = 0
full_module_name = re.sub(r'[^\w.]', '_', full_module_name)
source = os.path.join(cwd, source)
-
+ result.main_source_file = source
+
if options.use_listing_file:
result.listing_file = replace_suffix(source, ".lis")
Errors.open_listing_file(result.listing_file,
self.listing_file = None
self.object_file = None
self.extension_file = None
+ self.main_source_file = None
def compile(source, options = None, c_compile = 0, c_link = 0,
result.c_file_generated = 1
if Options.annotate or options.annotate:
self.annotate(code)
- code.save_annotation(result.c_file[:-1] + "pyx") # change?
+ code.save_annotation(result.main_source_file, result.c_file)
def find_referenced_modules(self, env, module_list, modules_seen):
if env not in modules_seen: