Skip to main content

pycurenergia

Librería Python que lee las facturas en PDF de CurEnergía (electricidad y gas) y devuelve sus datos como objetos tipados. Todos los importes, kWh, m³ y porcentajes son decimal.Decimal.

Proyecto no oficial: no está afiliado, respaldado ni patrocinado por CurEnergía.

Licencia MIT.

Uso

from pycurenergia import check_consistency, parse_invoice_pdf

with open("factura.pdf", "rb") as f:
    invoice = parse_invoice_pdf(f.read())

print(invoice.supply, invoice.total)
print(check_consistency(invoice))  # [] si los importes cuadran
  • parse_invoice_pdf(data: bytes) lee un PDF; parse_invoice_text(text: str) parsea el texto ya extraído.
  • Errores (todos derivan de Exception; ninguno incluye texto de la factura en su mensaje):
    • InvoiceReadError: el PDF no se puede leer (dañado, vacío, cifrado con contraseña) o es demasiado grande (más de 10 MiB o de 20 páginas). Solo lo lanza parse_invoice_pdf; el error original de pypdf queda en __cause__.
    • UnsupportedInvoiceError: el documento no es una factura de luz o de gas, o es una factura rectificativa o de abono (no soportadas).
    • InvoiceParseError (con el atributo field): falta algún dato obligatorio o no tiene el formato esperado.
  • check_consistency(invoice) devuelve una lista de Problem; vacía si todo cuadra.
  • invoice.energy_price_kwh es el precio de la energía en €/kWh, o None si la factura no lo indica.

Publicar

El workflow .github/workflows/lib-release.yml construye y publica en PyPI al subir una etiqueta pycurenergia-v* (por ejemplo pycurenergia-v0.1.0), usando trusted publishing (sin tokens).

Paso manual previo, una sola vez:

  1. Crear la cuenta en PyPI.
  2. En PyPI, añadir un pending trusted publisher con estos datos:
    • Proyecto: pycurenergia
    • Owner: yuuues
    • Repositorio: hacs-curenergia
    • Workflow: lib-release.yml
    • Entorno: pypi
  3. Crear el entorno pypi en los ajustes del repositorio de GitHub y configurar en él required reviewers (revisores obligatorios), de modo que subir una etiqueta por sí solo no publique nada sin una aprobación manual.
  4. Etiquetar y subir: git tag pycurenergia-v0.1.0 && git push origin pycurenergia-v0.1.0.

Metadata

Release files for pycurenergia 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pycurenergia 0.1.0
File Size Uploaded Provenance Actions
pycurenergia-0.1.0.tar.gz 51.0 kB With provenance Details for pycurenergia-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pycurenergia 0.1.0
File Interpreter ABI Platform Actions
pycurenergia-0.1.0-py3-none-any.whl Python 3 none any Details for pycurenergia-0.1.0-py3-none-any.whl

Total release size: 66.1 kB

Release files / pycurenergia-0.1.0.tar.gz

Download URL pycurenergia-0.1.0.tar.gz
Size 51.0 kB
Tags Source
SHA-256 checksum
How to use checksums
90f3389cf9ef0ffcdc6e9f3b94954d432b4e5cae3bd8ee600164123e3d638169
BLAKE2b-256 checksum
How to use checksums
370e3eb5556eb9150bcf83e694e441abdf42156f7a3c97bc15fb773be0f9cc7d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 29, 2026.

Transparency log

Release files / pycurenergia-0.1.0-py3-none-any.whl

Download URL pycurenergia-0.1.0-py3-none-any.whl
Size 15.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6555c6ff43f605030d85729517d59d517b3db78e4cf0ced3a16d0319a029613b
BLAKE2b-256 checksum
How to use checksums
c6eefa0e5e6530bc77934a38bd81dbcb2fa38f6a73c8c8b9d76addc1d2b8b189
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 29, 2026.

Transparency log

Security for pycurenergia 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for pycurenergia-0.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 29, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page