barkod
GTIN parsing, canonicalisation, match keys and GS1 classification. Written in Rust; this is the Python binding.
pip install barkod
import barkod
barkod.store_form("7350053850019") # '07350053850019' — padded, check digit kept
barkod.store_form("lek") # 'lek' — untouched, never blanked
barkod.key("7350053850019") # GtinKey('07350053850010')
barkod.key("073905259077450") # None — 15 digits is not a GTIN
p = barkod.parse("370245100000000123")
p.is_gtin # False
p.reason # 'too_long'
p.message # 'More than 14 digits — not a GTIN'
p.raw # '370245100000000123' — always kept
The domain
Every function agrees that a GTIN is 8 to 14 digits and differs only on
what it does inside that range. Outside it, store_form hands the input back
untouched and key returns None. A lossy transformation is not a licence to
be more permissive about what counts as a GTIN.
The key is not a GTIN
key() returns a GtinKey, not a str. It has no __str__, so printing one
gives GtinKey('07390525907740') rather than a bare number — a key that leaks
into an export is visibly wrong instead of a plausible fabricated identifier.
Roughly nine in ten keys end in a check digit no product has.
key = barkod.key("7390525907745")
f"{key}" # "GtinKey('07390525907740')"
key.as_key_str() # '07390525907740' — say it out loud
Columns
store_form_many, key_strings and parse_many take a whole column and
release the GIL for the work. They accept whatever the column actually holds —
str, int, float or None.
import polars as pl
df = df.with_columns(
pl.Series("gtin_key", barkod.key_strings(df["gtin"].to_list()))
)
key_strings is named for what it does. It is the one place the type
distinction is deliberately dropped, because a dataframe column needs strings,
so the call site has to say so.
Classify, never reject
An invalid check digit does not mean "not a GTIN". Variable-weight in-store codes and internal PLUs are live products that fail GS1 Mod-10 by design.
g = barkod.parse("02011030000000").gtin
g.check_digit_is_valid # False
g.allocation # 'restricted_circulation_region'
g.measure_field_looks_zeroed # True — a named guess, not a verdict
Full documentation: https://github.com/mommo-codes/barkod
MIT licensed.
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 barkod-0.1.1-cp38-abi3-win_amd64.whl.
File metadata
- Download URL: barkod-0.1.1-cp38-abi3-win_amd64.whl
- Upload date:
- Size: 163.3 kB
- Tags: CPython 3.8+, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ed0649331450b5c3874828cf611b6f72f950d20a28e7884edaaa687865ccdaaf
|
|
| MD5 |
9b3874e83e8fbfeddad48195916a06b3
|
|
| BLAKE2b-256 |
f3b0fce0adf4312fcd60f41bf3c6158fb79d842be42cfc23447715182fe20d87
|
Provenance
The following attestation bundles were made for barkod-0.1.1-cp38-abi3-win_amd64.whl:
Publisher:
release.yml on mommo-codes/barkod
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
barkod-0.1.1-cp38-abi3-win_amd64.whl -
Subject digest:
ed0649331450b5c3874828cf611b6f72f950d20a28e7884edaaa687865ccdaaf - Sigstore transparency entry: 2624022839
- Sigstore integration time:
-
Permalink:
mommo-codes/barkod@2513c91293d2cec0157f4ead62201b1dfe44fbb3 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/mommo-codes
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@2513c91293d2cec0157f4ead62201b1dfe44fbb3 -
Trigger Event:
push
-
Statement type:
File details
Details for the file barkod-0.1.1-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: barkod-0.1.1-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 306.4 kB
- Tags: CPython 3.8+, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9c65b5a2439ea210c1c8051f16f52049cad7906b08b26ed7d3f746df170a8faf
|
|
| MD5 |
21d59072652ad52b3d2992cde171cf7c
|
|
| BLAKE2b-256 |
5904769be0284af0248be6246cc2cce56493c641bd4c47d3e313d75618ae3c68
|
Provenance
The following attestation bundles were made for barkod-0.1.1-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:
Publisher:
release.yml on mommo-codes/barkod
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
barkod-0.1.1-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl -
Subject digest:
9c65b5a2439ea210c1c8051f16f52049cad7906b08b26ed7d3f746df170a8faf - Sigstore transparency entry: 2624022941
- Sigstore integration time:
-
Permalink:
mommo-codes/barkod@2513c91293d2cec0157f4ead62201b1dfe44fbb3 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/mommo-codes
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@2513c91293d2cec0157f4ead62201b1dfe44fbb3 -
Trigger Event:
push
-
Statement type:
File details
Details for the file barkod-0.1.1-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: barkod-0.1.1-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 302.3 kB
- Tags: CPython 3.8+, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0db9edd7c20d6313c4c0d85da70e93dbad9619cfc0c9e1d680e42f240b7ab911
|
|
| MD5 |
6b5f37257bb459de56eb229d9795d7fb
|
|
| BLAKE2b-256 |
acb4dc647fa124a63abc29630f0886a5f75e7547c4960b9821c3a376c6ef1ce0
|
Provenance
The following attestation bundles were made for barkod-0.1.1-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:
Publisher:
release.yml on mommo-codes/barkod
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
barkod-0.1.1-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl -
Subject digest:
0db9edd7c20d6313c4c0d85da70e93dbad9619cfc0c9e1d680e42f240b7ab911 - Sigstore transparency entry: 2655153530
- Sigstore integration time:
-
Permalink:
mommo-codes/barkod@9dcae299773e0ae24f9753a95d36b785063ad9c9 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/mommo-codes
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@9dcae299773e0ae24f9753a95d36b785063ad9c9 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file barkod-0.1.1-cp38-abi3-macosx_11_0_arm64.whl.
File metadata
- Download URL: barkod-0.1.1-cp38-abi3-macosx_11_0_arm64.whl
- Upload date:
- Size: 268.1 kB
- Tags: CPython 3.8+, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0c76bca23836ba2a5bcbefb51c0e280969e1462e3a481d087ac7432d74a49fbc
|
|
| MD5 |
f0e09d5c1ce38c44ddddd4524b984a00
|
|
| BLAKE2b-256 |
a2aa94339ccfd3ace00988e65010dd94a402edebde03f8fa5b13289318b736b6
|
Provenance
The following attestation bundles were made for barkod-0.1.1-cp38-abi3-macosx_11_0_arm64.whl:
Publisher:
release.yml on mommo-codes/barkod
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
barkod-0.1.1-cp38-abi3-macosx_11_0_arm64.whl -
Subject digest:
0c76bca23836ba2a5bcbefb51c0e280969e1462e3a481d087ac7432d74a49fbc - Sigstore transparency entry: 2624022898
- Sigstore integration time:
-
Permalink:
mommo-codes/barkod@2513c91293d2cec0157f4ead62201b1dfe44fbb3 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/mommo-codes
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@2513c91293d2cec0157f4ead62201b1dfe44fbb3 -
Trigger Event:
push
-
Statement type: