mirror of
https://github.com/python-escpos/python-escpos
synced 2025-09-13 09:09:58 +00:00
Feature/check barcodes (#255)
* add a method to check barcode code format ensure that the code to print is compatible with the ESC/POS formats and also automatically check this format before printing (barcode() method). * rewrite test using pytest's parametrize functionality * add test for the 'check' argument * update authors list
This commit is contained in:

committed by
Patrick Kanzler

parent
d78a6f1699
commit
456f5b7aa6
@@ -225,6 +225,24 @@ BARCODE_TYPE_B = {
|
||||
'GS1 DATABAR EXPANDED': _SET_BARCODE_TYPE(78),
|
||||
}
|
||||
|
||||
BARCODE_FORMATS = {
|
||||
'UPC-A': ([(11, 12)], "^[0-9]{11,12}$"),
|
||||
'UPC-E': ([(7, 8), (11, 12)], "^([0-9]{7,8}|[0-9]{11,12})$"),
|
||||
'EAN13': ([(12, 13)], "^[0-9]{12,13}$"),
|
||||
'EAN8': ([(7, 8)], "^[0-9]{7,8}$"),
|
||||
'CODE39': ([(1, 255)], "^([0-9A-Z \$\%\+\-\.\/]+|\*[0-9A-Z \$\%\+\-\.\/]+\*)$"),
|
||||
'ITF': ([(2, 255)], "^([0-9]{2})+$"),
|
||||
'NW7': ([(1, 255)], "^[A-Da-d][0-9\$\+\-\.\/\:]+[A-Da-d]$"),
|
||||
'CODABAR': ([(1, 255)], "^[A-Da-d][0-9\$\+\-\.\/\:]+[A-Da-d]$"), # Same as NW7
|
||||
'CODE93': ([(1, 255)], "^[\\x00-\\x7F]+$"),
|
||||
'CODE128': ([(2, 255)], "^\{[A-C][\\x00-\\x7F]+$"),
|
||||
'GS1-128': ([(2, 255)], "^\{[A-C][\\x00-\\x7F]+$"), # same as CODE128
|
||||
'GS1 DATABAR OMNIDIRECTIONAL': ([(13,13)], "^[0-9]{13}$"),
|
||||
'GS1 DATABAR TRUNCATED': ([(13,13)], "^[0-9]{13}$"), # same as GS1 omnidirectional
|
||||
'GS1 DATABAR LIMITED': ([(13,13)], "^[01][0-9]{12}$"),
|
||||
'GS1 DATABAR EXPANDED': ([(2,255)], "^\([0-9][A-Za-z0-9 \!\"\%\&\'\(\)\*\+\,\-\.\/\:\;\<\=\>\?\_\{]+$"),
|
||||
}
|
||||
|
||||
BARCODE_TYPES = {
|
||||
'A': BARCODE_TYPE_A,
|
||||
'B': BARCODE_TYPE_B,
|
||||
|
Reference in New Issue
Block a user