-
-
Notifications
You must be signed in to change notification settings - Fork 135
Add EAN addons support (fixes #140) #255
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
dekoza
wants to merge
13
commits into
WhyNotHugo:main
Choose a base branch
from
dekoza:ean_addons_support
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 4 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
425120a
Fix ISSN - don't throw out digits 11 and 12 when using EAN13 form as …
dekoza d10c26f
Add EAN-2 and EAN-5 addon support for barcodes based on EAN-13 and EA…
dekoza cc7d103
Add EAN-2 and EAN-5 addon support for UPC-A (EAN-12) barcodes as per …
dekoza f59619f
Add scannability (image correctness) tests to ensure proper addon ren…
dekoza fcc4a10
Update docs/getting-started.rst
dekoza f718168
Update barcode/charsets/ean.py
dekoza cec724b
Fix too opinionated validation of ISBN-13 code starting with 979
dekoza 55a0b27
Refactor duplicated code to a helper module.
dekoza de552c3
Adjust addon rendering
dekoza 6364ab6
Update barcode/writer.py
dekoza 43a053e
Mention in docs that UPC-A also supports addons
dekoza ea4a6b4
Fix marker position of marker in 'get_fullcode()' for guarded codes
dekoza 9b844ee
Fix guard marker for eans with and without addons; fix addon renderin…
dekoza File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,6 +9,7 @@ | |
| *.kpf | ||
| *.svg | ||
| *.db | ||
| .coverage | ||
| .idea/* | ||
| barcode/__pycache* | ||
| build/* | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| """Common addon patterns for EAN-2 and EAN-5 supplemental barcodes. | ||
|
|
||
| These patterns are shared by EAN-13, EAN-8, UPC-A, and related barcode types. | ||
| Based on GS1/ISO standard. | ||
| """ | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| # Addon guard patterns | ||
| ADDON_QUIET_ZONE = "000000000" # 9-module separator between main code and addon (GS1 spec) | ||
| ADDON_START = "1011" # Start guard for addon | ||
| ADDON_SEPARATOR = "01" # Separator between addon digits | ||
|
|
||
| # Addon digit encoding (uses A and B parity patterns) | ||
| ADDON_CODES = { | ||
| "A": ( | ||
| "0001101", | ||
| "0011001", | ||
| "0010011", | ||
| "0111101", | ||
| "0100011", | ||
| "0110001", | ||
| "0101111", | ||
| "0111011", | ||
| "0110111", | ||
| "0001011", | ||
| ), | ||
| "B": ( | ||
| "0100111", | ||
| "0110011", | ||
| "0011011", | ||
| "0100001", | ||
| "0011101", | ||
| "0111001", | ||
| "0000101", | ||
| "0010001", | ||
| "0001001", | ||
| "0010111", | ||
| ), | ||
| } | ||
|
|
||
| # EAN-2 parity patterns: determined by value mod 4 | ||
| ADDON2_PARITY = ( | ||
| "AA", # 0 | ||
| "AB", # 1 | ||
| "BA", # 2 | ||
| "BB", # 3 | ||
| ) | ||
|
|
||
| # EAN-5 parity patterns: determined by checksum | ||
| ADDON5_PARITY = ( | ||
| "BBAAA", # 0 | ||
| "BABAA", # 1 | ||
| "BAABA", # 2 | ||
| "BAAAB", # 3 | ||
| "ABBAA", # 4 | ||
| "AABBA", # 5 | ||
| "AAABB", # 6 | ||
| "ABABA", # 7 | ||
| "ABAAB", # 8 | ||
| "AABAB", # 9 | ||
| ) | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.