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.2.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.2.tar.gz.
File metadata
- Download URL: nodepython-0.1.2.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 |
194cd080c260162d96d14ba45b8fd9923ed33f07f6b09c3274fd8649f532a4c9
|
|
| MD5 |
0964283773593a61003a1fc76a74334f
|
|
| BLAKE2b-256 |
a5567ee1dbd9d6d8bf4e8618d07fe606641bff949dd828adf93fb292b13729b4
|
File details
Details for the file nodepython-0.1.2-py3-none-any.whl.
File metadata
- Download URL: nodepython-0.1.2-py3-none-any.whl
- Upload date:
- Size: 6.6 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 |
0444e5c0de55b932effe6a1167c213a90e404c296fa26e3cb82c4f853d07071f
|
|
| MD5 |
13e096e372edd7234bcc586003639858
|
|
| BLAKE2b-256 |
ac870d0bb0885d723d526ad20a6b0f07d352f2e0b9c18cec0f54cf84fc1e1829
|