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
6449d43c
Commit
6449d43c
authored
Apr 26, 2014
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
clean up annotation code a little
--HG-- extra : amend_source : 9e1c6980d3fd2fa2d1cd0e882f7e186c3a08c7e5
parent
758dd001
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
14 deletions
+5
-14
Cython/Compiler/Annotate.py
Cython/Compiler/Annotate.py
+5
-14
No files found.
Cython/Compiler/Annotate.py
View file @
6449d43c
...
...
@@ -10,9 +10,6 @@ import Version
from
Code
import
CCodeWriter
from
Cython
import
Utils
from
contextlib
import
closing
# need one-characters subsitutions (for now) so offsets aren't off
class
AnnotationCCodeWriter
(
CCodeWriter
):
...
...
@@ -52,12 +49,12 @@ class AnnotationCCodeWriter(CCodeWriter):
def
_css
(
self
):
"""css template will later allow to choose a colormap"""
css
=
self
.
_css_template
css
=
[
self
.
_css_template
]
for
i
in
range
(
255
):
color
=
u"FFFF%02x"
%
int
(
255
/
(
1
+
i
/
10.0
))
css
=
css
+
'
\
n
.cython.score-%s {background-color: #%s;}'
%
(
str
(
i
),
color
)
css
.
append
(
'
\
n
.cython.score-%d {background-color: #%s;}'
%
(
i
,
color
)
)
return
css
return
''
.
join
(
css
)
_js
=
"""
function toggleDiv(id) {
...
...
@@ -67,7 +64,6 @@ class AnnotationCCodeWriter(CCodeWriter):
}
"""
_css_template
=
"""
body { font-family: courier; font-size: 12; }
...
...
@@ -96,7 +92,7 @@ body { font-family: courier; font-size: 12; }
"""
def
save_annotation
(
self
,
source_filename
,
target_filename
):
with
closing
(
Utils
.
open_source_file
(
source_filename
)
)
as
f
:
with
Utils
.
open_source_file
(
source_filename
)
as
f
:
lines
=
f
.
readlines
()
code_source_file
=
self
.
code
.
get
(
source_filename
,
{})
c_file
=
Utils
.
decode_filename
(
os
.
path
.
basename
(
target_filename
))
...
...
@@ -129,9 +125,6 @@ body { font-family: courier; font-size: 12; }
def
_save_annotation_footer
(
self
):
return
(
u'</body></html>
\
n
'
,)
def
_save_annotation
(
self
,
lines
,
code_source_file
,
c_file
=
None
):
"""
lines : original cython source code split by lines
...
...
@@ -148,7 +141,6 @@ body { font-family: courier; font-size: 12; }
outlist
.
extend
(
self
.
_save_annotation_footer
())
return
''
.
join
(
outlist
)
def
_save_annotation_body
(
self
,
lines
,
code_source_file
,
c_file
=
None
):
outlist
=
[]
pos_comment_marker
=
u'/*
\
N{HORIZONTAL ELLIPSIS}
*/
\
n
'
...
...
@@ -157,14 +149,12 @@ body { font-family: courier; font-size: 12; }
self
.
mark_pos
(
None
)
def
annotate
(
match
):
group_name
=
match
.
lastgroup
calls
[
group_name
]
+=
1
return
ur"<span class='cython %s'>%s</span>"
%
(
group_name
,
match
.
group
(
group_name
))
for
k
,
line
in
enumerate
(
lines
):
line
=
html_escape
(
line
)
try
:
...
...
@@ -191,6 +181,7 @@ body { font-family: courier; font-size: 12; }
outlist
.
append
(
u"<pre class='cython code score-%s' >%s</pre>"
%
(
score
,
code
))
return
outlist
_parse_code
=
re
.
compile
(
ur'(?P<refnanny>__Pyx_X?(?:GOT|GIVE)REF|__Pyx_RefNanny[A-Za-z]+)|'
ur'(?:'
...
...
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