File tree Expand file tree Collapse file tree 9 files changed +392
-6
lines changed
Expand file tree Collapse file tree 9 files changed +392
-6
lines changed Original file line number Diff line number Diff line change 2727 cache : pip
2828 cache-dependency-path : |
2929 pyproject.toml
30+ - name : Install system dependencies (Linux)
31+ if : runner.os == 'Linux'
32+ run : sudo apt-get update && sudo apt-get install -y libzbar0 libcairo2-dev
33+ - name : Install system dependencies (macOS)
34+ if : runner.os == 'macOS'
35+ run : brew install zbar cairo
36+ - name : Install system dependencies (Windows)
37+ if : runner.os == 'Windows'
38+ run : choco install zbar
3039 - name : Install test dependency
3140 run : pip install tox
3241 - name : Run tests
Original file line number Diff line number Diff line change 77from __future__ import annotations
88
99# Addon guard patterns
10+ ADDON_QUIET_ZONE = "000000000" # 9-module separator between main code and addon (GS1 spec)
1011ADDON_START = "1011" # Start guard for addon
1112ADDON_SEPARATOR = "01" # Separator between addon digits
1213
Original file line number Diff line number Diff line change 22
33from barcode .charsets .addons import ADDON2_PARITY
44from barcode .charsets .addons import ADDON5_PARITY
5+ from barcode .charsets .addons import ADDON_QUIET_ZONE
56from barcode .charsets .addons import ADDON_SEPARATOR
67from barcode .charsets .addons import ADDON_START
78
6465__all__ = [
6566 "ADDON2_PARITY" ,
6667 "ADDON5_PARITY" ,
68+ "ADDON_QUIET_ZONE" ,
6769 "ADDON_SEPARATOR" ,
6870 "ADDON_START" ,
6971 "CODES" ,
Original file line number Diff line number Diff line change 33from barcode .charsets .addons import ADDON2_PARITY
44from barcode .charsets .addons import ADDON5_PARITY
55from barcode .charsets .addons import ADDON_CODES
6+ from barcode .charsets .addons import ADDON_QUIET_ZONE
67from barcode .charsets .addons import ADDON_SEPARATOR
78from barcode .charsets .addons import ADDON_START
89
4041 "ADDON2_PARITY" ,
4142 "ADDON5_PARITY" ,
4243 "ADDON_CODES" ,
44+ "ADDON_QUIET_ZONE" ,
4345 "ADDON_SEPARATOR" ,
4446 "ADDON_START" ,
4547 "CODES" ,
Original file line number Diff line number Diff line change @@ -146,14 +146,20 @@ def build(self) -> list[str]:
146146 def _build_addon (self ) -> str :
147147 """Builds the addon barcode pattern (EAN-2 or EAN-5).
148148
149- :returns: The addon pattern as string
149+ :returns: The addon pattern as string (including quiet zone separator)
150150 """
151151 if not self .addon :
152152 return ""
153153
154+ # Add quiet zone (9 modules) before addon per GS1 specification
155+ code = _ean .ADDON_QUIET_ZONE
156+
154157 if len (self .addon ) == 2 :
155- return self ._build_addon2 ()
156- return self ._build_addon5 ()
158+ code += self ._build_addon2 ()
159+ else :
160+ code += self ._build_addon5 ()
161+
162+ return code
157163
158164 def _build_addon2 (self ) -> str :
159165 """Builds EAN-2 addon pattern.
Original file line number Diff line number Diff line change @@ -128,14 +128,20 @@ def build(self) -> list[str]:
128128 def _build_addon (self ) -> str :
129129 """Builds the addon barcode pattern (EAN-2 or EAN-5).
130130
131- :returns: The addon pattern as string
131+ :returns: The addon pattern as string (including quiet zone separator)
132132 """
133133 if not self .addon :
134134 return ""
135135
136+ # Add quiet zone (9 modules) before addon per GS1 specification
137+ code = _upc .ADDON_QUIET_ZONE
138+
136139 if len (self .addon ) == 2 :
137- return self ._build_addon2 ()
138- return self ._build_addon5 ()
140+ code += self ._build_addon2 ()
141+ else :
142+ code += self ._build_addon5 ()
143+
144+ return code
139145
140146 def _build_addon2 (self ) -> str :
141147 """Builds EAN-2 addon pattern.
Original file line number Diff line number Diff line change 99 book prices.
1010* Added support for EAN-2 and EAN-5 addons to UPC-A barcodes via the ``addon ``
1111 parameter, following the same interface as EAN-13.
12+ * Addon rendering includes a 9-module quiet zone separator between the
13+ main barcode and the addon, as required by the GS1 specification. This ensures
14+ proper scanning of barcodes with addons.
15+ * Added scannability tests for EAN-2 and EAN-5 addons using the ``pyzbar `` library.
1216* Fixed ISSN to accept full EAN-13 format (13 digits starting with 977) and
1317 preserve digits 11-12 (sequence variant) instead of always replacing them
1418 with "00".
You can’t perform that action at this time.
0 commit comments