BaseEan.py revision 1ef3c8b1b935901dd133c337031a7300334db424
#
# Copyright (C) 2010 Martin Owens
#
# 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.
"""
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.
'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 = []
"""Convert a string of digits into an array of ints"""
"""Encode any side of the barcode, interleaved"""
result = []
return result
"""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'
return result
"""Encode the left side of the barcode, non-interleaved"""
result = []
for n in number:
return result
"""Space out an array of numbers"""
result = ''
for i in space:
return result
def getLengths(self):
"""Return a list of acceptable lengths"""
"""Encode any EAN barcode"""
raise NotImplementedError("_encode should be provided by parent EAN")
"""Standard Enclosure"""
result = 0
# We need to work from left to right so reverse
# checksum based on first digits.
# Modulous result to a single digit checksum
return '0'
"""Apply the checksum to a short number"""
"""Verify any checksum"""