Commit 0c87bea0 authored by Robert Bradshaw's avatar Robert Bradshaw

Annotate by default if there is an existing annotation.

parent 3d6647f0
......@@ -86,6 +86,7 @@ class AnnotationCCodeWriter(CCodeWriter):
html_filename = os.path.splitext(target_filename)[0] + ".html"
f = codecs.open(html_filename, "w", encoding="UTF-8")
f.write(u'<!-- Generated by Cython %s on %s -->\n' % (Version.version, time.asctime()))
f.write(u'<html>\n')
f.write(u"""
<head>
......
......@@ -2,7 +2,7 @@
# Cython Top Level
#
import os, sys, re
import os, sys, re, codecs
if sys.version_info[:2] < (2, 3):
sys.stderr.write("Sorry, Cython requires Python 2.3 or later\n")
sys.exit(1)
......@@ -607,6 +607,14 @@ def run_pipeline(source, options, full_module_name = None):
# Set up result object
result = create_default_resultobj(source, options)
if options.annotate is None:
# By default, decide based on whether an html file already exists.
html_filename = os.path.splitext(result.c_file)[0] + ".html"
if os.path.exists(html_filename):
line = codecs.open(html_filename, "r", encoding="UTF-8").readline()
if line.startswith(u'<!-- Generated by Cython'):
options.annotate = True
# Get pipeline
if source_ext.lower() == '.py':
pipeline = context.create_py_pipeline(options, result)
......@@ -826,7 +834,7 @@ default_options = dict(
errors_to_stderr = 1,
cplus = 0,
output_file = None,
annotate = False,
annotate = None,
generate_pxi = 0,
working_path = "",
recursive = 0,
......
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