Skip to main content

Train ticket barcode to json decoding library, using zxing-cpp decoding in combination with record interpreter, to transform content into json structure

Project description

ticket_decoder

Optional arguments for instance creation of DecoderFacade.

  • uic_public_key_xml_file = "cert/UIC_PublicKeys.xml"
    Relative path to the XML file containing UIC public keys you can obtain here: https://railpublickey.uic.org/ .
  • vdv_certificate_ldif_file = "cert/VDV_Certificates.ldif"
    Relative path to the LDIF file containing VDV certificates to decrypt VDV barcode content.
  • fail_on_decoder_error = false
    Fail when the aztec/barcode decoder gets an error if true or deliver an empty result when false.
  • fail_on_interpreter_error = true
    Fail when the interpretation of the data gets an error if true or deliver an empty result when false.

Provided python API is in an early state and the class DecoderFacade supports 3 methods right now only.

  • decode_bytes('...')

  • decode_base64('...') is considered for the use case you decode the raw data from aztec-code in advance via zxing-cpp or other aztec-code-decoding library of your choice and you want to decode raw train ticket barcode data to json only. In this case, be careful with the output of the decoder to avoid string encodings like UTF8 or other multi-byte encodings. Ideally try to get access to the raw byte array and just encode those bytes to base64 before passing it to the method. If your aztec-code-decoder provides a string-type only and you are able to pass a character-encoding option, try using 'ISO 8859-1' and cast the result string to raw bytes.

  • decode_files('...') detects and decodes aztec-codes from file or directories (PDF, image) and decodes barcode data to json. This is using zxing-cpp internally. It returns an array of tuples (input-path and json-result) of size x, while x is the amount of aztec-codes found on input. An image can contain always multiple barcodes, the the return value is alway a mapping of origin to content.

Example decoding directly from PDF or image

from ticket_decoder import DecoderFacade

decoder_facade = DecoderFacade(fail_on_interpreter_error = False)
for result in decoder_facade.decode_files('path/2/your/ticket.pdf'):
   print(result[1])

Decoding Aztec-Code in advance using zxingcpp on Python side

from ticket_decoder import DecoderFacade
from zxingcpp import read_barcodes
from cv2 import imread

image = imread('path/2/your/ticket.jpg')

barcodes = read_barcodes(image)
if not barcodes:
    print("No barcodes found")
    exit(1)

decoder_facade = DecoderFacade(\
    fail_on_interpreter_error = False,\
    uic_public_key_xml_file = "cert/UIC_PublicKeys.xml",\
    vdv_certificate_ldif_file = "cert/VDV_Certificates.ldif")

print(decoder_facade.decode_bytes(barcodes[0].bytes))

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ticket_decoder-0.19.1.tar.gz (1.7 MB view details)

Uploaded Source

Built Distributions

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

ticket_decoder-0.19.1-cp314-cp314-manylinux_2_34_x86_64.whl (10.5 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.34+ x86-64

ticket_decoder-0.19.1-cp314-cp314-manylinux_2_34_aarch64.whl (9.4 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.34+ ARM64

ticket_decoder-0.19.1-cp314-cp314-macosx_11_0_arm64.whl (7.4 MB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

ticket_decoder-0.19.1-cp313-cp313-manylinux_2_34_x86_64.whl (10.5 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.34+ x86-64

ticket_decoder-0.19.1-cp313-cp313-manylinux_2_34_aarch64.whl (9.4 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.34+ ARM64

ticket_decoder-0.19.1-cp313-cp313-macosx_11_0_arm64.whl (7.4 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

File details

Details for the file ticket_decoder-0.19.1.tar.gz.

File metadata

  • Download URL: ticket_decoder-0.19.1.tar.gz
  • Upload date:
  • Size: 1.7 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for ticket_decoder-0.19.1.tar.gz
Algorithm Hash digest
SHA256 17b9b6663cdfe892f3a0a48eb7c6e27b141502cc35fb81975fa8513ea3acca80
MD5 b296816bcbb6bd107cef0d68793473bd
BLAKE2b-256 091509908336c3da5ceb2d06ded186a1da4cebd3ae17f34c8d47825219c4f3fb

See more details on using hashes here.

Provenance

The following attestation bundles were made for ticket_decoder-0.19.1.tar.gz:

Publisher: pypi.yml on user4223/ticket-decoder

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ticket_decoder-0.19.1-cp314-cp314-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for ticket_decoder-0.19.1-cp314-cp314-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 1713b50c21a30f1d3ee1ea3cbfc6d8b7a78114fd70ca285696cd076dc364ec6d
MD5 a6e3b5cd6a2b31072f65ce5e35a0d683
BLAKE2b-256 9d9de8d03edac28464ec5c0d88ae6a9a6ebb3e36c5f07bfc9104ddb26116a437

See more details on using hashes here.

Provenance

The following attestation bundles were made for ticket_decoder-0.19.1-cp314-cp314-manylinux_2_34_x86_64.whl:

Publisher: pypi.yml on user4223/ticket-decoder

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ticket_decoder-0.19.1-cp314-cp314-manylinux_2_34_aarch64.whl.

File metadata

File hashes

Hashes for ticket_decoder-0.19.1-cp314-cp314-manylinux_2_34_aarch64.whl
Algorithm Hash digest
SHA256 8ac023b898af2580f947e1fb9ab658cd2f2a45ecc94843511ed62fef419f38f0
MD5 0ae3e2c2354bebe7585fb96f1ab53308
BLAKE2b-256 e142abf44c8af733a60cdd56185c62ad0ffee0a5ff45815e11307fd9eb5e5648

See more details on using hashes here.

Provenance

The following attestation bundles were made for ticket_decoder-0.19.1-cp314-cp314-manylinux_2_34_aarch64.whl:

Publisher: pypi.yml on user4223/ticket-decoder

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ticket_decoder-0.19.1-cp314-cp314-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for ticket_decoder-0.19.1-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ab9e9bc41489a01a0df5fc6f3a1eb7fcdbef515bcdbaedb7e5f7f039de370e46
MD5 9a5980da757a99eec337ffcb7e8fac2f
BLAKE2b-256 2ee9863518ce995ad638c2f968af6c69f92d9fe2d5413c160ff2fa8eb742510d

See more details on using hashes here.

Provenance

The following attestation bundles were made for ticket_decoder-0.19.1-cp314-cp314-macosx_11_0_arm64.whl:

Publisher: pypi.yml on user4223/ticket-decoder

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ticket_decoder-0.19.1-cp313-cp313-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for ticket_decoder-0.19.1-cp313-cp313-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 f31029677092e20111079bc8f8f7d8fe7f7d7e02b1e98642e786cda02eca93b8
MD5 18331e2055aaf72ce74e99d519833693
BLAKE2b-256 b7134cd1d2596a53a2149221759de161509b3ad27dbec713bbc4ae3b87666f6c

See more details on using hashes here.

Provenance

The following attestation bundles were made for ticket_decoder-0.19.1-cp313-cp313-manylinux_2_34_x86_64.whl:

Publisher: pypi.yml on user4223/ticket-decoder

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ticket_decoder-0.19.1-cp313-cp313-manylinux_2_34_aarch64.whl.

File metadata

File hashes

Hashes for ticket_decoder-0.19.1-cp313-cp313-manylinux_2_34_aarch64.whl
Algorithm Hash digest
SHA256 160a7908174a5c083a36383a67815eb86f984677977b2c2cb23a06b7139b033e
MD5 b138c60f514eb76b4766004468e2201a
BLAKE2b-256 b75a3c19d45f1270f5953d9f54ce3f13633787c79844c814497d3d78c79ae2b4

See more details on using hashes here.

Provenance

The following attestation bundles were made for ticket_decoder-0.19.1-cp313-cp313-manylinux_2_34_aarch64.whl:

Publisher: pypi.yml on user4223/ticket-decoder

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ticket_decoder-0.19.1-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for ticket_decoder-0.19.1-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b308b4a624282984f4d41745500721ccff17415f67df0de8822fd5779132734b
MD5 252c366c6cf5570dbd9247be640a6055
BLAKE2b-256 3437ad5d3e577515f9fe874fe79fc2f8de582c3e1dd3a045b04dac0a5a6ad4e4

See more details on using hashes here.

Provenance

The following attestation bundles were made for ticket_decoder-0.19.1-cp313-cp313-macosx_11_0_arm64.whl:

Publisher: pypi.yml on user4223/ticket-decoder

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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