Skip to main content

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)
  • translate_python_to_javascript(python_code)
  • NodeNotInstalledError
  • JavascriptExecutionError
  • JavascriptSyntaxError

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.0.tar.gz (5.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nodepython-0.1.0-py3-none-any.whl (5.9 kB view details)

Uploaded Python 3

File details

Details for the file nodepython-0.1.0.tar.gz.

File metadata

  • Download URL: nodepython-0.1.0.tar.gz
  • Upload date:
  • Size: 5.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.10.0

File hashes

Hashes for nodepython-0.1.0.tar.gz
Algorithm Hash digest
SHA256 b1b7657556a288006e6860dfac9af1d0d6131a74dc03facc4a83a4850ed8fd6e
MD5 aafee0d73643c3fbb5833ea5eef43f89
BLAKE2b-256 44e6cee41bd76a1efbba8b8f60ce68437ffd77f28dcd5453e5b21c95903f40e7

See more details on using hashes here.

File details

Details for the file nodepython-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: nodepython-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 5.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.10.0

File hashes

Hashes for nodepython-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 36281f54d81db5eb385a50abde3477e2c9488a81124e52af02a6ec0b1a4c0e8c
MD5 26fa1e353d544dfe0fa4789592feaf38
BLAKE2b-256 62f840c9828f5d760040172f08c75e426c72ce1b19a5b3b7274956396537d804

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page