From: Robert Bradshaw Date: Wed, 16 Jan 2008 06:54:00 +0000 (-0800) Subject: minor annotation additions X-Git-Tag: 0.9.6.14~29^2~76 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=6e308d101a9391e2719b37b767d9fd9472e6a80b;p=cython.git minor annotation additions --- diff --git a/Cython/Compiler/Annotate.py b/Cython/Compiler/Annotate.py index e1f05e49..c377d04d 100644 --- a/Cython/Compiler/Annotate.py +++ b/Cython/Compiler/Annotate.py @@ -1,10 +1,11 @@ # Note: Work in progress - +import os import re +import time from StringIO import StringIO - +import Version from Code import CCodeWriter # need one-characters subsitutions (for now) so offsets aren't off @@ -112,12 +113,15 @@ function toggleDiv(id) { """) f.write('\n') + f.write('

Generated by Cython %s on %s\n' % (Version.version, time.asctime())) + c_file = os.path.basename(filename)[:-3] + 'c' + f.write('

Raw output: %s\n' % (c_file, c_file)) k = 0 py_c_api = re.compile('(Py[A-Z][a-z]+_[A-Z][a-z][A-Za-z_]+)') pyx_api = re.compile('(__Pyx[A-Za-z_]+)\(') py_marco_api = re.compile('(Py[A-Za-z]*_[A-Z][A-Z_]+)') - error_goto = re.compile(r'(if .*? \{__pyx_filename = .*goto __pyx_L\w+;\})') + error_goto = re.compile(r'((; *if .*)? \{__pyx_filename = .*goto __pyx_L\w+;\})') for line in lines: @@ -132,6 +136,8 @@ function toggleDiv(id) { code, macro_api_calls = py_marco_api.subn(r"\1", code) code, error_goto_calls = error_goto.subn(r"\1", code) + code = code.replace(";", ";") + color = "FFFF%02x" % int(255/(1+(5*c_api_calls+2*pyx_api_calls+macro_api_calls)/10.0)) f.write("

" % (color, k))