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
aa433aaf
Commit
aa433aaf
authored
May 09, 2018
by
Michael Droettboom
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add first version of pyodide.py
parent
d385b7c9
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
27 additions
and
0 deletions
+27
-0
Makefile
Makefile
+2
-0
src/pyodide.py
src/pyodide.py
+17
-0
test/data.txt
test/data.txt
+1
-0
test/test_python.py
test/test_python.py
+7
-0
No files found.
Makefile
View file @
aa433aaf
...
...
@@ -144,6 +144,7 @@ root/.built: \
src/lazy_import.py
\
src/sitecustomize.py
\
src/webbrowser.py
\
src/pyodide.py
\
remove_modules.txt
rm
-rf
root
mkdir
-p
root/lib
...
...
@@ -154,6 +155,7 @@ root/.built: \
cp
src/webbrowser.py root/lib/python
$(PYMINOR)
cp
src/_testcapi.py root/lib/python
$(PYMINOR)
cp
src/pystone.py root/lib/python
$(PYMINOR)
cp
src/pyodide.py root/lib/python
$(PYMINOR)
/site-packages
(
\
cd
root/lib/python
$(PYMINOR)
;
\
rm
-fr
`
cat
../../../remove_modules.txt
`
;
\
...
...
src/pyodide.py
0 → 100644
View file @
aa433aaf
# A library of helper utilities for connecting Python to the browser environment
from
js
import
XMLHttpRequest
import
io
def
open_url
(
url
):
"""
Fetches a given *url* and returns a io.StringIO to access its contents.
"""
req
=
XMLHttpRequest
.
new
()
req
.
open
(
'GET'
,
url
,
False
)
req
.
send
(
None
)
return
io
.
StringIO
(
req
.
response
)
__all__
=
[
'open_url'
]
test/data.txt
0 → 100644
View file @
aa433aaf
HELLO
test/test_python.py
View file @
aa433aaf
...
...
@@ -48,6 +48,13 @@ def test_py_proxy(selenium):
assert
selenium
.
run
(
"hasattr(f, 'baz')"
)
==
False
def
test_open_url
(
selenium
):
assert
selenium
.
run
(
"import pyodide
\
n
"
"pyodide.open_url('../test/data.txt').read()
\
n
"
)
==
'HELLO
\
n
'
def
test_run_core_python_test
(
python_test
,
selenium
):
selenium
.
run
(
"import sys
\
n
"
...
...
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