module imghelper.js_helper
¶
Short summary¶
module pyquickhelper.imghelper.js_helper
Helpers around images and javascript. See also:
Classes¶
class |
truncated documentation |
---|---|
Raised if node.js fails. |
Functions¶
function |
truncated documentation |
---|---|
Installs missing dependencies to compile a convert a javascript libraries. |
|
Returns node.js version. |
|
Modified version of function require in node_import.py. … |
|
Assuming script contains some javascript which produces SVG. This functions runs the code. |
|
Runs a javascript script with node.js. |
Documentation¶
Helpers around images and javascript. See also:
- exception pyquickhelper.imghelper.js_helper.NodeJsException[source]¶
Bases:
Exception
Raised if node.js fails.
- pyquickhelper.imghelper.js_helper.install_node_js_modules(dest, module_list=None, fLOG=<function noLOG>)[source]¶
Installs missing dependencies to compile a convert a javascript libraries.
- Parameters:
dest – installation folder
module_list – list of modules to install
fLOG – logging function
If module_list is None, it is replaced by:
['babel-core', 'babel-cli', 'babel-preset-env', 'babel-polyfill', 'babelify', 'browserify', 'babel-preset-es2015']
- pyquickhelper.imghelper.js_helper.require(module_name, cache_folder='.', suffix='_pyq', update=False, fLOG=<function noLOG>)[source]¶
Modified version of function require in node_import.py.
- Parameters:
module_name – required library name
cache_folder – location of the files the function creates
suffix – change the suffix if you use the same folder for multiple files
update – update the converted script
fLOG – logging function
- Returns:
outcome of the javascript script
The function is not fully tested.
- pyquickhelper.imghelper.js_helper.run_js_fct(script, required=None)[source]¶
Assuming script contains some javascript which produces SVG. This functions runs the code.
- Parameters:
script – javascript
required – required libraries (does not guaranteed to work)
- Returns:
python function
The module relies on js2py and node.js. Dependencies must be installed with npm:.
npm install babel-core babel-cli babel-preset-es2015 babel-polyfill babelify browserify babel-preset-env
Function
install_node_js_modules
can be run with admin right for that. js2py tries to convert a dependency into Python
- pyquickhelper.imghelper.js_helper.run_js_with_nodejs(script, path_dependencies=None, fLOG=<function noLOG>)[source]¶
Runs a javascript script with node.js.
- Parameters:
script – script to run
path_dependencies – where dependencies can be found if needed
fLOG – logging function
- Returns:
output of the script