Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
pyodide
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
Boxiang Sun
pyodide
Commits
6c9f4fbb
Commit
6c9f4fbb
authored
Dec 04, 2018
by
Roman Yurchak
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Handle multi-line string input
parent
02e59bb2
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
6 deletions
+4
-6
src/pyodide.py
src/pyodide.py
+4
-0
test/conftest.py
test/conftest.py
+0
-6
No files found.
src/pyodide.py
View file @
6c9f4fbb
...
@@ -4,6 +4,7 @@ A library of helper utilities for connecting Python to the browser environment.
...
@@ -4,6 +4,7 @@ A library of helper utilities for connecting Python to the browser environment.
import
ast
import
ast
import
io
import
io
from
textwrap
import
dedent
__version__
=
'0.1.11'
__version__
=
'0.1.11'
...
@@ -24,6 +25,9 @@ def eval_code(code, ns):
...
@@ -24,6 +25,9 @@ def eval_code(code, ns):
"""
"""
Runs a string of code, the last part of which may be an expression.
Runs a string of code, the last part of which may be an expression.
"""
"""
# handle mis-indented input from multi-line strings
code
=
dedent
(
code
)
mod
=
ast
.
parse
(
code
)
mod
=
ast
.
parse
(
code
)
if
isinstance
(
mod
.
body
[
-
1
],
ast
.
Expr
):
if
isinstance
(
mod
.
body
[
-
1
],
ast
.
Expr
):
expr
=
ast
.
Expression
(
mod
.
body
[
-
1
].
value
)
expr
=
ast
.
Expression
(
mod
.
body
[
-
1
].
value
)
...
...
test/conftest.py
View file @
6c9f4fbb
...
@@ -102,17 +102,11 @@ class SeleniumWrapper:
...
@@ -102,17 +102,11 @@ class SeleniumWrapper:
self
.
driver
.
execute_script
(
"window.logs = []"
)
self
.
driver
.
execute_script
(
"window.logs = []"
)
def
run
(
self
,
code
):
def
run
(
self
,
code
):
if
isinstance
(
code
,
str
)
and
code
.
startswith
(
'
\
n
'
):
# we have a multiline string, fix indentation
code
=
textwrap
.
dedent
(
code
)
return
self
.
run_js
(
return
self
.
run_js
(
'return pyodide.runPython({!r})'
.
format
(
code
))
'return pyodide.runPython({!r})'
.
format
(
code
))
def
run_async
(
self
,
code
):
def
run_async
(
self
,
code
):
from
selenium.common.exceptions
import
TimeoutException
from
selenium.common.exceptions
import
TimeoutException
if
isinstance
(
code
,
str
)
and
code
.
startswith
(
'
\
n
'
):
# we have a multiline string, fix indentation
code
=
textwrap
.
dedent
(
code
)
self
.
run_js
(
self
.
run_js
(
"""
"""
window.done = false;
window.done = false;
...
...
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