Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Gwenaël Samain
cython
Commits
053fd91b
Commit
053fd91b
authored
Apr 22, 2014
by
Matthias BUSSONNIER
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
make _save annotation a io-less method
parent
2606468e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
19 deletions
+18
-19
Cython/Compiler/Annotate.py
Cython/Compiler/Annotate.py
+18
-19
No files found.
Cython/Compiler/Annotate.py
View file @
053fd91b
...
@@ -62,9 +62,10 @@ class AnnotationCCodeWriter(CCodeWriter):
...
@@ -62,9 +62,10 @@ class AnnotationCCodeWriter(CCodeWriter):
code_source_file
=
self
.
code
.
get
(
source_filename
,
{})
code_source_file
=
self
.
code
.
get
(
source_filename
,
{})
c_file
=
Utils
.
decode_filename
(
os
.
path
.
basename
(
target_filename
))
c_file
=
Utils
.
decode_filename
(
os
.
path
.
basename
(
target_filename
))
html_filename
=
os
.
path
.
splitext
(
target_filename
)[
0
]
+
".html"
html_filename
=
os
.
path
.
splitext
(
target_filename
)[
0
]
+
".html"
return
self
.
_save_annotation
(
lines
,
code_source_file
,
target_filename
,
c_file
,
html_filename
)
with
codecs
.
open
(
html_filename
,
"w"
,
encoding
=
"UTF-8"
)
as
out_buffer
:
out_buffer
.
write
(
self
.
_save_annotation
(
lines
,
code_source_file
,
target_filename
,
c_file
))
def
_save_annotation
(
self
,
lines
,
code_source_file
,
target_filename
,
c_file
,
html_filename
):
def
_save_annotation
(
self
,
lines
,
code_source_file
,
target_filename
,
c_file
):
"""
"""
lines : original cython source code split by lines
lines : original cython source code split by lines
code_source_file : generated c code keyed by line number in original file
code_source_file : generated c code keyed by line number in original file
...
@@ -78,12 +79,11 @@ class AnnotationCCodeWriter(CCodeWriter):
...
@@ -78,12 +79,11 @@ class AnnotationCCodeWriter(CCodeWriter):
for
c
,
cc
,
html
in
special_chars
:
for
c
,
cc
,
html
in
special_chars
:
line
=
line
.
replace
(
c
,
cc
)
line
=
line
.
replace
(
c
,
cc
)
lines
[
k
]
=
line
lines
[
k
]
=
line
outlist
=
[]
output_buffer
=
codecs
.
open
(
html_filename
,
"w"
,
encoding
=
"UTF-8"
)
outlist
.
append
(
u'<!DOCTYPE html>
\
n
'
)
output_buffer
.
write
(
u'<!DOCTYPE html>
\
n
'
)
outlist
.
append
(
u'<!-- Generated by Cython %s -->
\
n
'
%
Version
.
watermark
)
output_buffer
.
write
(
u'<!-- Generated by Cython %s -->
\
n
'
%
Version
.
watermark
)
outlist
.
append
(
u'<html>
\
n
'
)
output_buffer
.
write
(
u'<html>
\
n
'
)
outlist
.
append
(
u"""
output_buffer
.
write
(
u"""
<head>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
<style type="text/css">
...
@@ -121,9 +121,9 @@ function toggleDiv(id) {
...
@@ -121,9 +121,9 @@ function toggleDiv(id) {
</script>
</script>
</head>
</head>
"""
)
"""
)
out
put_buffer
.
write
(
u'<body>
\
n
'
)
out
list
.
append
(
u'<body>
\
n
'
)
out
put_buffer
.
write
(
u'<p>Generated by Cython %s
\
n
'
%
Version
.
watermark
)
out
list
.
append
(
u'<p>Generated by Cython %s
\
n
'
%
Version
.
watermark
)
out
put_buffer
.
write
(
u'<p>Raw output: <a href="%s">%s</a>
\
n
'
%
(
c_file
,
c_file
))
out
list
.
append
(
u'<p>Raw output: <a href="%s">%s</a>
\
n
'
%
(
c_file
,
c_file
))
zero_calls
=
dict
((
name
,
0
)
for
name
in
zero_calls
=
dict
((
name
,
0
)
for
name
in
'refnanny py_macro_api py_c_api pyx_macro_api pyx_c_api error_goto'
.
split
())
'refnanny py_macro_api py_c_api pyx_macro_api pyx_c_api error_goto'
.
split
())
...
@@ -154,18 +154,17 @@ function toggleDiv(id) {
...
@@ -154,18 +154,17 @@ function toggleDiv(id) {
score
=
(
5
*
calls
[
'py_c_api'
]
+
2
*
calls
[
'pyx_c_api'
]
+
score
=
(
5
*
calls
[
'py_c_api'
]
+
2
*
calls
[
'pyx_c_api'
]
+
calls
[
'py_macro_api'
]
+
calls
[
'pyx_macro_api'
])
calls
[
'py_macro_api'
]
+
calls
[
'pyx_macro_api'
])
color
=
u"FFFF%02x"
%
int
(
255
/
(
1
+
score
/
10.0
))
color
=
u"FFFF%02x"
%
int
(
255
/
(
1
+
score
/
10.0
))
out
put_buffer
.
write
(
u"<pre class='line' style='background-color: #%s' onclick='toggleDiv(
\
"
line%s
\
"
)'>"
%
(
color
,
k
))
out
list
.
append
(
u"<pre class='line' style='background-color: #%s' onclick='toggleDiv(
\
"
line%s
\
"
)'>"
%
(
color
,
k
))
out
put_buffer
.
write
(
u" %d: "
%
k
)
out
list
.
append
(
u" %d: "
%
k
)
for
c
,
cc
,
html
in
special_chars
:
for
c
,
cc
,
html
in
special_chars
:
line
=
line
.
replace
(
cc
,
html
)
line
=
line
.
replace
(
cc
,
html
)
output_buffer
.
write
(
line
.
rstrip
())
outlist
.
append
(
line
.
rstrip
())
output_buffer
.
write
(
u'</pre>
\
n
'
)
output_buffer
.
write
(
u"<pre id='line%s' class='code' style='background-color: #%s'>%s</pre>"
%
(
k
,
color
,
code
))
output_buffer
.
write
(
u'</body></html>
\
n
'
)
output_buffer
.
close
()
outlist
.
append
(
u'</pre>
\
n
'
)
outlist
.
append
(
u"<pre id='line%s' class='code' style='background-color: #%s'>%s</pre>"
%
(
k
,
color
,
code
))
outlist
.
append
(
u'</body></html>
\
n
'
)
return
''
.
join
(
outlist
)
_parse_code
=
re
.
compile
(
_parse_code
=
re
.
compile
(
ur'(?P<refnanny>__Pyx_X?(?:GOT|GIVE)REF|__Pyx_RefNanny[A-Za-z]+)|'
ur'(?P<refnanny>__Pyx_X?(?:GOT|GIVE)REF|__Pyx_RefNanny[A-Za-z]+)|'
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment