-
-
Notifications
You must be signed in to change notification settings - Fork 134
Expand file tree
/
Copy pathaddons.py
More file actions
63 lines (56 loc) · 1.27 KB
/
addons.py
File metadata and controls
63 lines (56 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
"""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
)