From 0c87bea0d56b1be244673625c5cb4e17e3ab5447 Mon Sep 17 00:00:00 2001 From: Robert Bradshaw Date: Thu, 24 Feb 2011 22:45:02 -0800 Subject: [PATCH] Annotate by default if there is an existing annotation. --- Cython/Compiler/Annotate.py | 1 + Cython/Compiler/Main.py | 12 ++++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/Cython/Compiler/Annotate.py b/Cython/Compiler/Annotate.py index cfdcfaed..98823fe0 100644 --- a/Cython/Compiler/Annotate.py +++ b/Cython/Compiler/Annotate.py @@ -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'\n' % (Version.version, time.asctime())) f.write(u'\n') f.write(u""" diff --git a/Cython/Compiler/Main.py b/Cython/Compiler/Main.py index c20d7a7c..993d8d99 100644 --- a/Cython/Compiler/Main.py +++ b/Cython/Compiler/Main.py @@ -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'