Commit 6da0b02d authored by Romain Casati's avatar Romain Casati
Browse files

Python 3: drawSvg added.

parent 02fb8339
......@@ -17,6 +17,15 @@
"imports": ["branca"],
"depends": ["jinja2"]
},
"drawsvg": {
"name": "drawSvg",
"version": "1.8.3",
"file_name": "https://files.pythonhosted.org/packages/65/07/6326bed81257671a3c3fd1f525bb9074c0bad61cb58ce77425dde2f18ee7/drawSvg-1.8.3-py3-none-any.whl",
"install_dir": "site",
"sha256": "2cef5cd3cc5cc01236da0142aa9afe053c2e9235861d38f6f77353ff8edb957f",
"imports": ["drawSvg"],
"depends": ["imageio", "numpy"]
},
"filelock": {
"name": "filelock",
"version": "3.8.0",
......
......@@ -12,6 +12,9 @@ __email__ = "romain.casati@basthon.fr"
# as a tgz, it is extracted at the wrong location...
Path("/lib/python3.10/site-packages/lolviz.py").symlink_to("lolviz-1.4.4/lolviz.py")
# Fake cairosvg module (for drawSvg)
Path('/lib/python3.10/site-packages/cairosvg.py').touch()
@importhook.on_import('time')
def patch_time(time):
......@@ -343,3 +346,12 @@ def patch_cv2(cv2):
imshow.__doc__ = cv2.imshow.__doc__
cv2.imshow = imshow
@importhook.on_import('drawSvg')
def patch_drawSvg(drawSvg):
def download(self, filename="draw.svg"):
"""Download drawing as SVG file."""
kernel.download(filename, self.asSvg())
drawSvg.Drawing.download = download
<img src="data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIgogICAgIHdpZHRoPSIyMDAiIGhlaWdodD0iMTAwIiB2aWV3Qm94PSItMTAwLjAgLTUwLjAgMjAwIDEwMCI+CjxkZWZzPgo8L2RlZnM+CjxyZWN0IHg9Ii04MCIgeT0iLTUwIiB3aWR0aD0iNDAiIGhlaWdodD0iNTAiIGZpbGw9IiMxMjQ4ZmYiPgo8dGl0bGU+T3VyIGZpcnN0IHJlY3RhbmdsZTwvdGl0bGU+CjwvcmVjdD4KPC9zdmc+">
\ No newline at end of file
["Bio", "CLAPACK", "IPython", "PIL", "RobotRaconteur", "__future__", "__main__", "_abc", "_aix_support", "_ast", "_bisect", "_bootsubprocess", "_bz2", "_codecs", "_collections", "_collections_abc", "_compat_pickle", "_compression", "_contextvars", "_frozen_importlib", "_frozen_importlib_external", "_functools", "_heapq", "_imp", "_io", "_json", "_locale", "_markupbase", "_operator", "_posixsubprocess", "_py_abc", "_pydecimal", "_pyio", "_pyodide", "_pyodide_core", "_random", "_sha512", "_signal", "_sitebuiltins", "_socket", "_sre", "_stat", "_string", "_strptime", "_struct", "_sysconfigdata__emscripten_wasm32-emscripten", "_thread", "_threading_local", "_warnings", "_weakref", "_weakrefset", "abc", "aifc", "antigravity", "argparse", "array", "asciitree", "ast", "astropy", "asynchat", "asyncio", "asyncore", "atexit", "atomicwrites", "attr", "autograd", "b2d", "base64", "basthon", "bdb", "binarytree", "binascii", "binhex", "bisect", "bitarray", "bleach", "bokeh", "boost_histogram", "branca", "brotli", "bs4", "builtins", "bz2", "cProfile", "calendar", "certifi", "cffi", "cffi_example", "cftime", "cgi", "cgitb", "chunk", "cloudpickle", "cmd", "cmyt", "code", "codecs", "codeop", "collections", "colorspacious", "colorsys", "compileall", "concurrent", "configparser", "contextlib", "contextvars", "copy", "copyreg", "cpp-exceptions-test", "crypt", "cryptography", "cssselect", "csv", "ctypes", "cv2", "cycler", "cytoolz", "dataclasses", "datetime", "dateutil", "decimal", "decorator", "demes", "difflib", "dis", "distlib", "distutils", "doctest", "docutils", "email", "encodings", "enum", "erfa", "errno", "filecmp", "fileinput", "filelock", "fnmatch", "folium", "fontTools", "fpcast_test", "fractions", "freesasa", "ftplib", "functools", "future", "galpy", "gc", "genericpath", "geos", "getopt", "getpass", "gettext", "glob", "gmpy2", "google", "graphlib", "graphviz", "gsw", "gzip", "hashlib", "heapq", "hmac", "html", "html5lib", "http", "imageio", "imaplib", "imghdr", "imp", "importlib", "iniconfig", "inspect", "io", "ipaddress", "ipythonblocks", "itertools", "jedi", "jinja2", "joblib", "js", "json", "jsonschema", "keyword", "kiwisolver", "lazy_object_proxy", "libmagic", "linecache", "locale", "logbook", "logging", "lolviz", "lxml", "lzma", "magic", "mailbox", "mailcap", "markupsafe", "marshal", "math", "matplotlib", "micropip", "mimetypes", "mne", "modulefinder", "more_itertools", "mpl_toolkits", "mpmath", "msgpack", "msprime", "multiprocessing", "netrc", "networkx", "newick", "nlopt", "nltk", "nntplib", "nose", "ntpath", "nturl2path", "numbers", "numcodecs", "numpy", "opcode", "openssl", "operator", "optlang", "optparse", "os", "osmiter", "p5", "packaging", "pandas", "parso", "pathlib", "patsy", "pdb", "pickle", "pickletools", "pipes", "pkg_resources", "pkgconfig", "pkgutil", "platform", "plistlib", "pluggy", "poplib", "posix", "posixpath", "pprint", "profile", "proj4py", "pstats", "pty", "py", "py_compile", "pyclbr", "pyclipper", "pycparser", "pydantic", "pydoc", "pydoc_data", "pygments", "pylab", "pyodide", "pyodide_js", "pyparsing", "pyproj", "pyroutelib3", "pyrsistent", "pysat", "pytest", "pytest_benchmark", "python_solvespace", "pytz", "pywt", "qrcode", "queue", "quopri", "random", "rcviz", "re", "rebound", "reboundx", "regex", "reprlib", "requests", "retrying", "rlcompleter", "ruamel", "runpy", "sched", "scipy", "secrets", "select", "selectors", "setuptools", "setuptools_scm", "shapely", "sharedlib-test", "sharedlib_test", "shelve", "shlex", "shutil", "signal", "site", "six", "skimage", "sklearn", "smtpd", "smtplib", "sndhdr", "socket", "socketserver", "soupsieve", "sparseqr", "sqlalchemy", "sqlite3", "sre_compile", "sre_constants", "sre_parse", "ssl", "stat", "statistics", "statsmodels", "string", "stringprep", "struct", "subprocess", "suitesparse", "sunau", "svgwrite", "swiglpk", "sympy", "symtable", "sys", "sysconfig", "tabnanny", "tarfile", "tblib", "telnetlib", "tempfile", "termcolor", "test", "textwrap", "this", "threading", "threadpoolctl", "time", "timeit", "token", "tokenize", "tomli", "tomli_w", "toolz", "tqdm", "trace", "traceback", "tracemalloc", "traits", "tskit", "tty", "turtle", "tutor", "types", "typing", "typing_extensions", "uncertainties", "unittest", "unyt", "urllib", "uu", "uuid", "warnings", "wave", "weakref", "webbrowser", "webencodings", "wrapt", "wsgiref", "xarray", "xdrlib", "xgboost", "xlrd", "xml", "xmlrpc", "yaml", "yt", "zarr", "zipapp", "zipfile", "zipimport", "zlib", "zoneinfo"]
\ No newline at end of file
["Bio", "CLAPACK", "IPython", "PIL", "RobotRaconteur", "__future__", "__main__", "_abc", "_aix_support", "_ast", "_bisect", "_bootsubprocess", "_bz2", "_codecs", "_collections", "_collections_abc", "_compat_pickle", "_compression", "_contextvars", "_frozen_importlib", "_frozen_importlib_external", "_functools", "_heapq", "_imp", "_io", "_json", "_locale", "_markupbase", "_operator", "_posixsubprocess", "_py_abc", "_pydecimal", "_pyio", "_pyodide", "_pyodide_core", "_random", "_sha512", "_signal", "_sitebuiltins", "_socket", "_sre", "_stat", "_string", "_strptime", "_struct", "_sysconfigdata__emscripten_wasm32-emscripten", "_thread", "_threading_local", "_warnings", "_weakref", "_weakrefset", "abc", "aifc", "antigravity", "argparse", "array", "asciitree", "ast", "astropy", "asynchat", "asyncio", "asyncore", "atexit", "atomicwrites", "attr", "autograd", "b2d", "base64", "basthon", "bdb", "binarytree", "binascii", "binhex", "bisect", "bitarray", "bleach", "bokeh", "boost_histogram", "branca", "brotli", "bs4", "builtins", "bz2", "cProfile", "cairosvg", "calendar", "certifi", "cffi", "cffi_example", "cftime", "cgi", "cgitb", "chunk", "cloudpickle", "cmd", "cmyt", "code", "codecs", "codeop", "collections", "colorspacious", "colorsys", "compileall", "concurrent", "configparser", "contextlib", "contextvars", "copy", "copyreg", "cpp-exceptions-test", "crypt", "cryptography", "cssselect", "csv", "ctypes", "cv2", "cycler", "cytoolz", "dataclasses", "datetime", "dateutil", "decimal", "decorator", "demes", "difflib", "dis", "distlib", "distutils", "doctest", "docutils", "drawSvg", "email", "encodings", "enum", "erfa", "errno", "filecmp", "fileinput", "filelock", "fnmatch", "folium", "fontTools", "fpcast_test", "fractions", "freesasa", "ftplib", "functools", "future", "galpy", "gc", "genericpath", "geos", "getopt", "getpass", "gettext", "glob", "gmpy2", "google", "graphlib", "graphviz", "gsw", "gzip", "hashlib", "heapq", "hmac", "html", "html5lib", "http", "imageio", "imaplib", "imghdr", "imp", "importlib", "iniconfig", "inspect", "io", "ipaddress", "ipythonblocks", "itertools", "jedi", "jinja2", "joblib", "js", "json", "jsonschema", "keyword", "kiwisolver", "lazy_object_proxy", "libmagic", "linecache", "locale", "logbook", "logging", "lolviz", "lxml", "lzma", "magic", "mailbox", "mailcap", "markupsafe", "marshal", "math", "matplotlib", "micropip", "mimetypes", "mne", "modulefinder", "more_itertools", "mpl_toolkits", "mpmath", "msgpack", "msprime", "multiprocessing", "netrc", "networkx", "newick", "nlopt", "nltk", "nntplib", "nose", "ntpath", "nturl2path", "numbers", "numcodecs", "numpy", "opcode", "openssl", "operator", "optlang", "optparse", "os", "osmiter", "p5", "packaging", "pandas", "parso", "pathlib", "patsy", "pdb", "pickle", "pickletools", "pipes", "pkg_resources", "pkgconfig", "pkgutil", "platform", "plistlib", "pluggy", "poplib", "posix", "posixpath", "pprint", "profile", "proj4py", "pstats", "pty", "py", "py_compile", "pyclbr", "pyclipper", "pycparser", "pydantic", "pydoc", "pydoc_data", "pygments", "pylab", "pyodide", "pyodide_js", "pyparsing", "pyproj", "pyroutelib3", "pyrsistent", "pysat", "pytest", "pytest_benchmark", "python_solvespace", "pytz", "pywt", "qrcode", "queue", "quopri", "random", "rcviz", "re", "rebound", "reboundx", "regex", "reprlib", "requests", "retrying", "rlcompleter", "ruamel", "runpy", "sched", "scipy", "secrets", "select", "selectors", "setuptools", "setuptools_scm", "shapely", "sharedlib-test", "sharedlib_test", "shelve", "shlex", "shutil", "signal", "site", "six", "skimage", "sklearn", "smtpd", "smtplib", "sndhdr", "socket", "socketserver", "soupsieve", "sparseqr", "sqlalchemy", "sqlite3", "sre_compile", "sre_constants", "sre_parse", "ssl", "stat", "statistics", "statsmodels", "string", "stringprep", "struct", "subprocess", "suitesparse", "sunau", "svgwrite", "swiglpk", "sympy", "symtable", "sys", "sysconfig", "tabnanny", "tarfile", "tblib", "telnetlib", "tempfile", "termcolor", "test", "textwrap", "this", "threading", "threadpoolctl", "time", "timeit", "token", "tokenize", "tomli", "tomli_w", "toolz", "tqdm", "trace", "traceback", "tracemalloc", "traits", "tskit", "tty", "turtle", "tutor", "types", "typing", "typing_extensions", "uncertainties", "unittest", "unyt", "urllib", "uu", "uuid", "warnings", "wave", "weakref", "webbrowser", "webencodings", "wrapt", "wsgiref", "xarray", "xdrlib", "xgboost", "xlrd", "xml", "xmlrpc", "yaml", "yt", "zarr", "zipapp", "zipfile", "zipimport", "zlib", "zoneinfo"]
\ No newline at end of file
Please wait a moment while I gather a list of all available modules...
Bio calendar locale secrets
CLAPACK certifi logbook select
IPython cffi logging selectors
PIL cffi_example lolviz setuptools
RobotRaconteur cftime lxml setuptools_scm
__future__ cgi lzma shapely
_abc cgitb magic sharedlib-test
_aix_support chunk mailbox sharedlib_test
_ast cloudpickle mailcap shelve
_bisect cmath markupsafe shlex
_blake2 cmd marshal shutil
_bootsubprocess cmyt math signal
_bz2 code matplotlib site
_codecs codecs micropip six
_codecs_cn codeop mimetypes skimage
_codecs_hk collections mmap sklearn
_codecs_iso2022 colorspacious mne smtpd
_codecs_jp colorsys modulefinder smtplib
_codecs_kr compileall more_itertools sndhdr
_codecs_tw concurrent mpl_toolkits socket
_collections configparser mpmath socketserver
_collections_abc contextlib msgpack soupsieve
_compat_pickle contextvars msprime sparseqr
_compression copy multiprocessing sqlalchemy
_contextvars copyreg netrc sqlite3
_crypt cpp-exceptions-test networkx sre_compile
_csv crypt newick sre_constants
_ctypes cryptography nlopt sre_parse
_datetime cssselect nltk ssl
_decimal csv nntplib stat
_distutils_hack ctypes nose statistics
_functools cv2 ntpath statsmodels
_heapq cycler nturl2path string
_imp cytoolz numbers stringprep
_io dataclasses numcodecs struct
_json datetime numpy subprocess
_locale dateutil opcode suitesparse
_lsprof decimal openssl sunau
_markupbase decorator operator svgwrite
_md5 demes optlang swiglpk
_multibytecodec difflib optparse sympy
_operator dis os symtable
_pickle distlib osmiter sys
_posixsubprocess distutils p5 sysconfig
_py_abc doctest packaging tabnanny
_pydecimal docutils pandas tarfile
_pyio email parso tblib
_pyodide encodings pathlib telnetlib
_queue enum patsy tempfile
_random erfa pdb termcolor
_sha1 errno pickle test
_sha256 faulthandler pickletools textwrap
_sha3 filecmp pipes this
_sha512 fileinput pkg_resources threading
_signal filelock pkgconfig threadpoolctl
_sitebuiltins fnmatch pkgutil time
_socket folium platform timeit
_sqlite3 fontTools plistlib token
_sre fpcast_test pluggy tokenize
_stat fractions poplib tomli
_string freesasa posix tomli_w
_strptime ftplib posixpath toolz
_struct functools pprint tqdm
_symtable future profile trace
_sysconfigdata__emscripten_wasm32-emscripten galpy proj4py traceback
_thread gc pstats tracemalloc
_threading_local genericpath pty traits
_tracemalloc geos py tskit
_warnings getopt py_compile tty
_weakref getpass pyclbr turtle
_weakrefset gettext pyclipper tutor
_xxsubinterpreters glob pycparser types
abc gmpy2 pydantic typing
aifc google pydoc typing_extensions
antigravity graphlib pydoc_data uncertainties
argparse graphviz pyexpat unicodedata
array gsw pygments unittest
asciitree gzip pylab unyt
ast hashlib pyodide urllib
astropy heapq pyparsing uu
asynchat hmac pyproj uuid
asyncio html pyroutelib3 warnings
asyncore html5lib pyrsistent wave
atexit http pysat weakref
atomicwrites imageio pytest webbrowser
attr imaplib pytest_benchmark webencodings
audioop imghdr python_solvespace wrapt
autograd imp pytz wsgiref
b2d importlib pywt xarray
base64 iniconfig qrcode xdrlib
basthon inspect queue xgboost
bdb io quopri xlrd
binarytree ipaddress random xml
binascii ipythonblocks rcviz xmlrpc
binhex itertools re xxsubtype
bisect jedi rebound yaml
bitarray jinja2 reboundx yt
bleach joblib regex zarr
bokeh js reprlib zipapp
boost_histogram json requests zipfile
branca jsonschema retrying zipimport
brotli keyword rlcompleter zlib
bs4 kiwisolver ruamel zoneinfo
builtins lazy_object_proxy runpy
bz2 libmagic sched
cProfile linecache scipy
Bio cairosvg libmagic sched
CLAPACK calendar linecache scipy
IPython certifi locale secrets
PIL cffi logbook select
RobotRaconteur cffi_example logging selectors
__future__ cftime lolviz setuptools
_abc cgi lxml setuptools_scm
_aix_support cgitb lzma shapely
_ast chunk magic sharedlib-test
_bisect cloudpickle mailbox sharedlib_test
_blake2 cmath mailcap shelve
_bootsubprocess cmd markupsafe shlex
_bz2 cmyt marshal shutil
_codecs code math signal
_codecs_cn codecs matplotlib site
_codecs_hk codeop micropip six
_codecs_iso2022 collections mimetypes skimage
_codecs_jp colorspacious mmap sklearn
_codecs_kr colorsys mne smtpd
_codecs_tw compileall modulefinder smtplib
_collections concurrent more_itertools sndhdr
_collections_abc configparser mpl_toolkits socket
_compat_pickle contextlib mpmath socketserver
_compression contextvars msgpack soupsieve
_contextvars copy msprime sparseqr
_crypt copyreg multiprocessing sqlalchemy
_csv cpp-exceptions-test netrc sqlite3
_ctypes crypt networkx sre_compile
_datetime cryptography newick sre_constants
_decimal cssselect nlopt sre_parse
_distutils_hack csv nltk ssl
_functools ctypes nntplib stat
_heapq cv2 nose statistics
_imp cycler ntpath statsmodels
_io cytoolz nturl2path string
_json dataclasses numbers stringprep
_locale datetime numcodecs struct
_lsprof dateutil numpy subprocess
_markupbase decimal opcode suitesparse
_md5 decorator openssl sunau
_multibytecodec demes operator svgwrite
_operator difflib optlang swiglpk
_pickle dis optparse sympy
_posixsubprocess distlib os symtable
_py_abc distutils osmiter sys
_pydecimal doctest p5 sysconfig
_pyio docutils packaging tabnanny
_pyodide drawSvg pandas tarfile
_queue email parso tblib
_random encodings pathlib telnetlib
_sha1 enum patsy tempfile
_sha256 erfa pdb termcolor
_sha3 errno pickle test
_sha512 faulthandler pickletools textwrap
_signal filecmp pipes this
_sitebuiltins fileinput pkg_resources threading
_socket filelock pkgconfig threadpoolctl
_sqlite3 fnmatch pkgutil time
_sre folium platform timeit
_stat fontTools plistlib token
_string fpcast_test pluggy tokenize
_strptime fractions poplib tomli
_struct freesasa posix tomli_w
_symtable ftplib posixpath toolz
_sysconfigdata__emscripten_wasm32-emscripten functools pprint tqdm
_thread future profile trace
_threading_local galpy proj4py traceback
_tracemalloc gc pstats tracemalloc
_warnings genericpath pty traits
_weakref geos py tskit
_weakrefset getopt py_compile tty
_xxsubinterpreters getpass pyclbr turtle
abc gettext pyclipper tutor
aifc glob pycparser types
antigravity gmpy2 pydantic typing
argparse google pydoc typing_extensions
array graphlib pydoc_data uncertainties
asciitree graphviz pyexpat unicodedata
ast gsw pygments unittest
astropy gzip pylab unyt
asynchat hashlib pyodide urllib
asyncio heapq pyparsing uu
asyncore hmac pyproj uuid
atexit html pyroutelib3 warnings
atomicwrites html5lib pyrsistent wave
attr http pysat weakref
audioop imageio pytest webbrowser
autograd imaplib pytest_benchmark webencodings
b2d imghdr python_solvespace wrapt
base64 imp pytz wsgiref
basthon importlib pywt xarray
bdb iniconfig qrcode xdrlib
binarytree inspect queue xgboost
binascii io quopri xlrd
binhex ipaddress random xml
bisect ipythonblocks rcviz xmlrpc
bitarray itertools re xxsubtype
bleach jedi rebound yaml
bokeh jinja2 reboundx yt
boost_histogram joblib regex zarr
branca js reprlib zipapp
brotli json requests zipfile
bs4 jsonschema retrying zipimport
builtins keyword rlcompleter zlib
bz2 kiwisolver ruamel zoneinfo
cProfile lazy_object_proxy runpy
Enter any module name to get more help. Or, type "modules spam" to search
for modules whose name or summary contain the string "spam".
......
......@@ -275,3 +275,23 @@ def test_cv2(selenium_py3):
# img = result['display']['content']['image/png']
# target = read_and_backup(_test_data / "python3_cv2.png", img)
# assert target == img
def test_drawSvg(selenium_py3):
data = selenium_py3.run_basthon("""
import drawSvg as draw
d = draw.Drawing(200, 100, origin='center', displayInline=False)
r = draw.Rectangle(-80,0,40,50, fill='#1248ff')
r.appendTitle('Our first rectangle')
d.append(r)
d
""")
assert data['stdout'] == ""
assert data['stderr'] == ""
result = data['result']
html = result['result']['text/html']
target = read_and_backup(_test_data / "python3_drawSvg.html", html)
assert target == html
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment