Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
fluiddyn
transonic
Commits
e84ef70b49f6
Commit
5ea2ef68
authored
Oct 01, 2018
by
Pierre Augier
Browse files
Get block name
parent
3a475b05b92c
Changes
2
Hide whitespace changes
Inline
Side-by-side
doc/example_class.py
View file @
e84ef70b
...
...
@@ -17,11 +17,15 @@ class MyClass:
result
=
fp
.
use_pythranized_block
(
"block0"
)
else
:
# pythran block (
# float[][] a, b
,
# float[][] a, b
;
# int n
# ) -> result
# silly comment
# another comment here
# pythran block (
# float[][][] a, b
,
# float[][][] a, b
;
# int n
# ) -> result
result
=
0.0
...
...
doc/try_create_pythran_file.py
View file @
e84ef70b
from
tokenize
import
tokenize
,
untokenize
from
tokenize
import
(
tokenize
,
untokenize
,
COMMENT
,
INDENT
,
DEDENT
,
OP
,
STRING
,
NAME
,
)
from
token
import
tok_name
from
io
import
BytesIO
path
=
"example_class.py"
blocks
=
[]
with
open
(
path
)
as
file
:
code
=
file
.
read
()
has_to_find_name_block
=
False
g
=
tokenize
(
BytesIO
(
code
.
encode
(
'
utf-8
'
)).
readline
)
g
=
tokenize
(
BytesIO
(
code
.
encode
(
"
utf-8
"
)).
readline
)
for
toknum
,
tokval
,
a
,
b
,
c
in
g
:
print
((
toknum
,
tokval
,
a
,
b
,
c
))
if
toknum
==
NAME
and
tokval
==
"use_pythranized_block"
:
has_to_find_name_block
=
True
if
has_to_find_name_block
and
toknum
==
STRING
:
name_block
=
eval
(
tokval
)
print
(
"Block"
,
name_block
)
has_to_find_name_block
=
False
blocks
.
append
(
name_block
)
print
((
tok_name
[
toknum
],
tokval
))
print
(
blocks
)
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