pynode_blend
pynode_blend permite executar código Node.js diretamente a partir de scripts Python, com passagem de dados bidirecional usando JSON.
Recursos
- Executa código Node.js de dentro do Python
- Passa variáveis Python para JavaScript via JSON
- Retorna valores estruturados do Node.js para Python
- Detecta ausência de Node.js e gera exceção personalizada
- Captura erros de execução e de sintaxe do JavaScript
Instalação
pip install .
Se você publicar este pacote no PyPI como nodepython, o comando será:
pip install nodepython
Uso
from pynode_blend import run_javascript, NodeNotInstalledError
context = {
"name": "Mundo",
"numbers": [3, 5, 7, 11],
}
js_code = """
const greeting = `Olá, ${context.name}!`;
const total = context.numbers.reduce((sum, value) => sum + value, 0);
return { greeting, total };
"""
try:
result = run_javascript(js_code, context=context)
print(result)
except NodeNotInstalledError as exc:
print("Node.js não está instalado.", exc)
API
run_javascript(code, context=None, timeout=30, capture_console=False)run_python_code(python_code, context=None, timeout=30, capture_console=False)run_mixed_python_code(mixed_code, context=None, timeout=30, capture_console=False)translate_python_to_javascript(python_code)translate_mixed_python_to_javascript(mixed_code)NodeNotInstalledErrorJavascriptExecutionErrorJavascriptSyntaxError
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
nodepython-0.1.1.tar.gz
(6.6 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file nodepython-0.1.1.tar.gz.
File metadata
- Download URL: nodepython-0.1.1.tar.gz
- Upload date:
- Size: 6.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/7.0.0 CPython/3.10.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1864e467dfecbde09b344f77f835188ab8c35004fb65b9abe69a258b6041fe39
|
|
| MD5 |
96c0bf78f6a16ef3e00ed965395a1ac0
|
|
| BLAKE2b-256 |
2d1a9d4abb98dae51ad1559ea104717ea39515d5315a60cdbce08a5ab00fefd6
|
File details
Details for the file nodepython-0.1.1-py3-none-any.whl.
File metadata
- Download URL: nodepython-0.1.1-py3-none-any.whl
- Upload date:
- Size: 6.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/7.0.0 CPython/3.10.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d23351dda93a7f1b3f9e589ea5fafa26c8d08010d2ef93b6d31d5e25dc67638f
|
|
| MD5 |
046c25f3418db849a075b5ff693c549a
|
|
| BLAKE2b-256 |
c0c653cf8d13e58822afcb59a96d0ddf42a435c086b3d8e44c2c95dd456c64fb
|