2
Copyright (C) 2007 Martin Owens
4
Thanks to Lineaire Chez of Inkbar ( www.inkbar.lineaire.net )
6
This program is free software; you can redistribute it and/or modify
7
it under the terms of the GNU General Public License as published by
8
the Free Software Foundation; either version 2 of the License, or
9
(at your option) any later version.
11
This program is distributed in the hope that it will be useful,
12
but WITHOUT ANY WARRANTY; without even the implied warranty of
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
GNU General Public License for more details.
16
You should have received a copy of the GNU General Public License
17
along with this program; if not, write to the Free Software
18
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22
from EAN13 import mapLeftFaimly, guardBar, centerBar, mapRight
25
class Object(EAN13.Object):
26
def encode(self, number):
29
if len(number) < 11 or len(number) > 12 or not number.isdigit():
30
sys.stderr.write("Can not encode '" + number + "' into UPC-A Barcode, Size must be 11 numbers only, and 1 check digit (optional).\n")
34
number = number + self.getChecksum(number)
36
if not self.varifyChecksum(number):
37
sys.stderr.write("EAN13 Checksum not correct for this barcode, omit last charicter to generate new checksum.\n")
40
result = result + guardBar
44
result += mapLeftFaimly[0][int(number[i])]
48
for i in range (6,12):
49
result += mapRight[int(number[i])]
51
result = result + guardBar;
53
self.label = number[0] + ' ' + number[1:6] + ' ' + number[6:11] + ' ' + number[11]
54
self.inclabel = self.label