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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
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 ticket_decoder-0.18-cp314-cp314-macosx_11_0_arm64.whl.
File metadata
- Download URL: ticket_decoder-0.18-cp314-cp314-macosx_11_0_arm64.whl
- Upload date:
- Size: 8.4 MB
- Tags: CPython 3.14, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c9d34897503ee728c91c3b9d8890efdc528198b8f707403d9ee4e965678c9ccc
|
|
| MD5 |
31c8a99e6b0a6daffbf5282da6e58a48
|
|
| BLAKE2b-256 |
619262f98573528033e3fabc26ed0b33c6ef9596103bda5a6f69a5d88cb43412
|
Provenance
The following attestation bundles were made for ticket_decoder-0.18-cp314-cp314-macosx_11_0_arm64.whl:
Publisher:
pypi.yml on user4223/ticket-decoder
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ticket_decoder-0.18-cp314-cp314-macosx_11_0_arm64.whl -
Subject digest:
c9d34897503ee728c91c3b9d8890efdc528198b8f707403d9ee4e965678c9ccc - Sigstore transparency entry: 1490718771
- Sigstore integration time:
-
Permalink:
user4223/ticket-decoder@5f87ad1a8190f94a77102ff31c1b4519d93ebbd8 -
Branch / Tag:
refs/tags/v0.18.2 - Owner: https://github.com/user4223
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi.yml@5f87ad1a8190f94a77102ff31c1b4519d93ebbd8 -
Trigger Event:
push
-
Statement type:
File details
Details for the file ticket_decoder-0.18-cp313-cp313-macosx_11_0_arm64.whl.
File metadata
- Download URL: ticket_decoder-0.18-cp313-cp313-macosx_11_0_arm64.whl
- Upload date:
- Size: 8.4 MB
- Tags: CPython 3.13, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1dce3bda616e10dcbce51571f2f5c397b5731e33fde791eb84ebadb73df6e3d7
|
|
| MD5 |
4e0aeb20f7674fbd65b8982e09684a31
|
|
| BLAKE2b-256 |
1076a98ca1b2b1b5813edc66cebaa59ecbad6fd50f3960710adf41702f288ad2
|
Provenance
The following attestation bundles were made for ticket_decoder-0.18-cp313-cp313-macosx_11_0_arm64.whl:
Publisher:
pypi.yml on user4223/ticket-decoder
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ticket_decoder-0.18-cp313-cp313-macosx_11_0_arm64.whl -
Subject digest:
1dce3bda616e10dcbce51571f2f5c397b5731e33fde791eb84ebadb73df6e3d7 - Sigstore transparency entry: 1490718677
- Sigstore integration time:
-
Permalink:
user4223/ticket-decoder@5f87ad1a8190f94a77102ff31c1b4519d93ebbd8 -
Branch / Tag:
refs/tags/v0.18.2 - Owner: https://github.com/user4223
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi.yml@5f87ad1a8190f94a77102ff31c1b4519d93ebbd8 -
Trigger Event:
push
-
Statement type: