mirror of https://github.com/pyodide/pyodide.git
Add first version of pyodide.py
This commit is contained in:
parent
d385b7c9f1
commit
aa433aaf81
2
Makefile
2
Makefile
|
@ -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`; \
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
# 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']
|
|
@ -0,0 +1 @@
|
|||
HELLO
|
|
@ -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"
|
||||
|
|
Loading…
Reference in New Issue