From 1ef3c8b1b935901dd133c337031a7300334db424 Mon Sep 17 00:00:00 2001 From: JazzyNico Date: Thu, 30 Dec 2010 09:59:02 +0100 Subject: [PATCH] Extensions. Barcode extension refactoring (see https://code.launchpad.net/~doctormo/inkscape/barcode-refactor). --- share/extensions/Barcode/Base.py | 134 +++-- share/extensions/Barcode/BaseEan.py | 145 ++++++ share/extensions/Barcode/Code128.py | 226 ++++----- share/extensions/Barcode/Code25i.py | 78 +++ share/extensions/Barcode/Code39.py | 182 +++---- share/extensions/Barcode/Code39Ext.py | 84 ++-- share/extensions/Barcode/Code93.py | 164 +++--- share/extensions/Barcode/EAN13.py | 135 ++--- share/extensions/Barcode/EAN5.py | 103 ++-- share/extensions/Barcode/EAN8.py | 116 ++--- share/extensions/Barcode/Makefile.am | 2 + share/extensions/Barcode/RM4CC.py | 232 ++++----- share/extensions/Barcode/UPCA.py | 96 ++-- share/extensions/Barcode/UPCE.py | 227 ++++----- share/extensions/Barcode/__init__.py | 118 ++--- share/extensions/render_barcode.inx | 5 +- share/extensions/render_barcode.py | 6 +- share/extensions/test/render_barcode.data | 500 +++++++++++++++++++ share/extensions/test/render_barcode.test.py | 70 ++- 19 files changed, 1607 insertions(+), 1016 deletions(-) create mode 100644 share/extensions/Barcode/BaseEan.py create mode 100644 share/extensions/Barcode/Code25i.py create mode 100644 share/extensions/test/render_barcode.data diff --git a/share/extensions/Barcode/Base.py b/share/extensions/Barcode/Base.py index 398e877e9..8fee6a996 100644 --- a/share/extensions/Barcode/Base.py +++ b/share/extensions/Barcode/Base.py @@ -1,67 +1,63 @@ -#!/usr/bin/env python -''' -Copyright (C) 2007 Martin Owens - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -''' +# +# Copyright (C) 2010 Martin Owens +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +""" +Base module for rendering barcodes for Inkscape. +""" import itertools import sys from lxml import etree -class Barcode: +(WHITE_BAR, BLACK_BAR, TALL_BAR) = range(3) +TEXT_TEMPLATE = 'font-size:%dpx;text-align:center;text-anchor:middle;' + +class Barcode(object): + """Provide a base class for all barcode renderers""" + name = None + + def error(self, bar, msg): + """Cause an error to be reported""" + sys.stderr.write( + "Error encoding '%s' as %s barcode: %s\n" % (bar, self.name, msg)) + def __init__(self, param={}): - self.document = None - self.x = 0 - self.y = 0 - - if param.has_key('document'): - self.document = param['document'] - if param.has_key('x'): - self.x = param['x'] - if param.has_key('y'): - self.y = param['y'] - - if param.has_key('height'): - self.height = param['height'] - else: - self.height = 30 - - self.text = param['text'] - self.label = self.text - self.string = self.encode( self.text ) + self.document = param.get('document', None) + self.x = int(param.get('x', 0)) + self.y = int(param.get('y', 0)) + self.height = param.get('height', 30) + self.label = param.get('text', None) + self.string = self.encode( self.label ) + if not self.string: return + self.width = len(self.string) self.data = self.graphicalArray(self.string) def generate(self): + """Generate the actual svg from the coding""" svg_uri = u'http://www.w3.org/2000/svg' if not self.string or not self.data: return - - data = self.data; - - # create an SVG document if required - # if not self.document: - # self.document = UNKNOWN - if not self.document: - sys.stderr.write("No document defined to add barcode to\n") - return + return self.error("No document defined") + data = self.data # Collect document ids doc_ids = {} docIdNodes = self.document.xpath('//@id') @@ -81,10 +77,10 @@ class Barcode: barcode = etree.Element('{%s}%s' % (svg_uri,'g')) barcode.set('id', name) barcode.set('style', 'fill: black;') + barcode.set('transform', 'translate(%d,%d)' % (self.x, self.y)) - draw = 1 - wOffset = int(self.x) - id = 1 + bar_offset = 0 + bar_id = 1 for datum in data: # Datum 0 tells us what style of bar is to come next @@ -94,41 +90,41 @@ class Barcode: width = int(datum[1]) * int(style['width']) if style['write']: - # Add height for styles such as EA8 where - # the barcode goes into the text - rect = etree.SubElement(barcode,'{%s}%s' % (svg_uri,'rect')) - rect.set('x', str(wOffset)) + rect.set('x', str(bar_offset)) rect.set('y', str(style['top'])) rect.set('width', str(width)) rect.set('height', str(style['height'])) - rect.set('id', name + '_bar' + str(id)) - wOffset = int(wOffset) + int(width) - id = id + 1 + rect.set('id', "%s_bar%d" % (name, bar_id)) + bar_offset += width + bar_id += 1 - barwidth = wOffset - int(self.x) + bar_width = bar_offset # Add text at the bottom of the barcode text = etree.SubElement(barcode,'{%s}%s' % (svg_uri,'text')) - text.set( 'x', str(int(self.x) + int(barwidth / 2)) ) - text.set( 'y', str(int(self.height) + 10 + int(self.y)) ) - text.set( 'style', 'font-size:' + self.fontSize() + 'px;text-align:center;text-anchor:middle;' ) + text.set( 'x', str(int(bar_width / 2))) + text.set( 'y', str(self.height + self.fontSize() )) + text.set( 'style', TEXT_TEMPLATE % self.fontSize() ) text.set( '{http://www.w3.org/XML/1998/namespace}space', 'preserve' ) - text.set( 'id', name + '_bottomtext' ) - + text.set( 'id', '%s_text' % name ) text.text = str(self.label) - return barcode - # Converts black and white markers into a space array def graphicalArray(self, code): + """Converts black and white markets into a space array""" return [(x,len(list(y))) for x, y in itertools.groupby(code)] def getStyle(self, index): - result = { 'width' : 1, 'top' : int(self.y), 'write' : False } - if index==1: # Black Bar + """Returns the styles that should be applied to each bar""" + result = { 'width' : 1, 'top' : 0, 'write' : True } + if index == BLACK_BAR: result['height'] = int(self.height) - result['write'] = True + if index == TALL_BAR: + result['height'] = int(self.height) + int(self.fontSize() / 2) + if index == WHITE_BAR: + result['write'] = False return result def fontSize(self): - return '9' + """Return the ideal font size, defaults to 9px""" + return 9 diff --git a/share/extensions/Barcode/BaseEan.py b/share/extensions/Barcode/BaseEan.py new file mode 100644 index 000000000..05c9b1c39 --- /dev/null +++ b/share/extensions/Barcode/BaseEan.py @@ -0,0 +1,145 @@ +# +# Copyright (C) 2010 Martin Owens +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +""" +Some basic common code shared between EAN and UCP generators. +""" + +from Base import Barcode +import sys + +MAPPING = [ + # Left side of barcode Family '0' + [ "0001101", "0011001", "0010011", "0111101", "0100011", + "0110001", "0101111", "0111011", "0110111", "0001011" ], + # Left side of barcode Family '1' and flipped to right side. + [ "0100111", "0110011", "0011011", "0100001", "0011101", + "0111001", "0000101", "0010001", "0001001", "0010111" ], +] +# This chooses which of the two encodings above to use. +FAMILIES = [ '000000', '001011', '001101', '001110', '010011', + '011001', '011100', '010101', '010110', '011010' ] + +GUARD_BAR = '202' +CENTER_BAR = '02020' + +class EanBarcode(Barcode): + """Simple base class for all EAN type barcodes""" + length = None + lengths = None + checks = [] + + def intarray(self, number): + """Convert a string of digits into an array of ints""" + return [ int(i) for i in number ] + + + def encode_interleaved(self, family, number, fams=FAMILIES): + """Encode any side of the barcode, interleaved""" + result = [] + encset = self.intarray(fams[family]) + for i in range(len(number)): + thismap = MAPPING[encset[i]] + result.append( thismap[number[i]] ) + return result + + + def encode_right(self, number): + """Encode the right side of the barcode, non-interleaved""" + result = [] + for n in number: + # The right side is always the reverse of the left's family '1' + result.append( MAPPING[1][n][::-1] ) + return result + + + def encode_left(self, number): + """Encode the left side of the barcode, non-interleaved""" + result = [] + for n in number: + result.append( MAPPING[0][n] ) + return result + + + def space(self, *spacing): + """Space out an array of numbers""" + result = '' + for space in spacing: + if isinstance(space, list): + for i in space: + result += str(i) + elif isinstance(space, int): + result += ' ' * space + return result + + + def getLengths(self): + """Return a list of acceptable lengths""" + if self.length: + return [ self.length ] + return self.lengths[:] + + + def encode(self, code): + """Encode any EAN barcode""" + if not code.isdigit(): + return self.error(code, 'Not a Number, must be digits 0-9 only') + lengths = self.getLengths() + self.checks + + if len(code) not in lengths: + return self.error(code, 'Wrong size, must be %s digits' % + (', '.join(self.space(lengths)))) + + if self.checks: + if len(code) not in self.checks: + code = self.appendChecksum(code) + elif not self.verifyChecksum(code): + return self.error(code, 'Checksum failed, omit for new sum') + return self._encode(self.intarray(code)) + + + def _encode(self, n): + raise NotImplementedError("_encode should be provided by parent EAN") + + def enclose(self, left, right=[], guard=GUARD_BAR, center=CENTER_BAR): + """Standard Enclosure""" + parts = [ guard ] + left + [ center ] + right + [ guard ] + return ''.join( parts ) + + def getChecksum(self, number, magic=10): + """Generate a UPCA/EAN13/EAN8 Checksum""" + weight = [3,1] * len(number) + result = 0 + # We need to work from left to right so reverse + number = number[::-1] + # checksum based on first digits. + for i in range(len(number)): + result += int(number[i]) * weight[i] + # Modulous result to a single digit checksum + checksum = magic - (result % magic) + if checksum < 0 or checksum >= magic: + return '0' + return str(checksum) + + def appendChecksum(self, number): + """Apply the checksum to a short number""" + return number + self.getChecksum(number) + + def verifyChecksum(self, number): + """Verify any checksum""" + return self.getChecksum(number[:-1]) == number[-1] + diff --git a/share/extensions/Barcode/Code128.py b/share/extensions/Barcode/Code128.py index 3cb79b487..3036b5f98 100644 --- a/share/extensions/Barcode/Code128.py +++ b/share/extensions/Barcode/Code128.py @@ -1,27 +1,27 @@ -#!/usr/bin/env python -''' -Copyright (C) 2007 Martin Owens - -Debugged by Ralf Heinecke & Martin Siepmann 09/07/2007 -Debugged by Horst Schottky Feb. 27. 2010 - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - - -''' +# +# Authored by Martin Owens +# Debugged by Ralf Heinecke & Martin Siepmann 2007-09-07 +# Horst Schottky 2010-02-27 +# +# Copyright (C) 2007 Martin Owens +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +""" +Python barcode renderer for Code128/EAN128 barcodes. Designed for use with Inkscape. +""" from Base import Barcode import math @@ -30,13 +30,13 @@ import re map = [ '11011001100','11001101100','11001100110','10010011000','10010001100','10001001100','10011001000','10011000100','10001100100','11001001000','11001000100','11000100100','10110011100','10011011100','10011001110','10111001100','10011101100','10011100110','11001110010','11001011100','11001001110','11011100100','11001110100','11101101110','11101001100','11100101100','11100100110','11101100100','11100110100','11100110010','11011011000','11011000110','11000110110','10100011000','10001011000','10001000110','10110001000','10001101000','10001100010','11010001000','11000101000','11000100010','10110111000','10110001110','10001101110','10111011000','10111000110','10001110110','11101110110','11010001110','11000101110','11011101000','11011100010','11011101110','11101011000','11101000110','11100010110','11101101000','11101100010','11100011010','11101111010','11001000010','11110001010','10100110000','10100001100','10010110000','10010000110','10000101100','10000100110','10110010000','10110000100','10011010000','10011000010','10000110100','10000110010','11000010010','11001010000','11110111010','11000010100','10001111010','10100111100','10010111100','10010011110','10111100100','10011110100','10011110010','11110100100','11110010100','11110010010','11011011110','11011110110','11110110110','10101111000','10100011110','10001011110','10111101000','10111100010','11110101000','11110100010','10111011110','10111101110','11101011110','11110101110','11010000100','11010010000','11010011100','11000111010','11' ] def mapExtra(sd, chars): - result = list(sd) - for char in chars: - result.append(chr(char)) - result.append('FNC3') - result.append('FNC2') - result.append('SHIFT') - return result + result = list(sd) + for char in chars: + result.append(chr(char)) + result.append('FNC3') + result.append('FNC2') + result.append('SHIFT') + return result # The mapExtra method is used to slim down the amount # of pre code and instead we generate the lists @@ -45,86 +45,86 @@ charA = mapExtra(charAB, range(0, 31)) # Offset 64 charB = mapExtra(charAB, range(96, 125)) # Offset -32 class Object(Barcode): - def encode(self, text): - result = '' - blocks = [] - block = '' - - # Split up into sections of numbers, or charicters - # This makes sure that all the charicters are encoded - # In the best way posible for Code128 - for datum in re.findall(r'(?:(?:\d\d){2,})|(?:^\d\d)|.', text): - if len(datum) == 1: - block = block + datum - else: - if block: - blocks.append(self.bestBlock(block)) - block = '' - blocks.append( [ 'C', datum ] ) - - if block: - blocks.append(self.bestBlock(block)) - block = ''; - - self.inclabel = text - return self.encodeBlocks(blocks) - - def bestBlock(self, block): - # If this has lower case then select B over A - if block.upper() == block: - return [ 'A', block ] - return [ 'B', block ] - - def encodeBlocks(self, blocks): - total = 0 - pos = 0 - encode = ''; - - for block in blocks: - set = block[0] - datum = block[1] - - # POS : 0, 1 - # A : 101, 103 - # B : 100, 104 - # C : 99, 105 - num = 0; - if set == 'A': - num = 103 - elif set == 'B': - num = 104 - elif set == 'C': - num = 105 - - i = pos - if pos: - num = 204 - num - else: - i = 1 - - total = total + num * i - encode = encode + map[num] - pos = pos + 1 - - if set == 'A' or set == 'B': - chars = charB - if set == 'A': - chars = charA - - for char in datum: - total = total + (chars.index(char) * pos) - encode = encode + map[chars.index(char)] - pos = pos + 1 - else: - for char in (datum[i:i+2] for i in range(0, len(datum), 2)): - total = total + (int(char) * pos) - encode = encode + map[int(char)] - pos = pos + 1 - - checksum = total % 103 - encode = encode + map[checksum] - encode = encode + map[106] - encode = encode + map[107] - - return encode + def encode(self, text): + result = '' + blocks = [] + block = '' + + # Split up into sections of numbers, or charicters + # This makes sure that all the charicters are encoded + # In the best way posible for Code128 + for datum in re.findall(r'(?:(?:\d\d){2,})|(?:^\d\d)|.', text): + if len(datum) == 1: + block = block + datum + else: + if block: + blocks.append(self.bestBlock(block)) + block = '' + blocks.append( [ 'C', datum ] ) + + if block: + blocks.append(self.bestBlock(block)) + block = ''; + + self.inclabel = text + return self.encodeBlocks(blocks) + + def bestBlock(self, block): + # If this has lower case then select B over A + if block.upper() == block: + return [ 'A', block ] + return [ 'B', block ] + + def encodeBlocks(self, blocks): + total = 0 + pos = 0 + encode = ''; + + for block in blocks: + set = block[0] + datum = block[1] + + # POS : 0, 1 + # A : 101, 103 + # B : 100, 104 + # C : 99, 105 + num = 0; + if set == 'A': + num = 103 + elif set == 'B': + num = 104 + elif set == 'C': + num = 105 + + i = pos + if pos: + num = 204 - num + else: + i = 1 + + total = total + num * i + encode = encode + map[num] + pos = pos + 1 + + if set == 'A' or set == 'B': + chars = charB + if set == 'A': + chars = charA + + for char in datum: + total = total + (chars.index(char) * pos) + encode = encode + map[chars.index(char)] + pos = pos + 1 + else: + for char in (datum[i:i+2] for i in range(0, len(datum), 2)): + total = total + (int(char) * pos) + encode = encode + map[int(char)] + pos = pos + 1 + + checksum = total % 103 + encode = encode + map[checksum] + encode = encode + map[106] + encode = encode + map[107] + + return encode diff --git a/share/extensions/Barcode/Code25i.py b/share/extensions/Barcode/Code25i.py new file mode 100644 index 000000000..518a306f2 --- /dev/null +++ b/share/extensions/Barcode/Code25i.py @@ -0,0 +1,78 @@ +# +# Copyright (C) 2010 Geoffrey Mosini +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +""" +Generate barcodes for Code25-interleaved 2 of 5, for Inkscape. +""" + +from Base import Barcode +import sys + +# 1 means thick, 0 means thin +encoding = { + '0' : '00110', + '1' : '10001', + '2' : '01001', + '3' : '11000', + '4' : '00101', + '5' : '10100', + '6' : '01100', + '7' : '00011', + '8' : '10010', + '9' : '01010', + +} + +# Start and stop code are already encoded into white (0) and black(1) bars +start_code = '1010' +stop_code = '1101' + +class Object(Barcode): + # Convert a text into string binary of black and white markers + def encode(self, number): + self.label = number + + if not number.isdigit(): + sys.stderr.write("CODE25 can only encode numbers.\n") + return + + # Number of figures to encode must be even, a 0 is added to the left in case it's odd. + if len(number) % 2 > 0 : + number = '0' + number + + # Number is encoded by pairs of 2 figures + size = len(number) / 2; + encoded = start_code; + for i in range(size): + # First in the pair is encoded in black (1), second in white (0) + black = encoding[number[i*2]] + white = encoding[number[i*2+1]] + for j in range(5): + if black[j] == '1': + encoded += '11' + else: + encoded += '1' + if white[j] == '1': + encoded += '00' + else: + encoded += '0' + + encoded += stop_code + + self.inclabel = number + return encoded; + diff --git a/share/extensions/Barcode/Code39.py b/share/extensions/Barcode/Code39.py index 78c8521f1..64b22f352 100644 --- a/share/extensions/Barcode/Code39.py +++ b/share/extensions/Barcode/Code39.py @@ -1,101 +1,103 @@ -#!/usr/bin/env python -''' -Copyright (C) 2007 Martin Owens - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -''' +# +# Copyright (C) 2007 Martin Owens +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +""" +Python barcode renderer for Code39 barcodes. Designed for use with Inkscape. +""" from Base import Barcode encoding = { - '0' : '000110100', - '1' : '100100001', - '2' : '001100001', - '3' : '101100000', - '4' : '000110001', - '5' : '100110000', - '6' : '001110000', - '7' : '000100101', - '8' : '100100100', - '9' : '001100100', - 'A' : '100001001', - 'B' : '001001001', - 'C' : '101001000', - 'D' : '000011001', - 'E' : '100011000', - 'F' : '001011000', - 'G' : '000001101', - 'H' : '100001100', - 'I' : '001001100', - 'J' : '000011100', - 'K' : '100000011', - 'L' : '001000011', - 'M' : '101000010', - 'N' : '000010011', - 'O' : '100010010', - 'P' : '001010010', - 'Q' : '000000111', - 'R' : '100000110', - 'S' : '001000110', - 'T' : '000010110', - 'U' : '110000001', - 'V' : '011000001', - 'W' : '111000000', - 'X' : '010010001', - 'Y' : '110010000', - 'Z' : '011010000', - '-' : '010000101', - '*' : '010010100', - '+' : '010001010', - '$' : '010101000', - '%' : '000101010', - '/' : '010100010', - '.' : '110000100', - ' ' : '011000100', + '0' : '000110100', + '1' : '100100001', + '2' : '001100001', + '3' : '101100000', + '4' : '000110001', + '5' : '100110000', + '6' : '001110000', + '7' : '000100101', + '8' : '100100100', + '9' : '001100100', + 'A' : '100001001', + 'B' : '001001001', + 'C' : '101001000', + 'D' : '000011001', + 'E' : '100011000', + 'F' : '001011000', + 'G' : '000001101', + 'H' : '100001100', + 'I' : '001001100', + 'J' : '000011100', + 'K' : '100000011', + 'L' : '001000011', + 'M' : '101000010', + 'N' : '000010011', + 'O' : '100010010', + 'P' : '001010010', + 'Q' : '000000111', + 'R' : '100000110', + 'S' : '001000110', + 'T' : '000010110', + 'U' : '110000001', + 'V' : '011000001', + 'W' : '111000000', + 'X' : '010010001', + 'Y' : '110010000', + 'Z' : '011010000', + '-' : '010000101', + '*' : '010010100', + '+' : '010001010', + '$' : '010101000', + '%' : '000101010', + '/' : '010100010', + '.' : '110000100', + ' ' : '011000100', } class Object(Barcode): - # Convert a text into string binary of black and white markers - def encode(self, text): - text = text.upper() - self.label = text - text = '*' + text + '*' - result = '' - # It isposible for us to encode code39 - # into full ascii, but this feature is - # not enabled here - for char in text: - if not encoding.has_key(char): - char = '-'; + # Convert a text into string binary of black and white markers + def encode(self, text): + text = text.upper() + self.label = text + text = '*' + text + '*' + result = '' + # It isposible for us to encode code39 + # into full ascii, but this feature is + # not enabled here + for char in text: + if not encoding.has_key(char): + char = '-'; - result = result + encoding[char] + '0'; + result = result + encoding[char] + '0'; - # Now we need to encode the code39, best read - # the code to understand what it's up to: - encoded = ''; - colour = '1'; # 1 = Black, 0 = White - for data in result: - if data == '1': - encoded = encoded + colour + colour - else: - encoded = encoded + colour - if colour == '1': - colour = '0' - else: - colour = '1' + # Now we need to encode the code39, best read + # the code to understand what it's up to: + encoded = ''; + colour = '1'; # 1 = Black, 0 = White + for data in result: + if data == '1': + encoded = encoded + colour + colour + else: + encoded = encoded + colour + if colour == '1': + colour = '0' + else: + colour = '1' - self.inclabel = text - return encoded; + self.inclabel = text + return encoded; diff --git a/share/extensions/Barcode/Code39Ext.py b/share/extensions/Barcode/Code39Ext.py index 23c0d6a46..8f1e77826 100644 --- a/share/extensions/Barcode/Code39Ext.py +++ b/share/extensions/Barcode/Code39Ext.py @@ -1,21 +1,23 @@ -#!/usr/bin/env python -''' -Copyright (C) 2007 Martin Owens - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -''' +# +# Copyright (C) 2007 Martin Owens +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +""" +Python barcode renderer for Code39 Extended barcodes. Designed for Inkscape. +""" import Code39 @@ -25,18 +27,18 @@ map = {} i = 0 for char in encode: - map[char] = i - i = i + 1 + map[char] = i + i = i + 1 # Extended encoding maps for full ASCII Code93 def getMap(array): - result = {} - y = 0 - for x in array: - result[chr(x)] = encode[y] - y = y + 1 + result = {} + y = 0 + for x in array: + result[chr(x)] = encode[y] + y = y + 1 - return result; + return result; # MapA is eclectic, but B, C, D are all ASCII ranges mapA = getMap([27,28,29,30,31,59,60,61,62,63,91,92,93,94,95,123,124,125,126,127,0,64,96,127,127,127]) # % @@ -45,19 +47,19 @@ mapC = getMap(range(33, 58)) # / mapD = getMap(range(97, 122)) # + class Object(Code39.Object): - def encode(self, text): - # We are only going to extend the Code39 barcodes - result = '' - for char in text: - if mapA.has_key(char): - char = '%' + mapA[char] - elif mapB.has_key(char): - char = '$' + mapB[char] - elif mapC.has_key(char): - char = '/' + mapC[char] - elif mapD.has_key(char): - char = '+' + mapD[char] - result = result + char - - return Code39.Object.encode(self, result); + def encode(self, text): + # We are only going to extend the Code39 barcodes + result = '' + for char in text: + if mapA.has_key(char): + char = '%' + mapA[char] + elif mapB.has_key(char): + char = '$' + mapB[char] + elif mapC.has_key(char): + char = '/' + mapC[char] + elif mapD.has_key(char): + char = '+' + mapD[char] + result = result + char + + return Code39.Object.encode(self, result); diff --git a/share/extensions/Barcode/Code93.py b/share/extensions/Barcode/Code93.py index 03c31adf1..76cbf683b 100644 --- a/share/extensions/Barcode/Code93.py +++ b/share/extensions/Barcode/Code93.py @@ -1,21 +1,23 @@ -#!/usr/bin/env python -''' -Copyright (C) 2007 Martin Owens - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -''' +# +# Copyright (C) 2007 Martin Owens +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +""" +Python barcode renderer for Code93 barcodes. Designed for use with Inkscape. +""" from Base import Barcode @@ -31,20 +33,20 @@ map = {} i = 0 for char in encode: - map[char] = i - i = i + 1 + map[char] = i + i = i + 1 # Extended encoding maps for full ASCII Code93 def getMap(array): - result = {} - y = 10 + result = {} + y = 10 - for x in array: - result[chr(x)] = encode[y] - y = y + 1 + for x in array: + result[chr(x)] = encode[y] + y = y + 1 - return result; + return result; # MapA is eclectic, but B, C, D are all ASCII ranges mapA = getMap([27,28,29,30,31,59,60,61,62,63,91,92,93,94,95,123,124,125,126,127,0,64,96,127,127,127]) # % @@ -55,65 +57,65 @@ mapD = getMap(range(97, 122)) # + encoding = '100010100 101001000 101000100 101000010 100101000 100100100 100100010 101010000 100010010 100001010 110101000 110100100 110100010 110010100 110010010 110001010 101101000 101100100 101100010 100110100 100011010 101011000 101001100 101000110 100101100 100010110 110110100 110110010 110101100 110100110 110010110 110011010 101101100 101100110 100110110 100111010 100101110 111010100 111010010 111001010 101101110 101110110 110101110 100100110 111011010 111010110 100110010 101011110'.split() class Object(Barcode): - def encode(self, text): - # start marker - bits = self.encode93('MARKER') + def encode(self, text): + # start marker + bits = self.encode93('MARKER') - # Extend to ASCII charset ( return Array ) - text = self.encodeAscii(text) + # Extend to ASCII charset ( return Array ) + text = self.encodeAscii(text) - # Calculate the checksums - text.append(self.checksum(text, 20)) # C - text.append(self.checksum(text, 15)) # K + # Calculate the checksums + text.append(self.checksum(text, 20)) # C + text.append(self.checksum(text, 15)) # K - # Now convert text into the encoding bits (black and white stripes) - for char in text: - bits = bits + self.encode93(char) + # Now convert text into the encoding bits (black and white stripes) + for char in text: + bits = bits + self.encode93(char) - # end marker - bits = bits + self.encode93('MARKER') + # end marker + bits = bits + self.encode93('MARKER') - # termination bar - bits = bits + '1' + # termination bar + bits = bits + '1' - self.inclabel = text - return bits - - def checksum(self, text, mod): - weight = len(text) % mod - check = 0 - for char in text: - check = check + (map[char] * weight) - # Reset the weight is required - weight = weight - 1 - if weight == 0: - weight = mod - - return encode[check % 47] - - # Some charicters need re-encoding into the code93 specification - def encodeAscii(self, text): - result = [] - for char in text: - if map.has_key(char): - result.append(char) - elif mapA.has_key(char): - result.append('(%)') - result.append(mapA[char]) - elif mapB.has_key(char): - result.append('($)') - result.append(mapB[char]) - elif mapC.has_key(char): - result.append('(/)') - result.append(mapC[char]) - elif mapD.has_key(char): - result.append('(+)') - result.append(mapD[char]) - - return result - - def encode93(self, char): - if map.has_key(char): - return encoding[map[char]] - return '' + self.inclabel = text + return bits + + def checksum(self, text, mod): + weight = len(text) % mod + check = 0 + for char in text: + check = check + (map[char] * weight) + # Reset the weight is required + weight = weight - 1 + if weight == 0: + weight = mod + + return encode[check % 47] + + # Some charicters need re-encoding into the code93 specification + def encodeAscii(self, text): + result = [] + for char in text: + if map.has_key(char): + result.append(char) + elif mapA.has_key(char): + result.append('(%)') + result.append(mapA[char]) + elif mapB.has_key(char): + result.append('($)') + result.append(mapB[char]) + elif mapC.has_key(char): + result.append('(/)') + result.append(mapC[char]) + elif mapD.has_key(char): + result.append('(+)') + result.append(mapD[char]) + + return result + + def encode93(self, char): + if map.has_key(char): + return encoding[map[char]] + return '' diff --git a/share/extensions/Barcode/EAN13.py b/share/extensions/Barcode/EAN13.py index a7029d982..41681173b 100644 --- a/share/extensions/Barcode/EAN13.py +++ b/share/extensions/Barcode/EAN13.py @@ -1,101 +1,38 @@ -#!/usr/bin/env python -''' -Copyright (C) 2007 Martin Owens +# +# Copyright (C) 2010 Martin Owens +# +# Thanks to Lineaire Chez of Inkbar ( www.inkbar.lineaire.net ) +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +""" +Python barcode renderer for EAN13 barcodes. Designed for use with Inkscape. +""" + +from BaseEan import EanBarcode + +class Object(EanBarcode): + """Provide an Ean13 barcode generator""" + name = 'ean13' + lengths = [ 12 ] + checks = [ 13 ] + + def _encode(self, n): + """Encode an ean13 barcode""" + self.label = self.space(n[0:1], 4, n[1:7], 5, n[7:], 7) + return self.enclose( + self.encode_interleaved(n[0], n[1:7]), self.encode_right(n[7:]) ) -Thanks to Lineaire Chez of Inkbar ( www.inkbar.lineaire.net ) - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -''' - -from Base import Barcode -import sys - -mapLeftFaimly = [ - [ "0001101","0011001","0010011","0111101","0100011","0110001","0101111","0111011","0110111","0001011" ], - [ "0100111","0110011","0011011","0100001","0011101","0111001","0000101","0010001","0001001","0010111" ], -] -mapRight = [ "1110010","1100110","1101100","1000010","1011100","1001110","1010000","1000100","1001000","1110100" ] -mapFaimly = [ '000000','001011','001101','001110','010011','011001','011100','010101','010110','011010' ] - -guardBar = '202'; -centerBar = '02020'; - -class Object(Barcode): - def encode(self, number): - result = '' - - if len(number) < 12 or len(number) > 13 or not number.isdigit(): - sys.stderr.write("Can not encode '" + number + "' into EAN13 Barcode, Size must be 12 numbers only\n") - return - - if len(number) == 12: - number = number + self.getChecksum(number) - else: - if not self.verifyChecksum(number): - sys.stderr.write("EAN13 Checksum not correct for this barcode, omit last character to generate new checksum.\n") - return - - result = result + guardBar - family = mapFaimly[int(number[0])] - - i = 0 - for i in range(0,6): - mapLeft = mapLeftFaimly[int(family[i])] - result += mapLeft[int(number[i+1])] - - result += centerBar - - for i in range (7,13): - result += mapRight[int(number[i])] - - result = result + guardBar; - - self.label = number[0] + ' ' + number[1:7] + ' ' + number[7:] + ' ' - self.inclabel = self.label - return result; - - def getChecksum(self, number): - # UPCA/EAN13 - weight=[3,1]*6 - magic=10 - sum = 0 - # We need to work from left to right so reverse - number = number[::-1] - # checksum based on first 12 digits. - for i in range(len(number)): - sum = sum + int(number[i]) * weight[i] - - # Mod it down to a single digit - z = ( magic - (sum % magic) ) % magic - if z < 0 or z >= magic: - return 0 - - return str(z) - - def verifyChecksum(self, number): - new = self.getChecksum(number[:-1]) - existing = number[-1] - return new == existing - - def getStyle(self, index): - result = { 'width' : '1', 'top' : int(self.y), 'write' : True } - if index==0: # White Space - result['write'] = False - elif index==1: # Black Bar - result['height'] = int(self.height) - elif index==2: # Guide Bar - result['height'] = int(self.height) + 5 - return result diff --git a/share/extensions/Barcode/EAN5.py b/share/extensions/Barcode/EAN5.py index 8a93b497b..68ff99738 100644 --- a/share/extensions/Barcode/EAN5.py +++ b/share/extensions/Barcode/EAN5.py @@ -1,68 +1,39 @@ -#!/usr/bin/env python -''' -Copyright (C) 2007 Martin Owens -Copyright (C) 2009 Aaron C Spike - -Thanks to Lineaire Chez of Inkbar ( www.inkbar.lineaire.net ) - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -''' - -from Base import Barcode -import sys - -mapLeftFamily = [ - [ "0001101","0011001","0010011","0111101","0100011","0110001","0101111","0111011","0110111","0001011" ], #L - [ "0100111","0110011","0011011","0100001","0011101","0111001","0000101","0010001","0001001","0010111" ], #G -] -mapFamily = [ '11000','10100','10010','10001','01100','00110','00011','01010','01001','00101' ] - -startBar = '01011'; -sepBar = '01'; - -class Object(Barcode): - def encode(self, number): - result = [] - self.x += 110.0 # horizontal offset so it does not overlap EAN13 +# +# Copyright (C) 2009 Aaron C Spike +# 2010 Martin Owens +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +""" +Python barcode renderer for EAN5 barcodes. Designed for use with Inkscape. +""" + +from BaseEan import EanBarcode + +FAMS = [ '11000','10100','10010','10001','01100','00110','00011','01010','01001','00101' ] +START = '01011' + +class Object(EanBarcode): + """Provide an Ean5 barcode generator""" + name = 'ean5' + length = 5 + + def _encode(self, number): + self.x += 110.0 # horiz offset so it does not overlap EAN13 self.y -= self.height + 5 # move the text to the top - if len(number) != 5 or not number.isdigit(): - sys.stderr.write("Can not encode '" + number + "' into EAN5 Barcode, Size must be 5 numbers only\n") - return - - check = self.getChecksum(number) - family = mapFamily[check] - - for i in range(5): - mapLeft = mapLeftFamily[int(family[i])] - result.append(mapLeft[int(number[i])]) - - self.label = number[0] - for i in range(1,5): - self.label += ' ' + number[i] - self.inclabel = self.label - return startBar + '01'.join(result) - - def getChecksum(self, number): - return sum([int(n)*int(m) for n,m in zip(number, '39393')]) % 10 + self.label = ' '.join(self.space(number)) + family = sum([int(n)*int(m) for n,m in zip(number, '39393')]) % 10 + return START + '01'.join(self.encode_interleaved(family, number, FAMS)) - def getStyle(self, index): - result = { 'width' : '1', 'top' : int(self.y) + self.height + 5 + int(self.fontSize()), 'write' : True } - if index==0: # White Space - result['write'] = False - elif index==1: # Black Bar - result['height'] = int(self.height) - elif index==2: # Guide Bar - result['height'] = int(self.height) + 5 - return result diff --git a/share/extensions/Barcode/EAN8.py b/share/extensions/Barcode/EAN8.py index e51cfa93a..05b4d7bb7 100644 --- a/share/extensions/Barcode/EAN8.py +++ b/share/extensions/Barcode/EAN8.py @@ -1,84 +1,34 @@ -#!/usr/bin/env python -''' -Copyright (C) 2007 Martin Owens - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -''' - -from Base import Barcode -import sys - -leftMap = [ '0001101', '0011001', '0010011', '0111101', '0100011', '0110001', '0101111', '0111011', '0110111', '0001011' ] -rightMap = [ '1110010', '1100110', '1101100', '1000010', '1011100', '1001110', '1010000', '1000100', '1001000', '1110100' ] -weightMap = [ 3, 1, 3, 1, 3, 1, 3 ] - -guardBar = '202'; -centerBar = '02020'; - -class Object(Barcode): - def encode(self, number): - result = '' - - # Rejig the label for use - self.label = number[:4] + ' ' + number[4:] - - if len(number) < 7 or len(number) > 8 or not number.isdigit(): - sys.stderr.write("Can not encode '" + number + "' into EAN8 Barcode, Size must be 7 or 8 Numbers only\n") - - if len(number) == 7: - number = number + self.calculateChecksum(number) - - result = result + guardBar - - i = 0 - for num in number: - if i >= 4: - result = result + rightMap[int(num)] - else: - result = result + leftMap[int(num)] - - i = i + 1 - if i == 4: - result = result + centerBar; - - result = result + guardBar; - - self.inclabel = ' ' + number[:4] + ' ' + number[4:] - return result; - - - def calculateChecksum(self, number): - weight = 0; - i = 0; - - for num in number: - weight = weight + (int(num) * weightMap[i]) - i = i + 1 - - weight = 10 - (weight % 10) - if weight == 10: - weight = 0 - return str(weight); - - def getStyle(self, index): - result = { 'width' : '1', 'top' : int(self.y), 'write' : True } - if index==0: # White Space - result['write'] = False - elif index==1: # Black Bar - result['height'] = int(self.height) - elif index==2: # Guide Bar - result['height'] = int(self.height) + 8 - return result +# +# Copyright (C) 2010 Martin Owens +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +""" +Python barcode renderer for EAN8 barcodes. Designed for use with Inkscape. +""" + +from BaseEan import EanBarcode + +class Object(EanBarcode): + """Provide an EAN8 barcode generator""" + name = 'ean8' + lengths = [ 7 ] + checks = [ 8 ] + + def _encode(self, n): + """Encode an ean8 barcode""" + self.label = self.space(n[:4], 3, n[4:]) + return self.enclose( self.encode_left(n[:4]), self.encode_right(n[4:]) ) diff --git a/share/extensions/Barcode/Makefile.am b/share/extensions/Barcode/Makefile.am index fd5f1663b..9ec7f166c 100644 --- a/share/extensions/Barcode/Makefile.am +++ b/share/extensions/Barcode/Makefile.am @@ -3,9 +3,11 @@ barcodedir = $(datadir)/inkscape/extensions/Barcode barcode_SCRIPTS = \ Base.py \ + BaseEan.py \ Code128.py \ Code39Ext.py \ Code39.py \ + Code25i.py \ Code93.py \ EAN13.py \ EAN8.py \ diff --git a/share/extensions/Barcode/RM4CC.py b/share/extensions/Barcode/RM4CC.py index 22902f2e4..d980c6c86 100644 --- a/share/extensions/Barcode/RM4CC.py +++ b/share/extensions/Barcode/RM4CC.py @@ -1,131 +1,135 @@ -#!/usr/bin/env python -''' -Copyright (C) 2007 Martin Owens - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -''' +# +# Copyright (C) 2007 Martin Owens +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +""" +Python barcode renderer for RM4CC barcodes. Designed for use with Inkscape. +""" from Base import Barcode map = { - '(' : '25', - ')' : '3', - '0' : '05053535', - '1' : '05152535', - '2' : '05153525', - '3' : '15052535', - '4' : '15053525', - '5' : '15152525', - '6' : '05251535', - '7' : '05350535', - '8' : '05351525', - '9' : '15250535', - 'A' : '15251525', - 'B' : '15350525', - 'C' : '05253515', - 'D' : '05352515', - 'E' : '05353505', - 'F' : '15252515', - 'G' : '15253505', - 'H' : '15352505', - 'I' : '25051535', - 'J' : '25150535', - 'K' : '25151525', - 'L' : '35050535', - 'M' : '35051525', - 'N' : '35150525', - 'O' : '25053525', - 'P' : '25152515', - 'Q' : '25153505', - 'R' : '35052515', - 'S' : '35053505', - 'T' : '35152505', - 'U' : '25251515', - 'V' : '25350515', - 'W' : '25351505', - 'X' : '35250515', - 'Y' : '35251505', - 'Z' : '35350505', + '(' : '25', + ')' : '3', + '0' : '05053535', + '1' : '05152535', + '2' : '05153525', + '3' : '15052535', + '4' : '15053525', + '5' : '15152525', + '6' : '05251535', + '7' : '05350535', + '8' : '05351525', + '9' : '15250535', + 'A' : '15251525', + 'B' : '15350525', + 'C' : '05253515', + 'D' : '05352515', + 'E' : '05353505', + 'F' : '15252515', + 'G' : '15253505', + 'H' : '15352505', + 'I' : '25051535', + 'J' : '25150535', + 'K' : '25151525', + 'L' : '35050535', + 'M' : '35051525', + 'N' : '35150525', + 'O' : '25053525', + 'P' : '25152515', + 'Q' : '25153505', + 'R' : '35052515', + 'S' : '35053505', + 'T' : '35152505', + 'U' : '25251515', + 'V' : '25350515', + 'W' : '25351505', + 'X' : '35250515', + 'Y' : '35251505', + 'Z' : '35350505', } check = ['ZUVWXY','501234','B6789A','HCDEFG','NIJKLM','TOPQRS'] +(BAR_TRACK, BAR_DOWN, BAR_UP, BAR_FULL, BAR_NONE, WHITE_SPACE) = range(6) class Object(Barcode): - def encode(self, text): - result = '' + def encode(self, text): + result = '' - self.height = 18 - text = text.upper() - text.replace('(', '') - text.replace(')', '') + self.height = 18 + text = text.upper() + text.replace('(', '') + text.replace(')', '') - text = '(' + text + self.checksum(text) + ')' + text = '(' + text + self.checksum(text) + ')' - i = 0 - for char in text: - if map.has_key(char): - result = result + map[char] - - i = i + 1 + i = 0 + for char in text: + if map.has_key(char): + result = result + map[char] + + i = i + 1 - self.inclabel = text - return result; + self.inclabel = text + return result; - # given a string of data, return the check character - def checksum(self, text): - total_lower = 0 - total_upper = 0 - for char in text: - if map.has_key(char): - bars = map[char][0:8:2] - lower = 0 - upper = 0 + # given a string of data, return the check character + def checksum(self, text): + total_lower = 0 + total_upper = 0 + for char in text: + if map.has_key(char): + bars = map[char][0:8:2] + lower = 0 + upper = 0 - if int(bars[0]) & 1: - lower = lower + 4 - if int(bars[1]) & 1: - lower = lower + 2 - if int(bars[2]) & 1: - lower = lower + 1 - if int(bars[0]) & 2: - upper = upper + 4 - if int(bars[1]) & 2: - upper = upper + 2 - if int(bars[2]) & 2: - upper = upper + 1 - total_lower = total_lower + (lower % 6) - total_upper = total_upper + (upper % 6) + if int(bars[0]) & 1: + lower = lower + 4 + if int(bars[1]) & 1: + lower = lower + 2 + if int(bars[2]) & 1: + lower = lower + 1 + if int(bars[0]) & 2: + upper = upper + 4 + if int(bars[1]) & 2: + upper = upper + 2 + if int(bars[2]) & 2: + upper = upper + 1 + total_lower = total_lower + (lower % 6) + total_upper = total_upper + (upper % 6) - total_lower = total_upper % 6 - total_upper = total_upper % 6 - - checkchar = check[total_upper][total_lower] - return checkchar + total_lower = total_upper % 6 + total_upper = total_upper % 6 + + checkchar = check[total_upper][total_lower] + return checkchar - def getStyle(self, index): - result = { 'width' : 2, 'write' : True, 'top' : int(self.y) } - if index==0: # Track Bar - result['top'] = result['top'] + 6 - result['height'] = 5 - elif index==1: # Decender Bar - result['top'] = result['top'] + 6 - result['height'] = 11 - elif index==2: # Accender Bar - result['height'] = 11 - elif index==3: # Full Bar - result['height'] = 17 - elif index==5: # White Space - result['write'] = False - return result + def getStyle(self, index): + """Royal Mail Barcodes use a completely different style""" + result = { 'width' : 2, 'write' : True, 'top' : 0 } + if index == BAR_TRACK: # Track Bar + result['top'] = 6 + result['height'] = 5 + elif index == BAR_DOWN: # Decender Bar + result['top'] = 6 + result['height'] = 11 + elif index == BAR_UP: # Accender Bar + result['height'] = 11 + elif index == BAR_FULL: # Full Bar + result['height'] = 17 + elif index == WHITE_SPACE: # White Space + result['write'] = False + return result diff --git a/share/extensions/Barcode/UPCA.py b/share/extensions/Barcode/UPCA.py index 15d189daa..6ac10943c 100644 --- a/share/extensions/Barcode/UPCA.py +++ b/share/extensions/Barcode/UPCA.py @@ -1,59 +1,37 @@ -#!/usr/bin/env python -''' -Copyright (C) 2007 Martin Owens - -Thanks to Lineaire Chez of Inkbar ( www.inkbar.lineaire.net ) - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -''' - -import EAN13 -from EAN13 import mapLeftFaimly, guardBar, centerBar, mapRight -import sys - -class Object(EAN13.Object): - def encode(self, number): - result = '' - - if len(number) < 11 or len(number) > 12 or not number.isdigit(): - sys.stderr.write("Can not encode '" + number + "' into UPC-A Barcode, Size must be 11 numbers only, and 1 check digit (optional).\n") - return - - if len(number) == 11: - number = number + self.getChecksum(number) - else: - if not self.verifyChecksum(number): - sys.stderr.write("UPC-A Checksum not correct for this barcode, omit last character to generate new checksum.\n") - return - - result = result + guardBar - - i = 0 - for i in range(0,6): - result += mapLeftFaimly[0][int(number[i])] - - result += centerBar - - for i in range (6,12): - result += mapRight[int(number[i])] - - result = result + guardBar; - - self.label = number[0] + ' ' + number[1:6] + ' ' + number[6:11] + ' ' + number[11] - self.inclabel = self.label - return result; - - def fontSize(self): - return '10' +# +# Copyright (C) 2007 Martin Owens +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +""" +Python barcode renderer for UPCA barcodes. Designed for use with Inkscape. +""" + +from BaseEan import EanBarcode + +class Object(EanBarcode): + """Provides a renderer for EAN12 aka UPC-A Barcodes""" + name = 'upca' + lengths = [ 11 ] + checks = [ 12 ] + + def _encode(self, n): + """Encode for a UPC-A Barcode""" + self.label = self.space(n[0:1], 3, n[1:6], 4, n[6:11], 3, n[11:]) + return self.enclose(self.encode_left(n[0:6]), self.encode_right(n[6:12])) + + def fontSize(self): + """We need a bigger barcode""" + return 10 diff --git a/share/extensions/Barcode/UPCE.py b/share/extensions/Barcode/UPCE.py index 2065cfae9..dba5d48ea 100644 --- a/share/extensions/Barcode/UPCE.py +++ b/share/extensions/Barcode/UPCE.py @@ -1,130 +1,103 @@ -#!/usr/bin/env python -''' -Copyright (C) 2007 Martin Owens - -Thanks to Lineaire Chez of Inkbar ( www.inkbar.lineaire.net ) - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -''' - -import EAN13 -from EAN13 import mapLeftFaimly, guardBar, centerBar +# +# Copyright (C) 2010 Martin Owens +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +""" +Python barcode renderer for UPCE barcodes. Designed for use with Inkscape. +""" + +from BaseEan import EanBarcode import sys -mapFamily = [ '000111','001011','001101','001110','010011','011001','011100','010101','010110','011010' ] - -class Object(EAN13.Object): - def encode(self, number): - result = '' - - l = len(number) - - if (l != 6 and l != 7 and l != 11 and l != 12) or not number.isdigit(): - sys.stderr.write("Can not encode '" + number + "' into UPC-E Barcode, Size must be 6 numbers only, and 1 check digit (optional)\nOr a convertable 11 digit UPC-A number with 1 check digit (also optional).\n") - return - - echeck = None - if l==7 or l==12: - echeck = number[-1] - number = number[:-1] - sys.stderr.write("CHECKSUM FOUND!") - l -= 1 - - if l==6: - number = self.ConvertEtoA(number) - - if not echeck: - echeck = self.getChecksum(number) - else: - if not self.verifyChecksum(number + echeck): - sys.stderr.write("UPC-E Checksum not correct for this barcode, omit last character to generate new checksum.\n") - return - - number = self.ConvertAtoE(number) - if not number: - sys.stderr.write("UPC-A code could not be converted into a UPC-E barcode, please follow the UPC guide or enter a 6 digit UPC-E number..\n") - return - - number = number - - result = result + guardBar - # The check digit isn't stored as bars but as a mirroring system. :-( - family = mapFamily[int(echeck)] - - i = 0 - for i in range(0,6): - result += mapLeftFaimly[int(family[i])-1][int(number[i])] - - result = result + centerBar + '2'; - - self.label = '0 ' + number[:6] + ' ' + echeck - self.inclabel = self.label - return result; - - def fontSize(self): - return '10' - - def ConvertAtoE(self, number): - # Converting UPC-A to UPC-E - - # All UPC-E Numbers use number system 0 - if number[0] != '0' or len(number)!=11: - # If not then the code is invalid - return None - - # Most of the conversions deal - # with the specific code parts - manufacturer = number[1:6] - product = number[6:11] - - # There are 4 cases to convert: - if manufacturer[2:] == '000' or manufacturer[2:] == '100' or manufacturer[2:] == '200': - # Maxium number product code digits can be encoded - if product[:2]=='00': - return manufacturer[:2] + product[2:] + manufacturer[2] - elif manufacturer[3:5] == '00': - # Now only 2 product code digits can be used - if product[:3]=='000': - return manufacturer[:3] + product[3:] + '3' - elif manufacturer[4] == '0': - # With even more manufacturer code we have less room for product code - if product[:4]=='0000': - return manufacturer[0:4] + product[4] + '4' - elif product[:4]=='0000' and int(product[4]) > 4: - # The last recorse is to try and squeeze it in the last 5 numbers - # so long as the product is 00005-00009 so as not to conflict with - # the 0-4 used above. - return manufacturer + product[4] - else: - # Invalid UPC-A Numbe - return None - - def ConvertEtoA(self, number): - # Convert UPC-E to UPC-A - - # It's more likly to convert this without fault - # But we still must be mindful of the 4 conversions - if len(number)!=6: - return None - - if number[5]=='0' or number[5]=='1' or number[5]=='2': - return '0' + number[:2] + number[5] + '0000' + number[2:5] - elif number[5]=='3': - return '0' + number[:3] + '00000' + number[3:5] - elif number[5]=='4': - return '0' + number[:4] + '00000' + number[4] - else: - return '0' + number[:5] + '0000' + number[5] +# This is almost exactly the same as the standard FAMILIES +# But flipped around and with the first 111000 instead of 000000. +FAMS = [ '111000', '110100', '110010', '110001', '101100', + '100110', '100011', '101010', '101001', '100101' ] + +class Object(EanBarcode): + """Generate EAN6/UPC-E barcode generator""" + name = 'upce' + lengths = [ 6, 11 ] + checks = [ 7, 12 ] + + def _encode(self, n): + """Generate a UPC-E Barcode""" + self.label = self.space(['0'], 2, n[:6], 2, n[-1]) + code = self.encode_interleaved(n[-1], n[:6], FAMS) + # 202(guard) + code + 020(center) + 202(guard) + return self.enclose(code, center='020') + + def appendChecksum(self, number): + """Generate a UPCE Checksum""" + if len(number) == 6: + number = self.ConvertEtoA(number) + result = self.getChecksum(number) + return self.ConvertAtoE(number) + result + + def fontSize(self): + """We need a font size of 10""" + return 10 + + def ConvertAtoE(self, number): + """Converting UPC-A to UPC-E, may cause errors.""" + # All UPC-E Numbers use number system 0 + if number[0] != '0' or len(number)!=11: + # If not then the code is invalid + return None + + # Most of the conversions deal + # with the specific code parts + manufacturer = number[1:6] + product = number[6:11] + + # There are 4 cases to convert: + if manufacturer[2:] == '000' or manufacturer[2:] == '100' or manufacturer[2:] == '200': + # Maxium number product code digits can be encoded + if product[:2]=='00': + return manufacturer[:2] + product[2:] + manufacturer[2] + elif manufacturer[3:5] == '00': + # Now only 2 product code digits can be used + if product[:3]=='000': + return manufacturer[:3] + product[3:] + '3' + elif manufacturer[4] == '0': + # With even more manufacturer code we have less room for product code + if product[:4]=='0000': + return manufacturer[0:4] + product[4] + '4' + elif product[:4]=='0000' and int(product[4]) > 4: + # The last recorse is to try and squeeze it in the last 5 numbers + # so long as the product is 00005-00009 so as not to conflict with + # the 0-4 used above. + return manufacturer + product[4] + else: + # Invalid UPC-A Numbe + return None + + def ConvertEtoA(self, number): + """Convert UPC-E to UPC-A by padding with zeros""" + # It's more likly to convert this without fault + # But we still must be mindful of the 4 conversions + if len(number) != 6: + return None + + if number[5] in ['0', '1', '2']: + return '0' + number[:2] + number[5] + '0000' + number[2:5] + elif number[5] == '3': + return '0' + number[:3] + '00000' + number[3:5] + elif number[5] == '4': + return '0' + number[:4] + '00000' + number[4] + else: + return '0' + number[:5] + '0000' + number[5] diff --git a/share/extensions/Barcode/__init__.py b/share/extensions/Barcode/__init__.py index 281702c1e..370839f45 100644 --- a/share/extensions/Barcode/__init__.py +++ b/share/extensions/Barcode/__init__.py @@ -1,39 +1,36 @@ -#!/usr/bin/env python -''' -Barcodes SVG Extention +# +# Copyright (C) 2010 Martin Owens +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +""" +Renderer for barcodes, SVG extention for Inkscape. -Supported Barcodes: EAN8, EAN13, Code39, Code39 Extended, Code93, Code128, RM4CC(RM4SCC) +For supported barcodes see Barcode module directory. -Copyright (C) 2007 Martin Owens - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -''' +""" # This lists all known Barcodes missing from this package -# =========== UPC-Based =========== # -# ISBN (EAN13) # ===== UPC-Based Extensions ====== # # Code11 # ========= Code25-Based ========== # -# Code25 # Codabar # Postnet # ITF25 # ========= Alpha-numeric ========= # # Code39Mod -# EAN128 (Code128) # USPS128 # =========== 2D Based ============ # # PDF417 @@ -44,41 +41,44 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA import sys def getBarcode(format, param={}): - if format: - format = str(format).lower() - format = format.replace('-', '') - format = format.replace(' ', '') - if format=='code39': - import Code39 - return Code39.Object(param) - elif format=='code39ext': - import Code39Ext - return Code39Ext.Object(param) - elif format=='code93': - import Code93 - return Code93.Object(param) - elif format=='code128': - import Code128 - return Code128.Object(param) + if format: + format = str(format).lower() + format = format.replace('-', '') + format = format.replace(' ', '') + if format=='code25i': + import Code25i + return Code25i.Object(param) + elif format=='code39': + import Code39 + return Code39.Object(param) + elif format=='code39ext': + import Code39Ext + return Code39Ext.Object(param) + elif format=='code93': + import Code93 + return Code93.Object(param) + elif format=='code128': + import Code128 + return Code128.Object(param) - elif format in ['rm4cc', 'rm4scc']: - import RM4CC - return RM4CC.Object(param) + elif format in ['rm4cc', 'rm4scc']: + import RM4CC + return RM4CC.Object(param) - elif format == 'upca': - import UPCA - return UPCA.Object(param) - elif format == 'upce': - import UPCE - return UPCE.Object(param) - elif format in ['ean13', 'ucc13','jan']: - import EAN13 - return EAN13.Object(param) - elif format == 'ean5': - import EAN5 - return EAN5.Object(param) - elif format in ['ean8', 'ucc8']: - import EAN8 - return EAN8.Object(param) - sys.stderr.write("Invalid format for barcode: " + str(format) + "\n") + elif format == 'upca': + import UPCA + return UPCA.Object(param) + elif format == 'upce': + import UPCE + return UPCE.Object(param) + elif format == 'ean5': + import EAN5 + return EAN5.Object(param) + elif format in ['ean8', 'ucc8']: + import EAN8 + return EAN8.Object(param) + elif format in ['ean13', 'ucc13','jan']: + import EAN13 + return EAN13.Object(param) + sys.stderr.write("Invalid format for barcode: " + str(format) + "\n") diff --git a/share/extensions/render_barcode.inx b/share/extensions/render_barcode.inx index 91dd1bbe4..b511c7557 100644 --- a/share/extensions/render_barcode.inx +++ b/share/extensions/render_barcode.inx @@ -5,13 +5,14 @@ inkex.py render_barcode.py + EAN5 EAN8 EAN13 - EAN5 UPC-A UPC-E + Code25 Interleaved 2 of 5 Code39 - Code39Ext + Code39 Extended Code93 Code128 RM4CC / RM4SCC diff --git a/share/extensions/render_barcode.py b/share/extensions/render_barcode.py index 3de1a07da..ecfe215aa 100644 --- a/share/extensions/render_barcode.py +++ b/share/extensions/render_barcode.py @@ -39,15 +39,15 @@ class InsertBarcode(inkex.Effect): def effect(self): x, y = self.view_center - object = getBarcode( self.options.type, { + bargen = getBarcode( self.options.type, { 'text' : self.options.text, 'height' : self.options.height, 'document' : self.document, 'x' : x, 'y' : y, } ) - if object is not None: - barcode = object.generate() + if bargen is not None: + barcode = bargen.generate() if barcode is not None: self.current_layer.append(barcode) else: diff --git a/share/extensions/test/render_barcode.data b/share/extensions/test/render_barcode.data new file mode 100644 index 000000000..a5052faca --- /dev/null +++ b/share/extensions/test/render_barcode.data @@ -0,0 +1,500 @@ +ean8:9493712:2020001011010001100010110111101020201000100110011011011001100110202 +ean8:2811738:2020010011011011100110010011001020201000100100001010010001011100202 +ean8:2248057:2020010011001001101000110110111020201110010100111010001001010000202 +ean8:0995042:2020001101000101100010110110001020201110010101110011011001110100202 +ean8:0262682:2020001101001001101011110010011020201010000100100011011001010000202 +ean8:2006346:2020010011000110100011010101111020201000010101110010100001000100202 +ean8:9892307:2020001011011011100010110010011020201000010111001010001001010000202 +ean8:7033691:2020111011000110101111010111101020201010000111010011001101000100202 +ean8:6587381:2020101111011000101101110111011020201000010100100011001101010000202 +ean8:4491441:2020100011010001100010110011001020201011100101110011001101000100202 +ean8:0099044:2020001101000110100010110001011020201110010101110010111001001000202 +ean8:7565347:2020111011011000101011110110001020201000010101110010001001000100202 +ean8:0764195:2020001101011101101011110100011020201100110111010010011101011100202 +ean8:4882328:2020100011011011101101110010011020201000010110110010010001110100202 +ean8:4635078:2020100011010111101111010110001020201110010100010010010001000100202 +ean8:8992114:2020110111000101100010110010011020201100110110011010111001101100202 +ean8:6658162:2020101111010111101100010110111020201100110101000011011001001000202 +ean8:7880049:2020111011011011101101110001101020201110010101110011101001010000202 +ean8:7782648:2020111011011101101101110010011020201010000101110010010001110010202 +ean8:8249002:2020110111001001101000110001011020201110010111001011011001000100202 +ean8:8735885:2020110111011101101111010110001020201001000100100010011101001000202 +ean8:9818050:2020001011011011100110010110111020201110010100111011100101110100202 +ean8:3410390:2020111101010001100110010001101020201000010111010011100101010000202 +ean8:9699144:2020001011010111100010110001011020201100110101110010111001101100202 +ean8:7628790:2020111011010111100100110110111020201000100111010011100101110100202 +ean8:2020310:2020010011000110100100110001101020201000010110011011100101001000202 +ean8:0429248:2020001101010001100100110001011020201101100101110010010001000100202 +ean8:3135528:2020111101001100101111010110001020201001110110110010010001001110202 +ean8:3182301:2020111101001100101101110010011020201000010111001011001101101100202 +ean8:0320063:2020001101011110100100110001101020201110010101000010000101010000202 +ean8:0865925:2020001101011011101011110110001020201110100110110010011101001110202 +ean8:3413434:2020111101010001100110010111101020201011100100001010111001011100202 +ean8:6730313:2020101111011101101111010001101020201000010110011010000101000100202 +ean8:4091215:2020100011000110100010110011001020201101100110011010011101001000202 +ean8:6504268:2020101111011000100011010100011020201101100101000010010001000100202 +ean8:0127593:2020001101001100100100110111011020201001110111010010000101000010202 +ean8:9214184:2020001011001001100110010100011020201100110100100010111001100110202 +ean8:4457000:2020100011010001101100010111011020201110010111001011100101101100202 +ean8:2575579:2020010011011000101110110110001020201001110100010011101001011100202 +ean8:3501739:2020111101011000100011010011001020201000100100001011101001011100202 +ean8:0733658:2020001101011101101111010111101020201010000100111010010001011100202 +ean8:6162818:2020101111001100101011110010011020201001000110011010010001101100202 +ean8:2397509:2020010011011110100010110111011020201001110111001011101001001110202 +ean8:3813610:2020111101011011100110010111101020201010000110011011100101001000202 +ean8:9488712:2020001011010001101101110110111020201000100110011011011001110100202 +ean8:1754326:2020011001011101101100010100011020201000010110110010100001101100202 +ean8:5221351:2020110001001001100100110011001020201000010100111011001101110100202 +ean8:6047658:2020101111000110101000110111011020201010000100111010010001010000202 +ean8:0475473:2020001101010001101110110110001020201011100100010010000101101100202 +ean8:0775368:2020001101011101101110110110001020201000010101000010010001001000202 +ean8:5825189:2020110001011011100100110110001020201100110100100011101001001000202 +ean8:9934666:2020001011000101101111010100011020201010000101000010100001110100202 +ean8:4849196:2020100011011011101000110001011020201100110111010010100001110100202 +ean8:6672405:2020101111010111101110110010011020201011100111001010011101010000202 +ean8:6368942:2020101111011110101011110110111020201110100101110011011001010000202 +ean8:0356360:2020001101011110101100010101111020201000010101000011100101100110202 +ean8:1506024:2020011001011000100011010101111020201110010110110010111001101100202 +ean8:0218852:2020001101001001100110010110111020201001000100111011011001101100202 +ean8:4357801:2020100011011110101100010111011020201001000111001011001101010000202 +ean8:8268643:2020110111001001101011110110111020201010000101110010000101000100202 +ean8:0117677:2020001101001100100110010111011020201010000100010010001001000010202 +ean8:8066330:2020110111000110101011110101111020201000010100001011100101110010202 +ean8:3074324:2020111101000110101110110100011020201000010110110010111001000010202 +ean8:7241642:2020111011001001101000110011001020201010000101110011011001010000202 +ean8:3375910:2020111101011110101110110110001020201110100110011011100101011100202 +ean8:5797167:2020110001011101100010110111011020201100110101000010001001011100202 +ean8:4413827:2020100011010001100110010111101020201001000110110010001001100110202 +ean8:0008083:2020001101000110100011010110111020201110010100100010000101001110202 +ean8:3240693:2020111101001001101000110001101020201010000111010010000101100110202 +ean8:3358989:2020111101011110101100010110111020201110100100100011101001000010202 +ean8:2525297:2020010011011000100100110110001020201101100111010010001001101100202 +ean8:9429514:2020001011010001100100110001011020201001110110011010111001010000202 +ean8:7496160:2020111011010001100010110101111020201100110101000011100101000010202 +ean8:2549811:2020010011011000101000110001011020201001000110011011001101110010202 +ean8:0366059:2020001101011110101011110101111020201110010100111011101001100110202 +ean8:7565529:2020111011011000101011110110001020201001110110110011101001000100202 +ean8:0544331:2020001101011000101000110100011020201000010100001011001101011100202 +ean8:5278325:2020110001001001101110110110111020201000010110110010011101001000202 +ean8:9659719:2020001011010111101100010001011020201000100110011011101001011100202 +ean8:6060276:2020101111000110101011110001101020201101100100010010100001000010202 +ean8:9983234:2020001011000101101101110111101020201101100100001010111001010000202 +ean8:9912723:2020001011000101100110010010011020201000100110110010000101000100202 +ean8:3934993:2020111101000101101111010100011020201110100111010010000101011100202 +ean8:9878705:2020001011011011101110110110111020201000100111001010011101110010202 +ean8:6099896:2020101111000110100010110001011020201001000111010010100001001110202 +ean8:9344302:2020001011011110101000110100011020201000010111001011011001110100202 +ean8:5779196:2020110001011101101110110001011020201100110111010010100001001000202 +ean8:2670364:2020010011010111101110110001101020201000010101000010111001110010202 +ean8:4049157:2020100011000110101000110001011020201100110100111010001001001000202 +ean8:6303180:2020101111011110100011010111101020201100110100100011100101001110202 +ean8:4252404:2020100011001001101100010010011020201011100111001010111001001110202 +ean8:6442834:2020101111010001101000110010011020201001000100001010111001001110202 +ean8:7330702:2020111011011110101111010001101020201000100111001011011001110010202 +ean8:6650523:2020101111010111101100010001101020201001110110110010000101001110202 +ean8:3261954:2020111101001001101011110011001020201110100100111010111001010000202 +ean8:1149083:2020011001001100101000110001011020201110010100100010000101001000202 +ean8:1227062:2020011001001001100100110111011020201110010101000011011001110010202 +ean8:7770854:2020111011011101101110110001101020201001000100111010111001110010202 +ean8:4841093:2020100011011011101000110011001020201110010111010010000101110100202 +ean8:9642244:2020001011010111101000110010011020201101100101110010111001100110202 +ean13:082432472648:20201101110010011010001101111010010011010001102020100010011011001010000101110010010001110010202 +ean13:867963203104:20201011110010001000101100001010100001001001102020111001010000101100110111001010111001001110202 +ean13:509274672682:20200011010010111001101101110110100011000010102020100010011011001010000100100011011001110010202 +ean13:137969745319:20201111010111011001011101011110010111001000102020101110010011101000010110011011101001101100202 +ean13:167788639568:20201011110111011001000101101110001001000010102020100001011101001001110101000010010001101100202 +ean13:763909437639:20201011110100001000101101001110001011001110102020100001010001001010000100001011101001110010202 +ean13:552090940230:20201100010011011010011100010110001101001011102020101110011100101101100100001011100101110100202 +ean13:064430020090:20201011110100011010001101111010001101000110102020110110011100101110010111010011100101001000202 +ean13:932131660272:20201111010011011011001101111010110011010111102020101000011100101101100100010011011001001000202 +ean13:697948544222:20200010110010001001011100111010110111011000102020101110010111001101100110110011011001110010202 +ean13:156973387097:20201100010101111001011101110110100001010000102020100100010001001110010111010010001001100110202 +ean13:742353933447:20201000110011011011110101110010111101001011102020100001010000101011100101110010001001001000202 +ean13:165804313397:20201011110110001000100100011010011101010000102020110011010000101000010111010010001001101100202 +ean13:142542648187:20201000110010011011100101000110011011000010102020101110010010001100110100100010001001101100202 +ean13:293746185362:20200010110111101001000100111010101111011001102020100100010011101000010101000011011001011100202 +ean13:079018947306:20201110110001011000110100110010110111000101102020101110010001001000010111001010100001110010202 +ean13:114714603442:20200110010100011001000100110010011101000010102020111001010000101011100101110011011001000100202 +ean13:886864480655:20201101110000101011011100001010011101010001102020100100011100101010000100111010011101011100202 +ean13:087399049352:20201101110111011011110100010110001011000110102020101110011101001000010100111011011001000010202 +ean13:680731212600:20201101110100111001000101000010011001001001102020110011011011001010000111001011100101001000202 +ean13:839853108496:20201111010010111011011101110010100001001100102020111001010010001011100111010010100001001000202 +ean13:759662798861:20201100010010111010111100001010010011001000102020111010010010001001000101000011001101011100202 +ean13:522030126885:20200100110011011010011101111010001101011001102020110110010100001001000100100010011101011100202 +ean13:872252192093:20201110110011011001001101110010011011001100102020111010011011001110010111010010000101011100202 +ean13:978323527315:20201110110001001010000100100110100001011000102020110110010001001000010110011010011101110100202 +ean13:594820728295:20200010110011101000100100100110001101001000102020110110010010001101100111010010011101000100202 +ean13:817309047999:20200110010010001011110101001110010111000110102020101110010001001110100111010011101001011100202 +ean13:529552650589:20200100110010111011100101100010010011000010102020100111011100101001110100100011101001000010202 +ean13:301953031072:20200011010011001001011101110010100001000110102020100001011001101110010100010011011001101100202 +ean13:279759074172:20201110110001011001000101110010001011010011102020100010010111001100110100010011011001011100202 +ean13:966269952443:20201011110000101001101101011110010111000101102020100111011011001011100101110010000101000100202 +ean13:393886491651:20200010110111101000100100010010000101010001102020111010011001101010000100111011001101110100202 +ean13:592818880852:20200010110011011000100100110010110111000100102020100100011100101001000100111011011001110010202 +ean13:629415132010:20200100110010111001110101100110110001001100102020100001011011001110010110011011100101001000202 +ean13:649798154930:20201000110010111001000100101110110111001100102020100111010111001110100100001011100101110100202 +ean13:106475417609:20200011010101111001110101110110111001001110102020110011010001001010000111001011101001110010202 +ean13:853904645292:20201100010100001000101101001110011101010111102020101110010011101101100111010011011001100110202 +ean13:431977667645:20201111010110011000101101110110010001000010102020101000010001001010000101110010011101000010202 +ean13:814819509497:20200110010011101011011101100110010111011000102020111001011101001011100111010010001001000100202 +ean13:308817835364:20200011010110111000100101100110010001011011102020100001010011101000010101000010111001011100202 +ean13:618801393027:20200110010001001000100101001110011001011110102020111010010000101110010110110010001001110010202 +ean13:164480667538:20201011110100011001110101101110100111000010102020101000010001001001110100001010010001011100202 +ean13:081023710137:20201101110011001000110100100110111101011101102020110011011100101100110100001010001001000100202 +ean13:493359422890:20200010110100001011110101100010010111001110102020110110011011001001000111010011100101110010202 +ean13:275532814865:20201110110110001011100101000010010011000100102020110011010111001001000101000010011101001000202 +ean13:111345042302:20200110010011001010000101000110111001010011102020101110011011001000010111001011011001001000202 +ean13:513537464719:20200110010100001011100101111010111011001110102020101000010111001000100110011011101001001110202 +ean13:766449694282:20201011110000101010001100111010001011000010102020111010010111001101100100100011011001110100202 +ean13:961792988802:20201011110110011001000100010110011011000101102020100100010010001001000111001011011001001110202 +ean13:866540005468:20201011110000101011000100111010100111000110102020111001010011101011100101000010010001101100202 +ean13:888983089059:20201101110001001000101100010010100001000110102020100100011101001110010100111011101001100110202 +ean13:722513175727:20200100110011011011000101100110111101011001102020100010010011101000100110110010001001110100202 +ean13:843297735811:20201000110100001001001100101110010001011101102020100001010011101001000110011011001101101100202 +ean13:627233353075:20200100110010001001101101000010111101011110102020100111010000101110010100010010011101110010202 +ean13:203591705672:20200011010111101011100100101110011001001000102020111001010011101010000100010011011001001110202 +ean13:686779501514:20201101110000101001000100100010001011011000102020111001011001101001110110011010111001001110202 +ean13:379483955591:20201110110001011001110100010010100001000101102020100111010011101001110111010011001101101100202 +ean13:576363706332:20201110110000101010000101011110111101001000102020111001010100001000010100001011011001000010202 +ean13:295226681860:20200010110110001001101100110110101111000010102020100100011001101001000101000011100101110100202 +ean13:901443422086:20200011010110011001110101000110100001010001102020110110011011001110010100100010100001000100202 +ean13:093300442985:20200010110111101011110100011010001101010001102020101110011011001110100100100010011101000010202 +ean13:517520551545:20200110010010001011100100100110001101011100102020100111011001101001110101110010011101000010202 +ean13:370982564882:20201110110001101001011100010010011011011000102020101000010111001001000100100011011001110010202 +ean13:640884610730:20201000110100111000100100010010100011010111102020110011011100101000100100001011100101001110202 +ean13:601211133573:20200011010110011001101101100110011001001100102020100001010000101001110100010010000101110100202 +ean13:772390839786:20201110110011011011110100101110001101000100102020100001011101001000100100100010100001110100202 +ean13:037823325554:20201111010111011011011100100110111101011110102020110110010011101001110100111010111001000010202 +ean13:636746415900:20201111010000101001000100111010101111010001102020110011010011101110100111001011100101000100202 +ean13:378365729312:20201110110110111010000100001010111001011101102020110110011101001000010110011011011001110010202 +ean13:588008084415:20201101110001001010011100011010110111010011102020100100010111001011100110011010011101000010202 +ean13:493847586062:20200010110100001011011101000110010001011100102020100100010100001110010101000011011001110010202 +ean13:661725378018:20201011110110011001000100110110110001011110102020100010010010001110010110011010010001110010202 +ean13:785941917380:20201101110111001000101100111010011001001011102020110011010001001000010100100011100101011100202 +ean13:476858945743:20201110110000101011011101100010001001001011102020101110010011101000100101110010000101010000202 +ean13:621022451023:20200100110110011010011100110110010011010001102020100111011001101110010110110010000101001000202 +ean13:738611126276:20201111010001001010111101100110011001011001102020110110010100001101100100010010100001110010202 +ean13:610023637901:20200110010100111010011100110110111101010111102020100001010001001110100111001011001101001000202 +ean13:310432899227:20200110010001101001110101000010011011011011102020111010011101001101100110110010001001110010202 +ean13:079481718507:20201110110001011010001101101110011001011101102020110011010010001001110111001010001001000010202 +ean13:794525704564:20200010110011101011000100110110110001001000102020111001010111001001110101000010111001010000202 +ean13:367079205365:20201011110111011010011100100010010111001001102020111001010011101000010101000010011101100110202 +ean13:791478205064:20200010110110011010001100100010110111001101102020111001010011101110010101000010111001000100202 +ean13:622805103976:20200100110011011000100101001110110001001100102020111001010000101110100100010010100001100110202 +ean13:659692878482:20201100010010111000010100101110010011011011102020100010010010001011100100100011011001011100202 +ean13:312673979722:20200110010010011000010100100010100001000101102020100010011101001000100110110011011001110010202 +ean13:634789369262:20201111010011101001000100010010001011011110102020101000011101001101100101000011011001000100202 +ean13:508031061191:20200011010001001010011101111010011001010011102020101000011001101100110111010011001101000100202 +ean13:617546677352:20200110010010001011100100111010101111010111102020100010010001001000010100111011011001000010202 +ean13:386750842077:20201101110101111001000101110010100111011011102020101110011011001110010100010010001001100110202 +ean13:217930060540:20200110010111011001011101000010001101010011102020101000011100101001110101110011100101100110202 +ean13:529453929533:20200100110010111001110101100010111101001011102020110110011101001001110100001010000101000010202 +ean13:403667633768:20200011010100001010111101011110010001000010102020100001010000101000100101000010010001110100202 +ean13:788401327704:20201101110001001010001101001110011001010000102020110110010001001000100111001010111001000100202 +ean13:316882500762:20200110010101111000100100010010011011011000102020111001011100101000100101000011011001101100202 +ean13:413254666172:20200110010100001001001101100010011101000010102020101000010100001100110100010011011001100110202 +ean13:666719764771:20201011110000101001000101100110001011011101102020101000010111001000100100010011001101100110202 +ean13:502326102133:20200011010011011010000100100110101111011001102020111001011011001100110100001010000101010000202 +ean13:690549661049:20200010110100111011100100111010001011010111102020101000011001101110010101110011101001001110202 +ean13:055572466568:20201100010110001011000101110110010011010001102020101000010100001001110101000010010001110100202 +ean13:636596356068:20201111010000101011100100101110101111011110102020100111010100001110010101000010010001000010202 +upce:844677:202000100100111010011101010111101110110111011020202 +upce:610879:202000010101100110001101011011101110110010111020202 +upce:982526:202001011100010010011011011000100100110101111020202 +upce:846420:202000100100111010101111010001100110110001101020202 +upce:322140:202010000100110110010011001100100111010001101020202 +upce:625042:202000010100100110110001010011101000110011011020202 +upce:996072:202001011100101110101111000110101110110011011020202 +upce:539996:202011100101000010001011000101100010110000101020202 +upce:340168:202010000100111010001101001100100001010110111020202 +upce:841913:202000100101000110100111000101101100110011001020202 +upce:124122:202011001100110110100011001100100110110010011020202 +upce:401968:202001110100011010110011000101101011110001001020202 +upce:225085:202001101100100110111001010011101101110110001020202 +upce:368038:202010000101011110001001010011101111010110111020202 +upce:817155:202000100100110010111011011001101100010111001020202 +upce:554120:202011100101110010100011011001100100110001101020202 +upce:113080:202011001101100110111101000110101101110100111020202 +upce:755380:202001000101100010110001011110100010010100111020202 +upce:201858:202001101100011010110011000100101100010110111020202 +upce:226567:202001101100100110000101011100101011110111011020202 +upce:507089:202011100101001110111011000110101101110010111020202 +upce:442680:202001110101000110011011010111101101110100111020202 +upce:557738:202011100101100010111011001000101000010110111020202 +upce:928720:202001011100100110001001011101100100110100111020202 +upce:395240:202010000100101110110001001101101000110001101020202 +upce:931548:202001011101111010110011011000101000110001001020202 +upce:729228:202001000100100110001011001001100110110001001020202 +upce:116746:202011001100110010000101011101100111010101111020202 +upce:293469:202001101100101110111101010001101011110010111020202 +upce:555569:202011100101100010111001011000100001010001011020202 +upce:786474:202001000100010010000101010001101110110100011020202 +upce:761950:202001000101011110110011000101101100010100111020202 +upce:585584:202011100101101110111001011000100010010100011020202 +upce:929816:202001011100110110001011011011100110010000101020202 +upce:311259:202010000100110010011001001101101110010001011020202 +upce:694531:202000010100101110011101011000101111010011001020202 +upce:375808:202010000100100010110001011011101101110011101020202 +upce:240462:202001101100111010001101010001100001010010011020202 +upce:309270:202010000100011010010111001001100100010001101020202 +upce:531272:202011100101111010110011001001101110110011011020202 +upce:910577:202001011100110010001101011100100100010111011020202 +upce:816561:202000100100110010000101011000100001010011001020202 +upce:805838:202000100100011010110001011011101000010001001020202 +upce:533215:202011100101000010111101001101100110010110001020202 +upce:346122:202010000101000110000101001100100100110011011020202 +upce:625930:202000010100100110110001001011101000010001101020202 +upce:952717:202001011101110010010011001000100110010111011020202 +upce:402896:202001110101001110010011011011100010110000101020202 +upce:295983:202001101100101110110001000101101101110100001020202 +upce:024592:202010011100100110011101011000100010110011011020202 +upce:289724:202001101101101110010111011101100100110011101020202 +upce:252704:202001101101110010011011011101100011010100011020202 +upce:273290:202001101101110110111101001101100010110100111020202 +upce:385633:202010000100010010110001010111101111010100001020202 +upce:549951:202011100100111010001011001011101100010011001020202 +upce:568347:202011100101011110110111010000100111010111011020202 +upce:214740:202001101100110010011101001000101000110001101020202 +upce:969934:202001011101011110010111000101101111010011101020202 +upce:832367:202000100101111010010011010000100001010111011020202 +upce:359222:202010000101100010001011001101100110110010011020202 +upce:508230:202011100101001110001001001001101111010001101020202 +upce:308002:202010000101001110110111010011100011010010011020202 +upce:318751:202010000100110010001001011101101110010011001020202 +upce:174459:202011001100100010011101010001101100010001011020202 +upce:403448:202001110101001110111101010001101000110001001020202 +upce:429459:202001110100100110010111010001101110010001011020202 +upce:271338:202001101100100010110011011110101111010110111020202 +upce:515949:202011100100110010110001001011101000110010111020202 +upce:066186:202010011101011110000101001100100010010101111020202 +upce:609466:202000010100011010001011001110101011110000101020202 +upce:857406:202000100101110010010001010001101011110100011020202 +upce:237382:202001101101111010111011010000101101110011011020202 +upce:260304:202001101100001010001101010000100011010100011020202 +upce:899152:202000100100101110010111001100101100010010011020202 +upce:773424:202001000100100010111101001110100100110100011020202 +upce:367789:202010000101011110111011011101100010010010111020202 +upce:344078:202010000100111010011101000110101110110110111020202 +upce:627031:202000010100100110010001000110101000010011001020202 +upce:146732:202011001100111010101111001000101111010010011020202 +upce:608666:202000010100011010001001000010101011110101111020202 +upce:855228:202000100101110010111001001001100100110110111020202 +upce:439192:202001110101000010010111001100100010110010011020202 +upce:917451:202001011100110010010001010001101110010011001020202 +upce:072613:202010011101110110100111010111100110010011011020202 +upce:813590:202000100100110010100001011000100010110100111020202 +upce:176138:202011001100100010101111001100101000010110111020202 +upce:690945:202000010100101110001101001011101000110110001020202 +upce:849613:202000100100111010001011010111101100110111101020202 +upce:269053:202001101101011110001011000110101110010100001020202 +upce:701050:202001000100011010011001010011101110010001101020202 +upce:074527:202010011101110110011101011000100110110111011020202 +upce:218296:202001101100110010001001001101100010110101111020202 +upce:874938:202000100100100010100011000101101111010001001020202 +upce:023936:202010011100110110111101000101101111010000101020202 +upce:896764:202000100100101110000101011101101011110100011020202 +upce:979612:202001011100100010001011010111101100110010011020202 +upce:137449:202011001101000010010001010001101000110001011020202 +upce:687160:202000010100010010010001001100101011110001101020202 +upce:839620:202000100101111010010111000010100100110001101020202 +upce:921800:202001011100100110110011000100100011010001101020202 +ean5:72823:010110010001010011011010110111010010011010111101 +ean5:19075:010110110011010001011010001101010010001010110001 +ean5:16659:010110011001010000101010101111010111001010001011 +ean5:54239:010110111001010100011010011011010111101010001011 +ean5:70848:010110111011010001101010001001010011101010110111 +ean5:75795:010110010001010110001010111011010001011010111001 +ean5:15726:010110011001010110001010010001010011011010101111 +ean5:58560:010110110001010110111010110001010000101010100111 +ean5:24670:010110011011010100011010101111010111011010100111 +ean5:24946:010110011011010100011010001011010100011010000101 +ean5:69776:010110000101010001011010010001010111011010101111 +ean5:74692:010110010001010100011010101111010010111010010011 +ean5:10925:010110110011010001101010001011010010011010111001 +ean5:63372:010110000101010111101010111101010111011010011011 +ean5:62942:010110101111010010011010010111010011101010010011 +ean5:35265:010110111101010110001010011011010101111010111001 +ean5:38088:010110111101010001001010001101010001001010110111 +ean5:50203:010110111001010100111010010011010001101010111101 +ean5:57111:010110111001010111011010011001010011001010110011 +ean5:64593:010110101111010100011010111001010001011010100001 +ean5:52424:010110110001010010011010011101010011011010100011 +ean5:77259:010110010001010111011010010011010111001010001011 +ean5:07028:010110001101010111011010100111010011011010110111 +ean5:50627:010110111001010001101010101111010011011010111011 +ean5:60414:010110000101010001101010011101010011001010100011 +ean5:86940:010110001001010101111010010111010100011010001101 +ean5:36095:010110111101010101111010100111010001011010111001 +ean5:01124:010110100111010011001010011001010011011010100011 +ean5:57346:010110111001010111011010100001010100011010101111 +ean5:79607:010110010001010001011010000101010001101010111011 +ean5:31184:010110111101010011001010110011010001001010100011 +ean5:29583:010110011011010001011010110001010110111010100001 +ean5:75568:010110111011010110001010111001010101111010001001 +ean5:53258:010110110001010100001010010011010111001010110111 +ean5:78345:010110010001010110111010111101010100011010111001 +ean5:56838:010110110001010000101010001001010111101010110111 +ean5:61031:010110101111010110011010001101010100001010011001 +ean5:98054:010110001011010110111010001101010111001010011101 +ean5:28204:010110010011010110111010010011010100111010011101 +ean5:18738:010110011001010001001010111011010100001010110111 +ean5:17221:010110110011010111011010010011010010011010110011 +ean5:02270:010110001101010011011010010011010010001010001101 +ean5:02378:010110001101010011011010100001010111011010110111 +ean5:15957:010110110011010110001010010111010110001010111011 +ean5:13621:010110011001010111101010000101010010011010110011 +ean5:98891:010110001011010001001010110111010010111010011001 +ean5:50554:010110110001010100111010110001010111001010100011 +ean5:22677:010110010011010010011010101111010010001010010001 +ean5:49420:010110011101010001011010100011010010011010100111 +ean5:57712:010110110001010010001010010001010011001010010011 +ean5:13839:010110011001010100001010110111010111101010010111 +ean5:36422:010110111101010101111010011101010010011010011011 +ean5:10137:010110011001010100111010110011010111101010111011 +ean5:22734:010110010011010011011010010001010111101010100011 +ean5:25562:010110010011010110001010110001010000101010011011 +ean5:49015:010110100011010010111010001101010110011010110001 +ean5:34620:010110100001010100011010000101010010011010001101 +ean5:74909:010110010001010100011010010111010001101010001011 +ean5:57115:010110110001010111011010110011010110011010110001 +ean5:84963:010110001001010011101010001011010101111010111101 +ean5:95948:010110001011010110001010010111010100011010001001 +ean5:36006:010110100001010101111010100111010001101010101111 +ean5:05457:010110100111010110001010100011010110001010010001 +ean5:54806:010110111001010100011010110111010001101010000101 +ean5:32152:010110100001010010011010110011010110001010010011 +ean5:64913:010110101111010100011010010111010011001010100001 +ean5:53560:010110111001010111101010111001010101111010001101 +ean5:57373:010110110001010111011010100001010111011010100001 +ean5:54685:010110110001010100011010101111010001001010111001 +ean5:75408:010110010001010110001010100011010100111010110111 +ean5:56632:010110111001010000101010101111010111101010010011 +ean5:22639:010110010011010010011010101111010100001010010111 +ean5:92955:010110010111010010011010001011010111001010110001 +ean5:75465:010110111011010111001010100011010000101010110001 +ean5:56506:010110111001010101111010110001010100111010101111 +ean5:22627:010110011011010010011010000101010010011010111011 +ean5:98251:010110010111010110111010010011010110001010110011 +ean5:90220:010110010111010001101010011011010010011010001101 +ean5:93426:010110010111010111101010100011010011011010101111 +ean5:74169:010110010001010100011010110011010101111010001011 +ean5:36259:010110100001010101111010011011010110001010001011 +ean5:71855:010110111011010110011010001001010110001010110001 +ean5:04584:010110001101010100011010111001010001001010100011 +ean5:01152:010110100111010011001010011001010110001010011011 +ean5:72757:010110111011010010011010111011010111001010010001 +ean5:28673:010110010011010001001010101111010111011010100001 +ean5:75084:010110010001010111001010001101010110111010100011 +ean5:10562:010110011001010100111010110001010101111010011011 +ean5:63726:010110000101010111101010111011010011011010101111 +ean5:04292:010110001101010100011010011011010001011010011011 +ean5:77513:010110111011010010001010110001010110011010111101 +ean5:17826:010110011001010111011010110111010011011010000101 +ean5:44790:010110011101010011101010111011010001011010001101 +ean5:39572:010110111101010010111010111001010111011010010011 +ean5:55321:010110111001010111001010111101010010011010011001 +ean5:89717:010110110111010001011010111011010110011010010001 +ean5:02126:010110001101010011011010011001010011011010101111 +ean5:30106:010110100001010100111010011001010001101010101111 +ean5:57489:010110110001010111011010011101010110111010010111 +ean5:26505:010110011011010000101010110001010001101010110001 +upca:40710631975:20201000110001101011101100110010001101010111102020100001011001101110100100010010011101100110202 +upca:80176224795:20201101110001101001100101110110101111001001102020110110010111001000100111010010011101100110202 +upca:92748137722:20200010110010011011101101000110110111001100102020100001010001001000100110110011011001010000202 +upca:32450677259:20201111010010011010001101100010001101010111102020100010010001001101100100111011101001110010202 +upca:40851674702:20201000110001101011011101100010011001010111102020100010010111001000100111001011011001001000202 +upca:59115174167:20201100010001011001100100110010110001001100102020100010010111001100110101000010001001100110202 +upca:84003578078:20201101110100011000110100011010111101011000102020100010010010001110010100010010010001001000202 +upca:95062540829:20200010110110001000110101011110010011011000102020101110011100101001000110110011101001010000202 +upca:64901078016:20201011110100011000101100011010011001000110102020100010010010001110010110011010100001110010202 +upca:48432140125:20201000110110111010001101111010010011001100102020101110011100101100110110110010011101010000202 +upca:17430588576:20200110010111011010001101111010001101011000102020100100010010001001110100010010100001001000202 +upca:63153964133:20201011110111101001100101100010111101000101102020101000010111001100110100001010000101010000202 +upca:74093932950:20201110110100011000110100010110111101000101102020100001011011001110100100111011100101001110202 +upca:57541363089:20201100010111011011000101000110011001011110102020101000010000101110010100100011101001000100202 +upca:07377087198:20200011010111011011110101110110111011000110102020100100010001001100110111010010010001110100202 +upca:05635524594:20200011010110001010111101111010110001011000102020110110010111001001110111010010111001001000202 +upca:70318362910:20201110110001101011110100110010110111011110102020101000011011001110100110011011100101011100202 +upca:36925218506:20201111010101111000101100100110110001001001102020110011010010001001110111001010100001001110202 +upca:45343236277:20201000110110001011110101000110111101001001102020100001010100001101100100010010001001110010202 +upca:03926388241:20200011010111101000101100100110101111011110102020100100010010001101100101110011001101101100202 +upca:64192083538:20201011110100011001100100010110010011000110102020100100010000101001110100001010010001100110202 +upca:25525653142:20200100110110001011000100100110110001010111102020100111010000101100110101110011011001110010202 +upca:38104462945:20201111010110111001100100011010100011010001102020101000011011001110100101110010011101001000202 +upca:09225889378:20200011010001011001001100100110110001011011102020100100011101001000010100010010010001000100202 +upca:93748811785:20200010110111101011101101000110110111011011102020110011011001101000100100100010011101001110202 +upca:30467816622:20201111010001101010001101011110111011011011102020110011010100001010000110110011011001110100202 +upca:74931591622:20201110110100011000101101111010011001011000102020111010011001101010000110110011011001000010202 +upca:92475784788:20200010110010011010001101110110110001011101102020100100010111001000100100100010010001110100202 +upca:40454544331:20201000110001101010001101100010100011011000102020101110010111001000010100001011001101000010202 +upca:35237883084:20201111010110001001001101111010111011011011102020100100010000101110010100100010111001100110202 +upca:75646706855:20201110110110001010111101000110101111011101102020111001010100001001000100111010011101000100202 +upca:82889483314:20201101110010011011011101101110001011010001102020100100010000101000010110011010111001101100202 +upca:73893633416:20201110110111101011011100010110111101010111102020100001010000101011100110011010100001001110202 +upca:10454576813:20200110010001101010001101100010100011011000102020100010010100001001000110011010000101101100202 +upca:33334522835:20201111010111101011110101111010100011011000102020110110011011001001000100001010011101110100202 +upca:45793591164:20201000110110001011101100010110111101011000102020111010011001101100110101000010111001110010202 +upca:18057726450:20200110010110111000110101100010111011011101102020110110010100001011100100111011100101000100202 +upca:96083152912:20200010110101111000110101101110111101001100102020100111011011001110100110011011011001001000202 +upca:16563181689:20200110010101111011000101011110111101001100102020100100011001101010000100100011101001101100202 +upca:51276473461:20201100010011001001001101110110101111010001102020100010010000101011100101000011001101011100202 +upca:08128913293:20200011010110111001100100100110110111000101102020110011010000101101100111010010000101011100202 +upca:34146752391:20201111010100011001100101000110101111011101102020100111011011001000010111010011001101000100202 +upca:97515692692:20200010110111011011000100110010110001010111102020111010011011001010000111010011011001000100202 +upca:97669919853:20200010110111011010111101011110001011000101102020110011011101001001000100111010000101010000202 +upca:18678734797:20200110010110111010111101110110110111011101102020100001010111001000100111010010001001110100202 +upca:74076303825:20201110110100011000110101110110101111011110102020111001010000101001000110110010011101000010202 +upca:08662387020:20200011010110111010111101011110010011011110102020100100010001001110010110110011100101010000202 +upca:26133671442:20200100110101111001100101111010111101010111102020100010011001101011100101110011011001000010202 +upca:87138605931:20201101110111011001100101111010110111010111102020111001010011101110100100001011001101001110202 +upca:67189289819:20201011110111011001100101101110001011001001102020100100011101001001000110011011101001110010202 +upca:09759720707:20200011010001011011101101100010001011011101102020110110011100101000100111001010001001000010202 +upca:56485529906:20201100010101111010001101101110110001011000102020110110011101001110100111001010100001110100202 +upca:58154525395:20201100010110111001100101100010100011011000102020110110010011101000010111010010011101001000202 +upca:67888609275:20201011110111011011011101101110110111010111102020111001011101001101100100010010011101010000202 +upca:15168153237:20200110010110001001100101011110110111001100102020100111010000101101100100001010001001110010202 +upca:74424730673:20201110110100011010001100100110100011011101102020100001011100101010000100010010000101110100202 +upca:45168971187:20201000110110001001100101011110110111000101102020100010011001101100110100100010001001000100202 +upca:12149723784:20200110010010011001100101000110001011011101102020110110010000101000100100100010111001011100202 +upca:33804286457:20201111010111101011011100011010100011001001102020100100010100001011100100111010001001101100202 +upca:27558248562:20200100110111011011000101100010110111001001102020101110010010001001110101000011011001011100202 +upca:92390267160:20200010110010011011110100010110001101001001102020101000010001001100110101000011100101000100202 +upca:63742039163:20201011110111101011101101000110010011000110102020100001011101001100110101000010000101101100202 +upca:67117098326:20201011110111011001100100110010111011000110102020111010010010001000010110110010100001010000202 +upca:32901624258:20201111010010011000101100011010011001010111102020110110010111001101100100111010010001001000202 +upca:88848685777:20201101110110111011011101000110110111010111102020100100010011101000100100010010001001101100202 +upca:57070085601:20201100010111011000110101110110001101000110102020100100010011101010000111001011001101100110202 +upca:83043128438:20201101110111101000110101000110111101001100102020110110010010001011100100001010010001010000202 +upca:52432147628:20201100010010011010001101111010010011001100102020101110010001001010000110110010010001001000202 +upca:15067795584:20200110010110001000110101011110111011011101102020111010010011101001110100100010111001100110202 +upca:27777156430:20200100110111011011101101110110111011001100102020100111010100001011100100001011100101100110202 +upca:82471218344:20201101110010011010001101110110011001001001102020110011010010001000010101110010111001011100202 +upca:94175044091:20200010110100011001100101110110110001000110102020101110010111001110010111010011001101010000202 +upca:34936749963:20201111010100011000101101111010101111011101102020101110011101001110100101000010000101110100202 +upca:46502492658:20201000110101111011000100011010010011010001102020111010011011001010000100111010010001100110202 +upca:47153985860:20201000110111011001100101100010111101000101102020100100010011101001000101000011100101010000202 +upca:79601763982:20201110110001011010111100011010011001011101102020101000010000101110100100100011011001110010202 +upca:91685238225:20200010110011001010111101101110110001001001102020100001010010001101100110110010011101110100202 +upca:46916417994:20201000110101111000101100110010101111010001102020110011010001001110100111010010111001011100202 +upca:30878845484:20201111010001101011011101110110110111011011102020101110010011101011100100100010111001110100202 +upca:39321907655:20201111010001011011110100100110011001000101102020111001010001001010000100111010011101011100202 +upca:48232524842:20201000110110111001001101111010010011011000102020110110010111001001000101110011011001010000202 +upca:94750199914:20200010110100011011101101100010001101001100102020111010011101001110100110011010111001010000202 +upca:28310653784:20200100110110111011110100110010001101010111102020100111010000101000100100100010111001100110202 +upca:00814405096:20200011010001101011011100110010100011010001102020111001010011101110010111010010100001000100202 +upca:60974743279:20201011110001101000101101110110100011011101102020101110010000101101100100010011101001011100202 +upca:45141255670:20201000110110001001100101000110011001001001102020100111010011101010000100010011100101010000202 +upca:62241294735:20201011110010011001001101000110011001001001102020111010010111001000100100001010011101001110202 +upca:67241197048:20201011110111011001001101000110011001001100102020111010010001001110010101110010010001110100202 +upca:57709892169:20201100010111011011101100011010001011011011102020111010011011001100110101000011101001000100202 +upca:49234133045:20201000110001011001001101111010100011001100102020100001010000101110010101110010011101010000202 +upca:44106865868:20201000110100011001100100011010101111011011102020101000010011101001000101000010010001001000202 +upca:07033900539:20200011010111011000110101111010111101000101102020111001011100101001110100001011101001000100202 +upca:63922260360:20201011110111101000101100100110010011001001102020101000011100101000010101000011100101110100202 +upca:63544942112:20201011110111101011000101000110100011000101102020101110011011001100110110011011011001001110202 +upca:52602007800:20201100010010011010111100011010010011000110102020111001010001001001000111001011100101001000202 +upca:94048257810:20200010110100011000110101000110110111001001102020100111010001001001000110011011100101101100202 +upca:82699181094:20201101110010011010111100010110001011001100102020100100011001101110010111010010111001000010202 +upca:94628599972:20200010110100011010111100100110110111011000102020111010011101001110100100010011011001011100202 +upca:09938844603:20200011010001011000101101111010110111011011102020101110010111001010000111001010000101010000202 +upca:37128560103:20201111010111011001100100100110110111011000102020101000011100101100110111001010000101110010202 diff --git a/share/extensions/test/render_barcode.test.py b/share/extensions/test/render_barcode.test.py index 0762ccb99..79f4ff979 100755 --- a/share/extensions/test/render_barcode.test.py +++ b/share/extensions/test/render_barcode.test.py @@ -1,20 +1,39 @@ #!/usr/bin/env python - -# This is only the automatic generated test file for ../render_barcode.py -# This must be filled with real tests and this commentary -# must be cleared. -# If you want to help, read the python unittest documentation: -# http://docs.python.org/library/unittest.html +# +# Copyright (C) 2010 Martin Owens +# +# Written to test the coding of generating barcodes. +# import sys -sys.path.append('..') # this line allows to import the extension code - +import random import unittest + +# Allow import of the extension code and modules +sys.path.append('..') + from render_barcode import * -class InsertBarcodeBasicTest(unittest.TestCase): +import Barcode.EAN5 +import Barcode.EAN8 +import Barcode.EAN13 +import Barcode.UPCA +import Barcode.UPCE + +digits = [ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' ] - #def setUp(self): +class InsertBarcodeBasicTest(unittest.TestCase): + """Render Barcode""" + def setUp(self): + self.data = {} + fhl = open('render_barcode.data', 'r') + for line in fhl: + line = line.replace('\n', '').replace('\r', '') + (btype, text, code) = line.split(':') + if not self.data.has_key(btype): + self.data[btype] = [] + self.data[btype].append( [ text, code ] ) + fhl.close() def test_run_without_parameters(self): args = [ 'minimal-blank.svg' ] @@ -22,5 +41,36 @@ class InsertBarcodeBasicTest(unittest.TestCase): e.affect( args, False ) #self.assertEqual( e.something, 'some value', 'A commentary about that.' ) + def test_render_barcode_ian5(self): + """Barcode IAN5""" + self.barcode_test( 'ean5', Barcode.EAN5 ) + + def test_render_barcode_ian8(self): + """Barcode IAN5""" + self.barcode_test( 'ean8', Barcode.EAN8 ) + + def test_render_barcode_ian13(self): + """Barcode IAN5""" + self.barcode_test( 'ean13', Barcode.EAN13 ) + + def test_render_barcode_upca(self): + """Barcode IAN5""" + self.barcode_test( 'upca', Barcode.UPCA ) + + def test_render_barcode_upce(self): + """Barcode UPCE""" + self.barcode_test( 'upce', Barcode.UPCE ) + + def barcode_test(self, name, module): + """Base module for all barcode testing""" + for datum in self.data[name]: + (text, code) = datum + if not text or not code: + continue + code2 = module.Object( {'text': text} ).encode(text) + self.assertEqual(code, code2) + + if __name__ == '__main__': unittest.main() + -- 2.30.2