Merge lp:~doctormo/inkscape/barcode-refactor into lp:~inkscape.dev/inkscape/trunk
- barcode-refactor
- Merge into trunk
Status: | Merged |
---|---|
Merged at revision: | 9993 |
Proposed branch: | lp:~doctormo/inkscape/barcode-refactor |
Merge into: | lp:~inkscape.dev/inkscape/trunk |
Diff against target: |
2958 lines (+1630/-1039) 19 files modified
share/extensions/Barcode/Base.py (+65/-69) share/extensions/Barcode/BaseEan.py (+145/-0) share/extensions/Barcode/Code128.py (+113/-113) share/extensions/Barcode/Code25i.py (+78/-0) share/extensions/Barcode/Code39.py (+95/-93) share/extensions/Barcode/Code39Ext.py (+42/-40) share/extensions/Barcode/Code93.py (+90/-88) share/extensions/Barcode/EAN13.py (+37/-100) share/extensions/Barcode/EAN5.py (+38/-67) share/extensions/Barcode/EAN8.py (+33/-83) share/extensions/Barcode/Makefile.am (+2/-0) share/extensions/Barcode/RM4CC.py (+126/-122) share/extensions/Barcode/UPCA.py (+37/-59) share/extensions/Barcode/UPCE.py (+100/-127) share/extensions/Barcode/__init__.py (+63/-63) share/extensions/render_barcode.inx (+3/-2) share/extensions/render_barcode.py (+3/-3) share/extensions/test/render_barcode.data (+500/-0) share/extensions/test/render_barcode.test.py (+60/-10) |
To merge this branch: | bzr merge lp:~doctormo/inkscape/barcode-refactor |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Joker Wild (community) | Approve | ||
Review via email: mp+44768@code.launchpad.net |
Commit message
Extensions. Barcode extension refactoring (see https:/
Description of the change
I've done a lot of work to improve the barcode python code, both improving it so it's more in line with PEP standards and adding in code25 interleaved. We also have all the EAN codes now following the same base code.
There is a new test suite for testing all EAN barcodes against data to show that they're performing the same as the old code after the re-factoring.
Joker Wild (lajjr-deactivatedaccount) wrote : | # |
Joker Wild (lajjr-deactivatedaccount) : | # |
Martin Owens (doctormo) wrote : | # |
Hey Leo,
What all versions would you like to add what to, the PEP changes?
Martin
Joker Wild (lajjr-deactivatedaccount) wrote : | # |
Martin,
No not to the PEP that is fine, just to Inkscape .47, .48, and trunk. Sorry if I confused you in any way. The earlier version are used daily with the new. It would be great to add to all version period.
Regards,
Leo Jackson
su_v (suv-lp) wrote : | # |
0.47 is closed - there are no bug fixes or new features being backported to 0.47.
0.48.x is maintained for bug fixes, but no new features are added (translation is frozen).
IMHO refactored code should be merged into trunk only (milestoned for 0.49), and tested on all major platforms with different python versions.
Joker Wild (lajjr-deactivatedaccount) wrote : | # |
~suv,
Yes sorry about that. I think is it great overhaul of the barcode code and works great so far. I changed it in my extensions on my systems. Windows and Ubuntu I can do more testing.
Regards,
Leo Jackson
su_v (suv-lp) wrote : | # |
With Inkscape 0.48+devel r9990 on OS X 10.5.8, using Python 2.6.6 and default (new) preferences, I get this error when testing 'Extensions > Render > Barcode…' after applying the diff from this merge proposal to trunk and 'make install':
Traceback (most recent call last):
File "render_
from Barcode import getBarcode
File "/Volumes/
elif format=='code39':
^
IndentationError: unexpected indent
(Note: I don't usually use this extension and know close to nothing about barcodes, but I would expect the extension to either notify me if I entered an invalid value, or produce some kind of graphical output).
How can I investigate what causes this python error?
- 9993. By Martin Owens
-
PEP8 requires tabs to be removed and instead four spaces to be used.
Martin Owens (doctormo) wrote : | # |
@suv - I agree that it probably should stay in trunk unless there are specific things the re-factoring fixes for 0.48 (which I don't think it does)
the error you reported isn't because of an input error, it's because of a PEP8 error which I've just fixed. All tabs should be removed and there was some left over. Last commit should fix it, thanks for testing.
su_v (suv-lp) wrote : | # |
thx - error's gone :) (not tested in-depth though yet).
The new files need to be added to 'share/
- 9994. By Martin Owens
-
Add to makefile so it builds correctly.
Martin Owens (doctormo) wrote : | # |
Ah yes, the makefile, thanks for fixing that. It should be fixed in 9994
su_v (suv-lp) wrote : | # |
Some error messages for invalid input seem rather cryptic now: e.g.
Error encoding '1234567890123' as upce barcode: Wrong size, must be 6, 1, 1, 7, 1, 2 digits
No barcode was generated
This gives not many clues how a correct size must look (at least to me). The error message of the previous code (in 0.48.0) seems clearer to me:
Can not encode '1234567890123' into UPC-E Barcode, Size must be 6 numbers only, and 1 check digit (optional)
Or a convertable 11 digit UPC-A number with 1 check digit (also optional).
No barcode was generated
But maybe this type of discussion should happen after the merge?
Joker Wild (lajjr-deactivatedaccount) wrote : | # |
~suv, Martin,
I know that it is completed. I have to check my systems or something I didn't get PEP errors.
Step to apply download preview.diff 1st then patch to apply. I tried out about 30+ different ones printed, and with my symbol hand scanner. Decode and encode was correct I use the Emacs launchpad: https:/
I have to do a check to see what happened.
The patch part said
applied to files in a list like normal. Then I looked at the files, curiosity killed the cat and my PEP errors.
Hmmm.
Regards,
Leo Jackson
Preview Diff
1 | === modified file 'share/extensions/Barcode/Base.py' |
2 | --- share/extensions/Barcode/Base.py 2010-07-22 22:18:09 +0000 |
3 | +++ share/extensions/Barcode/Base.py 2010-12-30 04:23:15 +0000 |
4 | @@ -1,67 +1,63 @@ |
5 | -#!/usr/bin/env python |
6 | -''' |
7 | -Copyright (C) 2007 Martin Owens |
8 | - |
9 | -This program is free software; you can redistribute it and/or modify |
10 | -it under the terms of the GNU General Public License as published by |
11 | -the Free Software Foundation; either version 2 of the License, or |
12 | -(at your option) any later version. |
13 | - |
14 | -This program is distributed in the hope that it will be useful, |
15 | -but WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
17 | -GNU General Public License for more details. |
18 | - |
19 | -You should have received a copy of the GNU General Public License |
20 | -along with this program; if not, write to the Free Software |
21 | -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
22 | -''' |
23 | +# |
24 | +# Copyright (C) 2010 Martin Owens |
25 | +# |
26 | +# This program is free software; you can redistribute it and/or modify |
27 | +# it under the terms of the GNU General Public License as published by |
28 | +# the Free Software Foundation; either version 2 of the License, or |
29 | +# (at your option) any later version. |
30 | +# |
31 | +# This program is distributed in the hope that it will be useful, |
32 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
33 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
34 | +# GNU General Public License for more details. |
35 | +# |
36 | +# You should have received a copy of the GNU General Public License |
37 | +# along with this program; if not, write to the Free Software |
38 | +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
39 | +# |
40 | +""" |
41 | +Base module for rendering barcodes for Inkscape. |
42 | +""" |
43 | |
44 | import itertools |
45 | import sys |
46 | from lxml import etree |
47 | |
48 | -class Barcode: |
49 | +(WHITE_BAR, BLACK_BAR, TALL_BAR) = range(3) |
50 | +TEXT_TEMPLATE = 'font-size:%dpx;text-align:center;text-anchor:middle;' |
51 | + |
52 | +class Barcode(object): |
53 | + """Provide a base class for all barcode renderers""" |
54 | + name = None |
55 | + |
56 | + def error(self, bar, msg): |
57 | + """Cause an error to be reported""" |
58 | + sys.stderr.write( |
59 | + "Error encoding '%s' as %s barcode: %s\n" % (bar, self.name, msg)) |
60 | + |
61 | def __init__(self, param={}): |
62 | - self.document = None |
63 | - self.x = 0 |
64 | - self.y = 0 |
65 | - |
66 | - if param.has_key('document'): |
67 | - self.document = param['document'] |
68 | - if param.has_key('x'): |
69 | - self.x = param['x'] |
70 | - if param.has_key('y'): |
71 | - self.y = param['y'] |
72 | - |
73 | - if param.has_key('height'): |
74 | - self.height = param['height'] |
75 | - else: |
76 | - self.height = 30 |
77 | - |
78 | - self.text = param['text'] |
79 | - self.label = self.text |
80 | - self.string = self.encode( self.text ) |
81 | + self.document = param.get('document', None) |
82 | + self.x = int(param.get('x', 0)) |
83 | + self.y = int(param.get('y', 0)) |
84 | + self.height = param.get('height', 30) |
85 | + self.label = param.get('text', None) |
86 | + self.string = self.encode( self.label ) |
87 | + |
88 | if not self.string: |
89 | return |
90 | + |
91 | self.width = len(self.string) |
92 | self.data = self.graphicalArray(self.string) |
93 | |
94 | def generate(self): |
95 | + """Generate the actual svg from the coding""" |
96 | svg_uri = u'http://www.w3.org/2000/svg' |
97 | if not self.string or not self.data: |
98 | return |
99 | - |
100 | - data = self.data; |
101 | - |
102 | - # create an SVG document if required |
103 | - # if not self.document: |
104 | - # self.document = UNKNOWN |
105 | - |
106 | if not self.document: |
107 | - sys.stderr.write("No document defined to add barcode to\n") |
108 | - return |
109 | + return self.error("No document defined") |
110 | |
111 | + data = self.data |
112 | # Collect document ids |
113 | doc_ids = {} |
114 | docIdNodes = self.document.xpath('//@id') |
115 | @@ -81,10 +77,10 @@ |
116 | barcode = etree.Element('{%s}%s' % (svg_uri,'g')) |
117 | barcode.set('id', name) |
118 | barcode.set('style', 'fill: black;') |
119 | + barcode.set('transform', 'translate(%d,%d)' % (self.x, self.y)) |
120 | |
121 | - draw = 1 |
122 | - wOffset = int(self.x) |
123 | - id = 1 |
124 | + bar_offset = 0 |
125 | + bar_id = 1 |
126 | |
127 | for datum in data: |
128 | # Datum 0 tells us what style of bar is to come next |
129 | @@ -94,41 +90,41 @@ |
130 | width = int(datum[1]) * int(style['width']) |
131 | |
132 | if style['write']: |
133 | - # Add height for styles such as EA8 where |
134 | - # the barcode goes into the text |
135 | - |
136 | rect = etree.SubElement(barcode,'{%s}%s' % (svg_uri,'rect')) |
137 | - rect.set('x', str(wOffset)) |
138 | + rect.set('x', str(bar_offset)) |
139 | rect.set('y', str(style['top'])) |
140 | rect.set('width', str(width)) |
141 | rect.set('height', str(style['height'])) |
142 | - rect.set('id', name + '_bar' + str(id)) |
143 | - wOffset = int(wOffset) + int(width) |
144 | - id = id + 1 |
145 | + rect.set('id', "%s_bar%d" % (name, bar_id)) |
146 | + bar_offset += width |
147 | + bar_id += 1 |
148 | |
149 | - barwidth = wOffset - int(self.x) |
150 | + bar_width = bar_offset |
151 | # Add text at the bottom of the barcode |
152 | text = etree.SubElement(barcode,'{%s}%s' % (svg_uri,'text')) |
153 | - text.set( 'x', str(int(self.x) + int(barwidth / 2)) ) |
154 | - text.set( 'y', str(int(self.height) + 10 + int(self.y)) ) |
155 | - text.set( 'style', 'font-size:' + self.fontSize() + 'px;text-align:center;text-anchor:middle;' ) |
156 | + text.set( 'x', str(int(bar_width / 2))) |
157 | + text.set( 'y', str(self.height + self.fontSize() )) |
158 | + text.set( 'style', TEXT_TEMPLATE % self.fontSize() ) |
159 | text.set( '{http://www.w3.org/XML/1998/namespace}space', 'preserve' ) |
160 | - text.set( 'id', name + '_bottomtext' ) |
161 | - |
162 | + text.set( 'id', '%s_text' % name ) |
163 | text.text = str(self.label) |
164 | - |
165 | return barcode |
166 | |
167 | - # Converts black and white markers into a space array |
168 | def graphicalArray(self, code): |
169 | + """Converts black and white markets into a space array""" |
170 | return [(x,len(list(y))) for x, y in itertools.groupby(code)] |
171 | |
172 | def getStyle(self, index): |
173 | - result = { 'width' : 1, 'top' : int(self.y), 'write' : False } |
174 | - if index==1: # Black Bar |
175 | + """Returns the styles that should be applied to each bar""" |
176 | + result = { 'width' : 1, 'top' : 0, 'write' : True } |
177 | + if index == BLACK_BAR: |
178 | result['height'] = int(self.height) |
179 | - result['write'] = True |
180 | + if index == TALL_BAR: |
181 | + result['height'] = int(self.height) + int(self.fontSize() / 2) |
182 | + if index == WHITE_BAR: |
183 | + result['write'] = False |
184 | return result |
185 | |
186 | def fontSize(self): |
187 | - return '9' |
188 | + """Return the ideal font size, defaults to 9px""" |
189 | + return 9 |
190 | |
191 | === added file 'share/extensions/Barcode/BaseEan.py' |
192 | --- share/extensions/Barcode/BaseEan.py 1970-01-01 00:00:00 +0000 |
193 | +++ share/extensions/Barcode/BaseEan.py 2010-12-30 04:23:15 +0000 |
194 | @@ -0,0 +1,145 @@ |
195 | +# |
196 | +# Copyright (C) 2010 Martin Owens |
197 | +# |
198 | +# This program is free software; you can redistribute it and/or modify |
199 | +# it under the terms of the GNU General Public License as published by |
200 | +# the Free Software Foundation; either version 2 of the License, or |
201 | +# (at your option) any later version. |
202 | +# |
203 | +# This program is distributed in the hope that it will be useful, |
204 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
205 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
206 | +# GNU General Public License for more details. |
207 | +# |
208 | +# You should have received a copy of the GNU General Public License |
209 | +# along with this program; if not, write to the Free Software |
210 | +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
211 | +# |
212 | +""" |
213 | +Some basic common code shared between EAN and UCP generators. |
214 | +""" |
215 | + |
216 | +from Base import Barcode |
217 | +import sys |
218 | + |
219 | +MAPPING = [ |
220 | + # Left side of barcode Family '0' |
221 | + [ "0001101", "0011001", "0010011", "0111101", "0100011", |
222 | + "0110001", "0101111", "0111011", "0110111", "0001011" ], |
223 | + # Left side of barcode Family '1' and flipped to right side. |
224 | + [ "0100111", "0110011", "0011011", "0100001", "0011101", |
225 | + "0111001", "0000101", "0010001", "0001001", "0010111" ], |
226 | +] |
227 | +# This chooses which of the two encodings above to use. |
228 | +FAMILIES = [ '000000', '001011', '001101', '001110', '010011', |
229 | + '011001', '011100', '010101', '010110', '011010' ] |
230 | + |
231 | +GUARD_BAR = '202' |
232 | +CENTER_BAR = '02020' |
233 | + |
234 | +class EanBarcode(Barcode): |
235 | + """Simple base class for all EAN type barcodes""" |
236 | + length = None |
237 | + lengths = None |
238 | + checks = [] |
239 | + |
240 | + def intarray(self, number): |
241 | + """Convert a string of digits into an array of ints""" |
242 | + return [ int(i) for i in number ] |
243 | + |
244 | + |
245 | + def encode_interleaved(self, family, number, fams=FAMILIES): |
246 | + """Encode any side of the barcode, interleaved""" |
247 | + result = [] |
248 | + encset = self.intarray(fams[family]) |
249 | + for i in range(len(number)): |
250 | + thismap = MAPPING[encset[i]] |
251 | + result.append( thismap[number[i]] ) |
252 | + return result |
253 | + |
254 | + |
255 | + def encode_right(self, number): |
256 | + """Encode the right side of the barcode, non-interleaved""" |
257 | + result = [] |
258 | + for n in number: |
259 | + # The right side is always the reverse of the left's family '1' |
260 | + result.append( MAPPING[1][n][::-1] ) |
261 | + return result |
262 | + |
263 | + |
264 | + def encode_left(self, number): |
265 | + """Encode the left side of the barcode, non-interleaved""" |
266 | + result = [] |
267 | + for n in number: |
268 | + result.append( MAPPING[0][n] ) |
269 | + return result |
270 | + |
271 | + |
272 | + def space(self, *spacing): |
273 | + """Space out an array of numbers""" |
274 | + result = '' |
275 | + for space in spacing: |
276 | + if isinstance(space, list): |
277 | + for i in space: |
278 | + result += str(i) |
279 | + elif isinstance(space, int): |
280 | + result += ' ' * space |
281 | + return result |
282 | + |
283 | + |
284 | + def getLengths(self): |
285 | + """Return a list of acceptable lengths""" |
286 | + if self.length: |
287 | + return [ self.length ] |
288 | + return self.lengths[:] |
289 | + |
290 | + |
291 | + def encode(self, code): |
292 | + """Encode any EAN barcode""" |
293 | + if not code.isdigit(): |
294 | + return self.error(code, 'Not a Number, must be digits 0-9 only') |
295 | + lengths = self.getLengths() + self.checks |
296 | + |
297 | + if len(code) not in lengths: |
298 | + return self.error(code, 'Wrong size, must be %s digits' % |
299 | + (', '.join(self.space(lengths)))) |
300 | + |
301 | + if self.checks: |
302 | + if len(code) not in self.checks: |
303 | + code = self.appendChecksum(code) |
304 | + elif not self.verifyChecksum(code): |
305 | + return self.error(code, 'Checksum failed, omit for new sum') |
306 | + return self._encode(self.intarray(code)) |
307 | + |
308 | + |
309 | + def _encode(self, n): |
310 | + raise NotImplementedError("_encode should be provided by parent EAN") |
311 | + |
312 | + def enclose(self, left, right=[], guard=GUARD_BAR, center=CENTER_BAR): |
313 | + """Standard Enclosure""" |
314 | + parts = [ guard ] + left + [ center ] + right + [ guard ] |
315 | + return ''.join( parts ) |
316 | + |
317 | + def getChecksum(self, number, magic=10): |
318 | + """Generate a UPCA/EAN13/EAN8 Checksum""" |
319 | + weight = [3,1] * len(number) |
320 | + result = 0 |
321 | + # We need to work from left to right so reverse |
322 | + number = number[::-1] |
323 | + # checksum based on first digits. |
324 | + for i in range(len(number)): |
325 | + result += int(number[i]) * weight[i] |
326 | + # Modulous result to a single digit checksum |
327 | + checksum = magic - (result % magic) |
328 | + if checksum < 0 or checksum >= magic: |
329 | + return '0' |
330 | + return str(checksum) |
331 | + |
332 | + def appendChecksum(self, number): |
333 | + """Apply the checksum to a short number""" |
334 | + return number + self.getChecksum(number) |
335 | + |
336 | + def verifyChecksum(self, number): |
337 | + """Verify any checksum""" |
338 | + return self.getChecksum(number[:-1]) == number[-1] |
339 | + |
340 | |
341 | === modified file 'share/extensions/Barcode/Code128.py' |
342 | --- share/extensions/Barcode/Code128.py 2010-07-22 22:18:09 +0000 |
343 | +++ share/extensions/Barcode/Code128.py 2010-12-30 04:23:15 +0000 |
344 | @@ -1,27 +1,27 @@ |
345 | -#!/usr/bin/env python |
346 | -''' |
347 | -Copyright (C) 2007 Martin Owens |
348 | - |
349 | -Debugged by Ralf Heinecke & Martin Siepmann 09/07/2007 |
350 | -Debugged by Horst Schottky Feb. 27. 2010 |
351 | - |
352 | -This program is free software; you can redistribute it and/or modify |
353 | -it under the terms of the GNU General Public License as published by |
354 | -the Free Software Foundation; either version 2 of the License, or |
355 | -(at your option) any later version. |
356 | - |
357 | -This program is distributed in the hope that it will be useful, |
358 | -but WITHOUT ANY WARRANTY; without even the implied warranty of |
359 | -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
360 | -GNU General Public License for more details. |
361 | - |
362 | -You should have received a copy of the GNU General Public License |
363 | -along with this program; if not, write to the Free Software |
364 | -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
365 | - |
366 | - |
367 | - |
368 | -''' |
369 | +# |
370 | +# Authored by Martin Owens <doctormo@ubuntu.com> |
371 | +# Debugged by Ralf Heinecke & Martin Siepmann 2007-09-07 |
372 | +# Horst Schottky 2010-02-27 |
373 | +# |
374 | +# Copyright (C) 2007 Martin Owens |
375 | +# |
376 | +# This program is free software; you can redistribute it and/or modify |
377 | +# it under the terms of the GNU General Public License as published by |
378 | +# the Free Software Foundation; either version 2 of the License, or |
379 | +# (at your option) any later version. |
380 | +# |
381 | +# This program is distributed in the hope that it will be useful, |
382 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
383 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
384 | +# GNU General Public License for more details. |
385 | +# |
386 | +# You should have received a copy of the GNU General Public License |
387 | +# along with this program; if not, write to the Free Software |
388 | +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
389 | +# |
390 | +""" |
391 | +Python barcode renderer for Code128/EAN128 barcodes. Designed for use with Inkscape. |
392 | +""" |
393 | |
394 | from Base import Barcode |
395 | import math |
396 | @@ -30,13 +30,13 @@ |
397 | 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' ] |
398 | |
399 | def mapExtra(sd, chars): |
400 | - result = list(sd) |
401 | - for char in chars: |
402 | - result.append(chr(char)) |
403 | - result.append('FNC3') |
404 | - result.append('FNC2') |
405 | - result.append('SHIFT') |
406 | - return result |
407 | + result = list(sd) |
408 | + for char in chars: |
409 | + result.append(chr(char)) |
410 | + result.append('FNC3') |
411 | + result.append('FNC2') |
412 | + result.append('SHIFT') |
413 | + return result |
414 | |
415 | # The mapExtra method is used to slim down the amount |
416 | # of pre code and instead we generate the lists |
417 | @@ -45,86 +45,86 @@ |
418 | charB = mapExtra(charAB, range(96, 125)) # Offset -32 |
419 | |
420 | class Object(Barcode): |
421 | - def encode(self, text): |
422 | - result = '' |
423 | - blocks = [] |
424 | - block = '' |
425 | - |
426 | - # Split up into sections of numbers, or charicters |
427 | - # This makes sure that all the charicters are encoded |
428 | - # In the best way posible for Code128 |
429 | - for datum in re.findall(r'(?:(?:\d\d){2,})|(?:^\d\d)|.', text): |
430 | - if len(datum) == 1: |
431 | - block = block + datum |
432 | - else: |
433 | - if block: |
434 | - blocks.append(self.bestBlock(block)) |
435 | - block = '' |
436 | - blocks.append( [ 'C', datum ] ) |
437 | - |
438 | - if block: |
439 | - blocks.append(self.bestBlock(block)) |
440 | - block = ''; |
441 | - |
442 | - self.inclabel = text |
443 | - return self.encodeBlocks(blocks) |
444 | - |
445 | - def bestBlock(self, block): |
446 | - # If this has lower case then select B over A |
447 | - if block.upper() == block: |
448 | - return [ 'A', block ] |
449 | - return [ 'B', block ] |
450 | - |
451 | - def encodeBlocks(self, blocks): |
452 | - total = 0 |
453 | - pos = 0 |
454 | - encode = ''; |
455 | - |
456 | - for block in blocks: |
457 | - set = block[0] |
458 | - datum = block[1] |
459 | - |
460 | - # POS : 0, 1 |
461 | - # A : 101, 103 |
462 | - # B : 100, 104 |
463 | - # C : 99, 105 |
464 | - num = 0; |
465 | - if set == 'A': |
466 | - num = 103 |
467 | - elif set == 'B': |
468 | - num = 104 |
469 | - elif set == 'C': |
470 | - num = 105 |
471 | - |
472 | - i = pos |
473 | - if pos: |
474 | - num = 204 - num |
475 | - else: |
476 | - i = 1 |
477 | - |
478 | - total = total + num * i |
479 | - encode = encode + map[num] |
480 | - pos = pos + 1 |
481 | - |
482 | - if set == 'A' or set == 'B': |
483 | - chars = charB |
484 | - if set == 'A': |
485 | - chars = charA |
486 | - |
487 | - for char in datum: |
488 | - total = total + (chars.index(char) * pos) |
489 | - encode = encode + map[chars.index(char)] |
490 | - pos = pos + 1 |
491 | - else: |
492 | - for char in (datum[i:i+2] for i in range(0, len(datum), 2)): |
493 | - total = total + (int(char) * pos) |
494 | - encode = encode + map[int(char)] |
495 | - pos = pos + 1 |
496 | - |
497 | - checksum = total % 103 |
498 | - encode = encode + map[checksum] |
499 | - encode = encode + map[106] |
500 | - encode = encode + map[107] |
501 | - |
502 | - return encode |
503 | + def encode(self, text): |
504 | + result = '' |
505 | + blocks = [] |
506 | + block = '' |
507 | + |
508 | + # Split up into sections of numbers, or charicters |
509 | + # This makes sure that all the charicters are encoded |
510 | + # In the best way posible for Code128 |
511 | + for datum in re.findall(r'(?:(?:\d\d){2,})|(?:^\d\d)|.', text): |
512 | + if len(datum) == 1: |
513 | + block = block + datum |
514 | + else: |
515 | + if block: |
516 | + blocks.append(self.bestBlock(block)) |
517 | + block = '' |
518 | + blocks.append( [ 'C', datum ] ) |
519 | + |
520 | + if block: |
521 | + blocks.append(self.bestBlock(block)) |
522 | + block = ''; |
523 | + |
524 | + self.inclabel = text |
525 | + return self.encodeBlocks(blocks) |
526 | + |
527 | + def bestBlock(self, block): |
528 | + # If this has lower case then select B over A |
529 | + if block.upper() == block: |
530 | + return [ 'A', block ] |
531 | + return [ 'B', block ] |
532 | + |
533 | + def encodeBlocks(self, blocks): |
534 | + total = 0 |
535 | + pos = 0 |
536 | + encode = ''; |
537 | + |
538 | + for block in blocks: |
539 | + set = block[0] |
540 | + datum = block[1] |
541 | + |
542 | + # POS : 0, 1 |
543 | + # A : 101, 103 |
544 | + # B : 100, 104 |
545 | + # C : 99, 105 |
546 | + num = 0; |
547 | + if set == 'A': |
548 | + num = 103 |
549 | + elif set == 'B': |
550 | + num = 104 |
551 | + elif set == 'C': |
552 | + num = 105 |
553 | + |
554 | + i = pos |
555 | + if pos: |
556 | + num = 204 - num |
557 | + else: |
558 | + i = 1 |
559 | + |
560 | + total = total + num * i |
561 | + encode = encode + map[num] |
562 | + pos = pos + 1 |
563 | + |
564 | + if set == 'A' or set == 'B': |
565 | + chars = charB |
566 | + if set == 'A': |
567 | + chars = charA |
568 | + |
569 | + for char in datum: |
570 | + total = total + (chars.index(char) * pos) |
571 | + encode = encode + map[chars.index(char)] |
572 | + pos = pos + 1 |
573 | + else: |
574 | + for char in (datum[i:i+2] for i in range(0, len(datum), 2)): |
575 | + total = total + (int(char) * pos) |
576 | + encode = encode + map[int(char)] |
577 | + pos = pos + 1 |
578 | + |
579 | + checksum = total % 103 |
580 | + encode = encode + map[checksum] |
581 | + encode = encode + map[106] |
582 | + encode = encode + map[107] |
583 | + |
584 | + return encode |
585 | |
586 | |
587 | === added file 'share/extensions/Barcode/Code25i.py' |
588 | --- share/extensions/Barcode/Code25i.py 1970-01-01 00:00:00 +0000 |
589 | +++ share/extensions/Barcode/Code25i.py 2010-12-30 04:23:15 +0000 |
590 | @@ -0,0 +1,78 @@ |
591 | +# |
592 | +# Copyright (C) 2010 Geoffrey Mosini |
593 | +# |
594 | +# This program is free software; you can redistribute it and/or modify |
595 | +# it under the terms of the GNU General Public License as published by |
596 | +# the Free Software Foundation; either version 2 of the License, or |
597 | +# (at your option) any later version. |
598 | +# |
599 | +# This program is distributed in the hope that it will be useful, |
600 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
601 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
602 | +# GNU General Public License for more details. |
603 | +# |
604 | +# You should have received a copy of the GNU General Public License |
605 | +# along with this program; if not, write to the Free Software |
606 | +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
607 | +# |
608 | +""" |
609 | +Generate barcodes for Code25-interleaved 2 of 5, for Inkscape. |
610 | +""" |
611 | + |
612 | +from Base import Barcode |
613 | +import sys |
614 | + |
615 | +# 1 means thick, 0 means thin |
616 | +encoding = { |
617 | + '0' : '00110', |
618 | + '1' : '10001', |
619 | + '2' : '01001', |
620 | + '3' : '11000', |
621 | + '4' : '00101', |
622 | + '5' : '10100', |
623 | + '6' : '01100', |
624 | + '7' : '00011', |
625 | + '8' : '10010', |
626 | + '9' : '01010', |
627 | + |
628 | +} |
629 | + |
630 | +# Start and stop code are already encoded into white (0) and black(1) bars |
631 | +start_code = '1010' |
632 | +stop_code = '1101' |
633 | + |
634 | +class Object(Barcode): |
635 | + # Convert a text into string binary of black and white markers |
636 | + def encode(self, number): |
637 | + self.label = number |
638 | + |
639 | + if not number.isdigit(): |
640 | + sys.stderr.write("CODE25 can only encode numbers.\n") |
641 | + return |
642 | + |
643 | + # Number of figures to encode must be even, a 0 is added to the left in case it's odd. |
644 | + if len(number) % 2 > 0 : |
645 | + number = '0' + number |
646 | + |
647 | + # Number is encoded by pairs of 2 figures |
648 | + size = len(number) / 2; |
649 | + encoded = start_code; |
650 | + for i in range(size): |
651 | + # First in the pair is encoded in black (1), second in white (0) |
652 | + black = encoding[number[i*2]] |
653 | + white = encoding[number[i*2+1]] |
654 | + for j in range(5): |
655 | + if black[j] == '1': |
656 | + encoded += '11' |
657 | + else: |
658 | + encoded += '1' |
659 | + if white[j] == '1': |
660 | + encoded += '00' |
661 | + else: |
662 | + encoded += '0' |
663 | + |
664 | + encoded += stop_code |
665 | + |
666 | + self.inclabel = number |
667 | + return encoded; |
668 | + |
669 | |
670 | === modified file 'share/extensions/Barcode/Code39.py' |
671 | --- share/extensions/Barcode/Code39.py 2010-07-22 22:18:09 +0000 |
672 | +++ share/extensions/Barcode/Code39.py 2010-12-30 04:23:15 +0000 |
673 | @@ -1,101 +1,103 @@ |
674 | -#!/usr/bin/env python |
675 | -''' |
676 | -Copyright (C) 2007 Martin Owens |
677 | - |
678 | -This program is free software; you can redistribute it and/or modify |
679 | -it under the terms of the GNU General Public License as published by |
680 | -the Free Software Foundation; either version 2 of the License, or |
681 | -(at your option) any later version. |
682 | - |
683 | -This program is distributed in the hope that it will be useful, |
684 | -but WITHOUT ANY WARRANTY; without even the implied warranty of |
685 | -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
686 | -GNU General Public License for more details. |
687 | - |
688 | -You should have received a copy of the GNU General Public License |
689 | -along with this program; if not, write to the Free Software |
690 | -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
691 | -''' |
692 | +# |
693 | +# Copyright (C) 2007 Martin Owens |
694 | +# |
695 | +# This program is free software; you can redistribute it and/or modify |
696 | +# it under the terms of the GNU General Public License as published by |
697 | +# the Free Software Foundation; either version 2 of the License, or |
698 | +# (at your option) any later version. |
699 | +# |
700 | +# This program is distributed in the hope that it will be useful, |
701 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
702 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
703 | +# GNU General Public License for more details. |
704 | +# |
705 | +# You should have received a copy of the GNU General Public License |
706 | +# along with this program; if not, write to the Free Software |
707 | +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
708 | +# |
709 | +""" |
710 | +Python barcode renderer for Code39 barcodes. Designed for use with Inkscape. |
711 | +""" |
712 | |
713 | from Base import Barcode |
714 | |
715 | encoding = { |
716 | - '0' : '000110100', |
717 | - '1' : '100100001', |
718 | - '2' : '001100001', |
719 | - '3' : '101100000', |
720 | - '4' : '000110001', |
721 | - '5' : '100110000', |
722 | - '6' : '001110000', |
723 | - '7' : '000100101', |
724 | - '8' : '100100100', |
725 | - '9' : '001100100', |
726 | - 'A' : '100001001', |
727 | - 'B' : '001001001', |
728 | - 'C' : '101001000', |
729 | - 'D' : '000011001', |
730 | - 'E' : '100011000', |
731 | - 'F' : '001011000', |
732 | - 'G' : '000001101', |
733 | - 'H' : '100001100', |
734 | - 'I' : '001001100', |
735 | - 'J' : '000011100', |
736 | - 'K' : '100000011', |
737 | - 'L' : '001000011', |
738 | - 'M' : '101000010', |
739 | - 'N' : '000010011', |
740 | - 'O' : '100010010', |
741 | - 'P' : '001010010', |
742 | - 'Q' : '000000111', |
743 | - 'R' : '100000110', |
744 | - 'S' : '001000110', |
745 | - 'T' : '000010110', |
746 | - 'U' : '110000001', |
747 | - 'V' : '011000001', |
748 | - 'W' : '111000000', |
749 | - 'X' : '010010001', |
750 | - 'Y' : '110010000', |
751 | - 'Z' : '011010000', |
752 | - '-' : '010000101', |
753 | - '*' : '010010100', |
754 | - '+' : '010001010', |
755 | - '$' : '010101000', |
756 | - '%' : '000101010', |
757 | - '/' : '010100010', |
758 | - '.' : '110000100', |
759 | - ' ' : '011000100', |
760 | + '0' : '000110100', |
761 | + '1' : '100100001', |
762 | + '2' : '001100001', |
763 | + '3' : '101100000', |
764 | + '4' : '000110001', |
765 | + '5' : '100110000', |
766 | + '6' : '001110000', |
767 | + '7' : '000100101', |
768 | + '8' : '100100100', |
769 | + '9' : '001100100', |
770 | + 'A' : '100001001', |
771 | + 'B' : '001001001', |
772 | + 'C' : '101001000', |
773 | + 'D' : '000011001', |
774 | + 'E' : '100011000', |
775 | + 'F' : '001011000', |
776 | + 'G' : '000001101', |
777 | + 'H' : '100001100', |
778 | + 'I' : '001001100', |
779 | + 'J' : '000011100', |
780 | + 'K' : '100000011', |
781 | + 'L' : '001000011', |
782 | + 'M' : '101000010', |
783 | + 'N' : '000010011', |
784 | + 'O' : '100010010', |
785 | + 'P' : '001010010', |
786 | + 'Q' : '000000111', |
787 | + 'R' : '100000110', |
788 | + 'S' : '001000110', |
789 | + 'T' : '000010110', |
790 | + 'U' : '110000001', |
791 | + 'V' : '011000001', |
792 | + 'W' : '111000000', |
793 | + 'X' : '010010001', |
794 | + 'Y' : '110010000', |
795 | + 'Z' : '011010000', |
796 | + '-' : '010000101', |
797 | + '*' : '010010100', |
798 | + '+' : '010001010', |
799 | + '$' : '010101000', |
800 | + '%' : '000101010', |
801 | + '/' : '010100010', |
802 | + '.' : '110000100', |
803 | + ' ' : '011000100', |
804 | } |
805 | |
806 | class Object(Barcode): |
807 | - # Convert a text into string binary of black and white markers |
808 | - def encode(self, text): |
809 | - text = text.upper() |
810 | - self.label = text |
811 | - text = '*' + text + '*' |
812 | - result = '' |
813 | - # It isposible for us to encode code39 |
814 | - # into full ascii, but this feature is |
815 | - # not enabled here |
816 | - for char in text: |
817 | - if not encoding.has_key(char): |
818 | - char = '-'; |
819 | - |
820 | - result = result + encoding[char] + '0'; |
821 | - |
822 | - # Now we need to encode the code39, best read |
823 | - # the code to understand what it's up to: |
824 | - encoded = ''; |
825 | - colour = '1'; # 1 = Black, 0 = White |
826 | - for data in result: |
827 | - if data == '1': |
828 | - encoded = encoded + colour + colour |
829 | - else: |
830 | - encoded = encoded + colour |
831 | - if colour == '1': |
832 | - colour = '0' |
833 | - else: |
834 | - colour = '1' |
835 | - |
836 | - self.inclabel = text |
837 | - return encoded; |
838 | + # Convert a text into string binary of black and white markers |
839 | + def encode(self, text): |
840 | + text = text.upper() |
841 | + self.label = text |
842 | + text = '*' + text + '*' |
843 | + result = '' |
844 | + # It isposible for us to encode code39 |
845 | + # into full ascii, but this feature is |
846 | + # not enabled here |
847 | + for char in text: |
848 | + if not encoding.has_key(char): |
849 | + char = '-'; |
850 | + |
851 | + result = result + encoding[char] + '0'; |
852 | + |
853 | + # Now we need to encode the code39, best read |
854 | + # the code to understand what it's up to: |
855 | + encoded = ''; |
856 | + colour = '1'; # 1 = Black, 0 = White |
857 | + for data in result: |
858 | + if data == '1': |
859 | + encoded = encoded + colour + colour |
860 | + else: |
861 | + encoded = encoded + colour |
862 | + if colour == '1': |
863 | + colour = '0' |
864 | + else: |
865 | + colour = '1' |
866 | + |
867 | + self.inclabel = text |
868 | + return encoded; |
869 | |
870 | |
871 | === modified file 'share/extensions/Barcode/Code39Ext.py' |
872 | --- share/extensions/Barcode/Code39Ext.py 2010-07-22 22:18:09 +0000 |
873 | +++ share/extensions/Barcode/Code39Ext.py 2010-12-30 04:23:15 +0000 |
874 | @@ -1,21 +1,23 @@ |
875 | -#!/usr/bin/env python |
876 | -''' |
877 | -Copyright (C) 2007 Martin Owens |
878 | - |
879 | -This program is free software; you can redistribute it and/or modify |
880 | -it under the terms of the GNU General Public License as published by |
881 | -the Free Software Foundation; either version 2 of the License, or |
882 | -(at your option) any later version. |
883 | - |
884 | -This program is distributed in the hope that it will be useful, |
885 | -but WITHOUT ANY WARRANTY; without even the implied warranty of |
886 | -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
887 | -GNU General Public License for more details. |
888 | - |
889 | -You should have received a copy of the GNU General Public License |
890 | -along with this program; if not, write to the Free Software |
891 | -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
892 | -''' |
893 | +# |
894 | +# Copyright (C) 2007 Martin Owens |
895 | +# |
896 | +# This program is free software; you can redistribute it and/or modify |
897 | +# it under the terms of the GNU General Public License as published by |
898 | +# the Free Software Foundation; either version 2 of the License, or |
899 | +# (at your option) any later version. |
900 | +# |
901 | +# This program is distributed in the hope that it will be useful, |
902 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
903 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
904 | +# GNU General Public License for more details. |
905 | +# |
906 | +# You should have received a copy of the GNU General Public License |
907 | +# along with this program; if not, write to the Free Software |
908 | +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
909 | +# |
910 | +""" |
911 | +Python barcode renderer for Code39 Extended barcodes. Designed for Inkscape. |
912 | +""" |
913 | |
914 | import Code39 |
915 | |
916 | @@ -25,18 +27,18 @@ |
917 | |
918 | i = 0 |
919 | for char in encode: |
920 | - map[char] = i |
921 | - i = i + 1 |
922 | + map[char] = i |
923 | + i = i + 1 |
924 | |
925 | # Extended encoding maps for full ASCII Code93 |
926 | def getMap(array): |
927 | - result = {} |
928 | - y = 0 |
929 | - for x in array: |
930 | - result[chr(x)] = encode[y] |
931 | - y = y + 1 |
932 | + result = {} |
933 | + y = 0 |
934 | + for x in array: |
935 | + result[chr(x)] = encode[y] |
936 | + y = y + 1 |
937 | |
938 | - return result; |
939 | + return result; |
940 | |
941 | # MapA is eclectic, but B, C, D are all ASCII ranges |
942 | 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]) # % |
943 | @@ -45,19 +47,19 @@ |
944 | mapD = getMap(range(97, 122)) # + |
945 | |
946 | class Object(Code39.Object): |
947 | - def encode(self, text): |
948 | - # We are only going to extend the Code39 barcodes |
949 | - result = '' |
950 | - for char in text: |
951 | - if mapA.has_key(char): |
952 | - char = '%' + mapA[char] |
953 | - elif mapB.has_key(char): |
954 | - char = '$' + mapB[char] |
955 | - elif mapC.has_key(char): |
956 | - char = '/' + mapC[char] |
957 | - elif mapD.has_key(char): |
958 | - char = '+' + mapD[char] |
959 | - result = result + char |
960 | + def encode(self, text): |
961 | + # We are only going to extend the Code39 barcodes |
962 | + result = '' |
963 | + for char in text: |
964 | + if mapA.has_key(char): |
965 | + char = '%' + mapA[char] |
966 | + elif mapB.has_key(char): |
967 | + char = '$' + mapB[char] |
968 | + elif mapC.has_key(char): |
969 | + char = '/' + mapC[char] |
970 | + elif mapD.has_key(char): |
971 | + char = '+' + mapD[char] |
972 | + result = result + char |
973 | |
974 | - return Code39.Object.encode(self, result); |
975 | + return Code39.Object.encode(self, result); |
976 | |
977 | |
978 | === modified file 'share/extensions/Barcode/Code93.py' |
979 | --- share/extensions/Barcode/Code93.py 2010-07-22 22:18:09 +0000 |
980 | +++ share/extensions/Barcode/Code93.py 2010-12-30 04:23:15 +0000 |
981 | @@ -1,21 +1,23 @@ |
982 | -#!/usr/bin/env python |
983 | -''' |
984 | -Copyright (C) 2007 Martin Owens |
985 | - |
986 | -This program is free software; you can redistribute it and/or modify |
987 | -it under the terms of the GNU General Public License as published by |
988 | -the Free Software Foundation; either version 2 of the License, or |
989 | -(at your option) any later version. |
990 | - |
991 | -This program is distributed in the hope that it will be useful, |
992 | -but WITHOUT ANY WARRANTY; without even the implied warranty of |
993 | -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
994 | -GNU General Public License for more details. |
995 | - |
996 | -You should have received a copy of the GNU General Public License |
997 | -along with this program; if not, write to the Free Software |
998 | -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
999 | -''' |
1000 | +# |
1001 | +# Copyright (C) 2007 Martin Owens |
1002 | +# |
1003 | +# This program is free software; you can redistribute it and/or modify |
1004 | +# it under the terms of the GNU General Public License as published by |
1005 | +# the Free Software Foundation; either version 2 of the License, or |
1006 | +# (at your option) any later version. |
1007 | +# |
1008 | +# This program is distributed in the hope that it will be useful, |
1009 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
1010 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1011 | +# GNU General Public License for more details. |
1012 | +# |
1013 | +# You should have received a copy of the GNU General Public License |
1014 | +# along with this program; if not, write to the Free Software |
1015 | +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
1016 | +# |
1017 | +""" |
1018 | +Python barcode renderer for Code93 barcodes. Designed for use with Inkscape. |
1019 | +""" |
1020 | |
1021 | from Base import Barcode |
1022 | |
1023 | @@ -31,20 +33,20 @@ |
1024 | |
1025 | i = 0 |
1026 | for char in encode: |
1027 | - map[char] = i |
1028 | - i = i + 1 |
1029 | + map[char] = i |
1030 | + i = i + 1 |
1031 | |
1032 | # Extended encoding maps for full ASCII Code93 |
1033 | def getMap(array): |
1034 | |
1035 | - result = {} |
1036 | - y = 10 |
1037 | - |
1038 | - for x in array: |
1039 | - result[chr(x)] = encode[y] |
1040 | - y = y + 1 |
1041 | - |
1042 | - return result; |
1043 | + result = {} |
1044 | + y = 10 |
1045 | + |
1046 | + for x in array: |
1047 | + result[chr(x)] = encode[y] |
1048 | + y = y + 1 |
1049 | + |
1050 | + return result; |
1051 | |
1052 | # MapA is eclectic, but B, C, D are all ASCII ranges |
1053 | 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]) # % |
1054 | @@ -55,65 +57,65 @@ |
1055 | 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() |
1056 | |
1057 | class Object(Barcode): |
1058 | - def encode(self, text): |
1059 | - # start marker |
1060 | - bits = self.encode93('MARKER') |
1061 | - |
1062 | - # Extend to ASCII charset ( return Array ) |
1063 | - text = self.encodeAscii(text) |
1064 | - |
1065 | - # Calculate the checksums |
1066 | - text.append(self.checksum(text, 20)) # C |
1067 | - text.append(self.checksum(text, 15)) # K |
1068 | - |
1069 | - # Now convert text into the encoding bits (black and white stripes) |
1070 | - for char in text: |
1071 | - bits = bits + self.encode93(char) |
1072 | - |
1073 | - # end marker |
1074 | - bits = bits + self.encode93('MARKER') |
1075 | - |
1076 | - # termination bar |
1077 | - bits = bits + '1' |
1078 | + def encode(self, text): |
1079 | + # start marker |
1080 | + bits = self.encode93('MARKER') |
1081 | + |
1082 | + # Extend to ASCII charset ( return Array ) |
1083 | + text = self.encodeAscii(text) |
1084 | + |
1085 | + # Calculate the checksums |
1086 | + text.append(self.checksum(text, 20)) # C |
1087 | + text.append(self.checksum(text, 15)) # K |
1088 | + |
1089 | + # Now convert text into the encoding bits (black and white stripes) |
1090 | + for char in text: |
1091 | + bits = bits + self.encode93(char) |
1092 | + |
1093 | + # end marker |
1094 | + bits = bits + self.encode93('MARKER') |
1095 | + |
1096 | + # termination bar |
1097 | + bits = bits + '1' |
1098 | |
1099 | - self.inclabel = text |
1100 | - return bits |
1101 | - |
1102 | - def checksum(self, text, mod): |
1103 | - weight = len(text) % mod |
1104 | - check = 0 |
1105 | - for char in text: |
1106 | - check = check + (map[char] * weight) |
1107 | - # Reset the weight is required |
1108 | - weight = weight - 1 |
1109 | - if weight == 0: |
1110 | - weight = mod |
1111 | - |
1112 | - return encode[check % 47] |
1113 | - |
1114 | - # Some charicters need re-encoding into the code93 specification |
1115 | - def encodeAscii(self, text): |
1116 | - result = [] |
1117 | - for char in text: |
1118 | - if map.has_key(char): |
1119 | - result.append(char) |
1120 | - elif mapA.has_key(char): |
1121 | - result.append('(%)') |
1122 | - result.append(mapA[char]) |
1123 | - elif mapB.has_key(char): |
1124 | - result.append('($)') |
1125 | - result.append(mapB[char]) |
1126 | - elif mapC.has_key(char): |
1127 | - result.append('(/)') |
1128 | - result.append(mapC[char]) |
1129 | - elif mapD.has_key(char): |
1130 | - result.append('(+)') |
1131 | - result.append(mapD[char]) |
1132 | - |
1133 | - return result |
1134 | - |
1135 | - def encode93(self, char): |
1136 | - if map.has_key(char): |
1137 | - return encoding[map[char]] |
1138 | - return '' |
1139 | + self.inclabel = text |
1140 | + return bits |
1141 | + |
1142 | + def checksum(self, text, mod): |
1143 | + weight = len(text) % mod |
1144 | + check = 0 |
1145 | + for char in text: |
1146 | + check = check + (map[char] * weight) |
1147 | + # Reset the weight is required |
1148 | + weight = weight - 1 |
1149 | + if weight == 0: |
1150 | + weight = mod |
1151 | + |
1152 | + return encode[check % 47] |
1153 | + |
1154 | + # Some charicters need re-encoding into the code93 specification |
1155 | + def encodeAscii(self, text): |
1156 | + result = [] |
1157 | + for char in text: |
1158 | + if map.has_key(char): |
1159 | + result.append(char) |
1160 | + elif mapA.has_key(char): |
1161 | + result.append('(%)') |
1162 | + result.append(mapA[char]) |
1163 | + elif mapB.has_key(char): |
1164 | + result.append('($)') |
1165 | + result.append(mapB[char]) |
1166 | + elif mapC.has_key(char): |
1167 | + result.append('(/)') |
1168 | + result.append(mapC[char]) |
1169 | + elif mapD.has_key(char): |
1170 | + result.append('(+)') |
1171 | + result.append(mapD[char]) |
1172 | + |
1173 | + return result |
1174 | + |
1175 | + def encode93(self, char): |
1176 | + if map.has_key(char): |
1177 | + return encoding[map[char]] |
1178 | + return '' |
1179 | |
1180 | |
1181 | === modified file 'share/extensions/Barcode/EAN13.py' |
1182 | --- share/extensions/Barcode/EAN13.py 2010-07-22 22:18:09 +0000 |
1183 | +++ share/extensions/Barcode/EAN13.py 2010-12-30 04:23:15 +0000 |
1184 | @@ -1,101 +1,38 @@ |
1185 | -#!/usr/bin/env python |
1186 | -''' |
1187 | -Copyright (C) 2007 Martin Owens |
1188 | - |
1189 | -Thanks to Lineaire Chez of Inkbar ( www.inkbar.lineaire.net ) |
1190 | - |
1191 | -This program is free software; you can redistribute it and/or modify |
1192 | -it under the terms of the GNU General Public License as published by |
1193 | -the Free Software Foundation; either version 2 of the License, or |
1194 | -(at your option) any later version. |
1195 | - |
1196 | -This program is distributed in the hope that it will be useful, |
1197 | -but WITHOUT ANY WARRANTY; without even the implied warranty of |
1198 | -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1199 | -GNU General Public License for more details. |
1200 | - |
1201 | -You should have received a copy of the GNU General Public License |
1202 | -along with this program; if not, write to the Free Software |
1203 | -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
1204 | -''' |
1205 | - |
1206 | -from Base import Barcode |
1207 | -import sys |
1208 | - |
1209 | -mapLeftFaimly = [ |
1210 | - [ "0001101","0011001","0010011","0111101","0100011","0110001","0101111","0111011","0110111","0001011" ], |
1211 | - [ "0100111","0110011","0011011","0100001","0011101","0111001","0000101","0010001","0001001","0010111" ], |
1212 | -] |
1213 | -mapRight = [ "1110010","1100110","1101100","1000010","1011100","1001110","1010000","1000100","1001000","1110100" ] |
1214 | -mapFaimly = [ '000000','001011','001101','001110','010011','011001','011100','010101','010110','011010' ] |
1215 | - |
1216 | -guardBar = '202'; |
1217 | -centerBar = '02020'; |
1218 | - |
1219 | -class Object(Barcode): |
1220 | - def encode(self, number): |
1221 | - result = '' |
1222 | - |
1223 | - if len(number) < 12 or len(number) > 13 or not number.isdigit(): |
1224 | - sys.stderr.write("Can not encode '" + number + "' into EAN13 Barcode, Size must be 12 numbers only\n") |
1225 | - return |
1226 | - |
1227 | - if len(number) == 12: |
1228 | - number = number + self.getChecksum(number) |
1229 | - else: |
1230 | - if not self.verifyChecksum(number): |
1231 | - sys.stderr.write("EAN13 Checksum not correct for this barcode, omit last character to generate new checksum.\n") |
1232 | - return |
1233 | - |
1234 | - result = result + guardBar |
1235 | - family = mapFaimly[int(number[0])] |
1236 | - |
1237 | - i = 0 |
1238 | - for i in range(0,6): |
1239 | - mapLeft = mapLeftFaimly[int(family[i])] |
1240 | - result += mapLeft[int(number[i+1])] |
1241 | - |
1242 | - result += centerBar |
1243 | - |
1244 | - for i in range (7,13): |
1245 | - result += mapRight[int(number[i])] |
1246 | - |
1247 | - result = result + guardBar; |
1248 | - |
1249 | - self.label = number[0] + ' ' + number[1:7] + ' ' + number[7:] + ' ' |
1250 | - self.inclabel = self.label |
1251 | - return result; |
1252 | - |
1253 | - def getChecksum(self, number): |
1254 | - # UPCA/EAN13 |
1255 | - weight=[3,1]*6 |
1256 | - magic=10 |
1257 | - sum = 0 |
1258 | - # We need to work from left to right so reverse |
1259 | - number = number[::-1] |
1260 | - # checksum based on first 12 digits. |
1261 | - for i in range(len(number)): |
1262 | - sum = sum + int(number[i]) * weight[i] |
1263 | - |
1264 | - # Mod it down to a single digit |
1265 | - z = ( magic - (sum % magic) ) % magic |
1266 | - if z < 0 or z >= magic: |
1267 | - return 0 |
1268 | - |
1269 | - return str(z) |
1270 | - |
1271 | - def verifyChecksum(self, number): |
1272 | - new = self.getChecksum(number[:-1]) |
1273 | - existing = number[-1] |
1274 | - return new == existing |
1275 | - |
1276 | - def getStyle(self, index): |
1277 | - result = { 'width' : '1', 'top' : int(self.y), 'write' : True } |
1278 | - if index==0: # White Space |
1279 | - result['write'] = False |
1280 | - elif index==1: # Black Bar |
1281 | - result['height'] = int(self.height) |
1282 | - elif index==2: # Guide Bar |
1283 | - result['height'] = int(self.height) + 5 |
1284 | - return result |
1285 | +# |
1286 | +# Copyright (C) 2010 Martin Owens |
1287 | +# |
1288 | +# Thanks to Lineaire Chez of Inkbar ( www.inkbar.lineaire.net ) |
1289 | +# |
1290 | +# This program is free software; you can redistribute it and/or modify |
1291 | +# it under the terms of the GNU General Public License as published by |
1292 | +# the Free Software Foundation; either version 2 of the License, or |
1293 | +# (at your option) any later version. |
1294 | +# |
1295 | +# This program is distributed in the hope that it will be useful, |
1296 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
1297 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1298 | +# GNU General Public License for more details. |
1299 | +# |
1300 | +# You should have received a copy of the GNU General Public License |
1301 | +# along with this program; if not, write to the Free Software |
1302 | +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
1303 | +# |
1304 | +""" |
1305 | +Python barcode renderer for EAN13 barcodes. Designed for use with Inkscape. |
1306 | +""" |
1307 | + |
1308 | +from BaseEan import EanBarcode |
1309 | + |
1310 | +class Object(EanBarcode): |
1311 | + """Provide an Ean13 barcode generator""" |
1312 | + name = 'ean13' |
1313 | + lengths = [ 12 ] |
1314 | + checks = [ 13 ] |
1315 | + |
1316 | + def _encode(self, n): |
1317 | + """Encode an ean13 barcode""" |
1318 | + self.label = self.space(n[0:1], 4, n[1:7], 5, n[7:], 7) |
1319 | + return self.enclose( |
1320 | + self.encode_interleaved(n[0], n[1:7]), self.encode_right(n[7:]) ) |
1321 | + |
1322 | |
1323 | |
1324 | === modified file 'share/extensions/Barcode/EAN5.py' |
1325 | --- share/extensions/Barcode/EAN5.py 2010-07-22 22:18:09 +0000 |
1326 | +++ share/extensions/Barcode/EAN5.py 2010-12-30 04:23:15 +0000 |
1327 | @@ -1,68 +1,39 @@ |
1328 | -#!/usr/bin/env python |
1329 | -''' |
1330 | -Copyright (C) 2007 Martin Owens |
1331 | -Copyright (C) 2009 Aaron C Spike |
1332 | - |
1333 | -Thanks to Lineaire Chez of Inkbar ( www.inkbar.lineaire.net ) |
1334 | - |
1335 | -This program is free software; you can redistribute it and/or modify |
1336 | -it under the terms of the GNU General Public License as published by |
1337 | -the Free Software Foundation; either version 2 of the License, or |
1338 | -(at your option) any later version. |
1339 | - |
1340 | -This program is distributed in the hope that it will be useful, |
1341 | -but WITHOUT ANY WARRANTY; without even the implied warranty of |
1342 | -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1343 | -GNU General Public License for more details. |
1344 | - |
1345 | -You should have received a copy of the GNU General Public License |
1346 | -along with this program; if not, write to the Free Software |
1347 | -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
1348 | -''' |
1349 | - |
1350 | -from Base import Barcode |
1351 | -import sys |
1352 | - |
1353 | -mapLeftFamily = [ |
1354 | - [ "0001101","0011001","0010011","0111101","0100011","0110001","0101111","0111011","0110111","0001011" ], #L |
1355 | - [ "0100111","0110011","0011011","0100001","0011101","0111001","0000101","0010001","0001001","0010111" ], #G |
1356 | -] |
1357 | -mapFamily = [ '11000','10100','10010','10001','01100','00110','00011','01010','01001','00101' ] |
1358 | - |
1359 | -startBar = '01011'; |
1360 | -sepBar = '01'; |
1361 | - |
1362 | -class Object(Barcode): |
1363 | - def encode(self, number): |
1364 | - result = [] |
1365 | - self.x += 110.0 # horizontal offset so it does not overlap EAN13 |
1366 | +# |
1367 | +# Copyright (C) 2009 Aaron C Spike |
1368 | +# 2010 Martin Owens |
1369 | +# |
1370 | +# This program is free software; you can redistribute it and/or modify |
1371 | +# it under the terms of the GNU General Public License as published by |
1372 | +# the Free Software Foundation; either version 2 of the License, or |
1373 | +# (at your option) any later version. |
1374 | +# |
1375 | +# This program is distributed in the hope that it will be useful, |
1376 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
1377 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1378 | +# GNU General Public License for more details. |
1379 | +# |
1380 | +# You should have received a copy of the GNU General Public License |
1381 | +# along with this program; if not, write to the Free Software |
1382 | +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
1383 | +# |
1384 | +""" |
1385 | +Python barcode renderer for EAN5 barcodes. Designed for use with Inkscape. |
1386 | +""" |
1387 | + |
1388 | +from BaseEan import EanBarcode |
1389 | + |
1390 | +FAMS = [ '11000','10100','10010','10001','01100','00110','00011','01010','01001','00101' ] |
1391 | +START = '01011' |
1392 | + |
1393 | +class Object(EanBarcode): |
1394 | + """Provide an Ean5 barcode generator""" |
1395 | + name = 'ean5' |
1396 | + length = 5 |
1397 | + |
1398 | + def _encode(self, number): |
1399 | + self.x += 110.0 # horiz offset so it does not overlap EAN13 |
1400 | self.y -= self.height + 5 # move the text to the top |
1401 | - if len(number) != 5 or not number.isdigit(): |
1402 | - sys.stderr.write("Can not encode '" + number + "' into EAN5 Barcode, Size must be 5 numbers only\n") |
1403 | - return |
1404 | - |
1405 | - check = self.getChecksum(number) |
1406 | - family = mapFamily[check] |
1407 | - |
1408 | - for i in range(5): |
1409 | - mapLeft = mapLeftFamily[int(family[i])] |
1410 | - result.append(mapLeft[int(number[i])]) |
1411 | - |
1412 | - self.label = number[0] |
1413 | - for i in range(1,5): |
1414 | - self.label += ' ' + number[i] |
1415 | - self.inclabel = self.label |
1416 | - return startBar + '01'.join(result) |
1417 | - |
1418 | - def getChecksum(self, number): |
1419 | - return sum([int(n)*int(m) for n,m in zip(number, '39393')]) % 10 |
1420 | - |
1421 | - def getStyle(self, index): |
1422 | - result = { 'width' : '1', 'top' : int(self.y) + self.height + 5 + int(self.fontSize()), 'write' : True } |
1423 | - if index==0: # White Space |
1424 | - result['write'] = False |
1425 | - elif index==1: # Black Bar |
1426 | - result['height'] = int(self.height) |
1427 | - elif index==2: # Guide Bar |
1428 | - result['height'] = int(self.height) + 5 |
1429 | - return result |
1430 | + self.label = ' '.join(self.space(number)) |
1431 | + family = sum([int(n)*int(m) for n,m in zip(number, '39393')]) % 10 |
1432 | + return START + '01'.join(self.encode_interleaved(family, number, FAMS)) |
1433 | + |
1434 | |
1435 | === modified file 'share/extensions/Barcode/EAN8.py' |
1436 | --- share/extensions/Barcode/EAN8.py 2010-07-22 22:18:09 +0000 |
1437 | +++ share/extensions/Barcode/EAN8.py 2010-12-30 04:23:15 +0000 |
1438 | @@ -1,84 +1,34 @@ |
1439 | -#!/usr/bin/env python |
1440 | -''' |
1441 | -Copyright (C) 2007 Martin Owens |
1442 | - |
1443 | -This program is free software; you can redistribute it and/or modify |
1444 | -it under the terms of the GNU General Public License as published by |
1445 | -the Free Software Foundation; either version 2 of the License, or |
1446 | -(at your option) any later version. |
1447 | - |
1448 | -This program is distributed in the hope that it will be useful, |
1449 | -but WITHOUT ANY WARRANTY; without even the implied warranty of |
1450 | -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1451 | -GNU General Public License for more details. |
1452 | - |
1453 | -You should have received a copy of the GNU General Public License |
1454 | -along with this program; if not, write to the Free Software |
1455 | -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
1456 | -''' |
1457 | - |
1458 | -from Base import Barcode |
1459 | -import sys |
1460 | - |
1461 | -leftMap = [ '0001101', '0011001', '0010011', '0111101', '0100011', '0110001', '0101111', '0111011', '0110111', '0001011' ] |
1462 | -rightMap = [ '1110010', '1100110', '1101100', '1000010', '1011100', '1001110', '1010000', '1000100', '1001000', '1110100' ] |
1463 | -weightMap = [ 3, 1, 3, 1, 3, 1, 3 ] |
1464 | - |
1465 | -guardBar = '202'; |
1466 | -centerBar = '02020'; |
1467 | - |
1468 | -class Object(Barcode): |
1469 | - def encode(self, number): |
1470 | - result = '' |
1471 | - |
1472 | - # Rejig the label for use |
1473 | - self.label = number[:4] + ' ' + number[4:] |
1474 | - |
1475 | - if len(number) < 7 or len(number) > 8 or not number.isdigit(): |
1476 | - sys.stderr.write("Can not encode '" + number + "' into EAN8 Barcode, Size must be 7 or 8 Numbers only\n") |
1477 | - |
1478 | - if len(number) == 7: |
1479 | - number = number + self.calculateChecksum(number) |
1480 | - |
1481 | - result = result + guardBar |
1482 | - |
1483 | - i = 0 |
1484 | - for num in number: |
1485 | - if i >= 4: |
1486 | - result = result + rightMap[int(num)] |
1487 | - else: |
1488 | - result = result + leftMap[int(num)] |
1489 | - |
1490 | - i = i + 1 |
1491 | - if i == 4: |
1492 | - result = result + centerBar; |
1493 | - |
1494 | - result = result + guardBar; |
1495 | - |
1496 | - self.inclabel = ' ' + number[:4] + ' ' + number[4:] |
1497 | - return result; |
1498 | - |
1499 | - |
1500 | - def calculateChecksum(self, number): |
1501 | - weight = 0; |
1502 | - i = 0; |
1503 | - |
1504 | - for num in number: |
1505 | - weight = weight + (int(num) * weightMap[i]) |
1506 | - i = i + 1 |
1507 | - |
1508 | - weight = 10 - (weight % 10) |
1509 | - if weight == 10: |
1510 | - weight = 0 |
1511 | - return str(weight); |
1512 | - |
1513 | - def getStyle(self, index): |
1514 | - result = { 'width' : '1', 'top' : int(self.y), 'write' : True } |
1515 | - if index==0: # White Space |
1516 | - result['write'] = False |
1517 | - elif index==1: # Black Bar |
1518 | - result['height'] = int(self.height) |
1519 | - elif index==2: # Guide Bar |
1520 | - result['height'] = int(self.height) + 8 |
1521 | - return result |
1522 | +# |
1523 | +# Copyright (C) 2010 Martin Owens |
1524 | +# |
1525 | +# This program is free software; you can redistribute it and/or modify |
1526 | +# it under the terms of the GNU General Public License as published by |
1527 | +# the Free Software Foundation; either version 2 of the License, or |
1528 | +# (at your option) any later version. |
1529 | +# |
1530 | +# This program is distributed in the hope that it will be useful, |
1531 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
1532 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1533 | +# GNU General Public License for more details. |
1534 | +# |
1535 | +# You should have received a copy of the GNU General Public License |
1536 | +# along with this program; if not, write to the Free Software |
1537 | +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
1538 | +# |
1539 | +""" |
1540 | +Python barcode renderer for EAN8 barcodes. Designed for use with Inkscape. |
1541 | +""" |
1542 | + |
1543 | +from BaseEan import EanBarcode |
1544 | + |
1545 | +class Object(EanBarcode): |
1546 | + """Provide an EAN8 barcode generator""" |
1547 | + name = 'ean8' |
1548 | + lengths = [ 7 ] |
1549 | + checks = [ 8 ] |
1550 | + |
1551 | + def _encode(self, n): |
1552 | + """Encode an ean8 barcode""" |
1553 | + self.label = self.space(n[:4], 3, n[4:]) |
1554 | + return self.enclose( self.encode_left(n[:4]), self.encode_right(n[4:]) ) |
1555 | |
1556 | |
1557 | === modified file 'share/extensions/Barcode/Makefile.am' |
1558 | --- share/extensions/Barcode/Makefile.am 2009-12-21 23:48:17 +0000 |
1559 | +++ share/extensions/Barcode/Makefile.am 2010-12-30 04:23:15 +0000 |
1560 | @@ -3,9 +3,11 @@ |
1561 | |
1562 | barcode_SCRIPTS = \ |
1563 | Base.py \ |
1564 | + BaseEan.py \ |
1565 | Code128.py \ |
1566 | Code39Ext.py \ |
1567 | Code39.py \ |
1568 | + Code25i.py \ |
1569 | Code93.py \ |
1570 | EAN13.py \ |
1571 | EAN8.py \ |
1572 | |
1573 | === modified file 'share/extensions/Barcode/RM4CC.py' |
1574 | --- share/extensions/Barcode/RM4CC.py 2010-07-22 22:18:09 +0000 |
1575 | +++ share/extensions/Barcode/RM4CC.py 2010-12-30 04:23:15 +0000 |
1576 | @@ -1,131 +1,135 @@ |
1577 | -#!/usr/bin/env python |
1578 | -''' |
1579 | -Copyright (C) 2007 Martin Owens |
1580 | - |
1581 | -This program is free software; you can redistribute it and/or modify |
1582 | -it under the terms of the GNU General Public License as published by |
1583 | -the Free Software Foundation; either version 2 of the License, or |
1584 | -(at your option) any later version. |
1585 | - |
1586 | -This program is distributed in the hope that it will be useful, |
1587 | -but WITHOUT ANY WARRANTY; without even the implied warranty of |
1588 | -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1589 | -GNU General Public License for more details. |
1590 | - |
1591 | -You should have received a copy of the GNU General Public License |
1592 | -along with this program; if not, write to the Free Software |
1593 | -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
1594 | -''' |
1595 | +# |
1596 | +# Copyright (C) 2007 Martin Owens |
1597 | +# |
1598 | +# This program is free software; you can redistribute it and/or modify |
1599 | +# it under the terms of the GNU General Public License as published by |
1600 | +# the Free Software Foundation; either version 2 of the License, or |
1601 | +# (at your option) any later version. |
1602 | +# |
1603 | +# This program is distributed in the hope that it will be useful, |
1604 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
1605 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1606 | +# GNU General Public License for more details. |
1607 | +# |
1608 | +# You should have received a copy of the GNU General Public License |
1609 | +# along with this program; if not, write to the Free Software |
1610 | +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
1611 | +# |
1612 | +""" |
1613 | +Python barcode renderer for RM4CC barcodes. Designed for use with Inkscape. |
1614 | +""" |
1615 | |
1616 | from Base import Barcode |
1617 | |
1618 | map = { |
1619 | - '(' : '25', |
1620 | - ')' : '3', |
1621 | - '0' : '05053535', |
1622 | - '1' : '05152535', |
1623 | - '2' : '05153525', |
1624 | - '3' : '15052535', |
1625 | - '4' : '15053525', |
1626 | - '5' : '15152525', |
1627 | - '6' : '05251535', |
1628 | - '7' : '05350535', |
1629 | - '8' : '05351525', |
1630 | - '9' : '15250535', |
1631 | - 'A' : '15251525', |
1632 | - 'B' : '15350525', |
1633 | - 'C' : '05253515', |
1634 | - 'D' : '05352515', |
1635 | - 'E' : '05353505', |
1636 | - 'F' : '15252515', |
1637 | - 'G' : '15253505', |
1638 | - 'H' : '15352505', |
1639 | - 'I' : '25051535', |
1640 | - 'J' : '25150535', |
1641 | - 'K' : '25151525', |
1642 | - 'L' : '35050535', |
1643 | - 'M' : '35051525', |
1644 | - 'N' : '35150525', |
1645 | - 'O' : '25053525', |
1646 | - 'P' : '25152515', |
1647 | - 'Q' : '25153505', |
1648 | - 'R' : '35052515', |
1649 | - 'S' : '35053505', |
1650 | - 'T' : '35152505', |
1651 | - 'U' : '25251515', |
1652 | - 'V' : '25350515', |
1653 | - 'W' : '25351505', |
1654 | - 'X' : '35250515', |
1655 | - 'Y' : '35251505', |
1656 | - 'Z' : '35350505', |
1657 | + '(' : '25', |
1658 | + ')' : '3', |
1659 | + '0' : '05053535', |
1660 | + '1' : '05152535', |
1661 | + '2' : '05153525', |
1662 | + '3' : '15052535', |
1663 | + '4' : '15053525', |
1664 | + '5' : '15152525', |
1665 | + '6' : '05251535', |
1666 | + '7' : '05350535', |
1667 | + '8' : '05351525', |
1668 | + '9' : '15250535', |
1669 | + 'A' : '15251525', |
1670 | + 'B' : '15350525', |
1671 | + 'C' : '05253515', |
1672 | + 'D' : '05352515', |
1673 | + 'E' : '05353505', |
1674 | + 'F' : '15252515', |
1675 | + 'G' : '15253505', |
1676 | + 'H' : '15352505', |
1677 | + 'I' : '25051535', |
1678 | + 'J' : '25150535', |
1679 | + 'K' : '25151525', |
1680 | + 'L' : '35050535', |
1681 | + 'M' : '35051525', |
1682 | + 'N' : '35150525', |
1683 | + 'O' : '25053525', |
1684 | + 'P' : '25152515', |
1685 | + 'Q' : '25153505', |
1686 | + 'R' : '35052515', |
1687 | + 'S' : '35053505', |
1688 | + 'T' : '35152505', |
1689 | + 'U' : '25251515', |
1690 | + 'V' : '25350515', |
1691 | + 'W' : '25351505', |
1692 | + 'X' : '35250515', |
1693 | + 'Y' : '35251505', |
1694 | + 'Z' : '35350505', |
1695 | } |
1696 | |
1697 | check = ['ZUVWXY','501234','B6789A','HCDEFG','NIJKLM','TOPQRS'] |
1698 | +(BAR_TRACK, BAR_DOWN, BAR_UP, BAR_FULL, BAR_NONE, WHITE_SPACE) = range(6) |
1699 | |
1700 | class Object(Barcode): |
1701 | - def encode(self, text): |
1702 | - result = '' |
1703 | - |
1704 | - self.height = 18 |
1705 | - text = text.upper() |
1706 | - text.replace('(', '') |
1707 | - text.replace(')', '') |
1708 | - |
1709 | - text = '(' + text + self.checksum(text) + ')' |
1710 | - |
1711 | - i = 0 |
1712 | - for char in text: |
1713 | - if map.has_key(char): |
1714 | - result = result + map[char] |
1715 | - |
1716 | - i = i + 1 |
1717 | - |
1718 | - self.inclabel = text |
1719 | - return result; |
1720 | - |
1721 | - # given a string of data, return the check character |
1722 | - def checksum(self, text): |
1723 | - total_lower = 0 |
1724 | - total_upper = 0 |
1725 | - for char in text: |
1726 | - if map.has_key(char): |
1727 | - bars = map[char][0:8:2] |
1728 | - lower = 0 |
1729 | - upper = 0 |
1730 | - |
1731 | - if int(bars[0]) & 1: |
1732 | - lower = lower + 4 |
1733 | - if int(bars[1]) & 1: |
1734 | - lower = lower + 2 |
1735 | - if int(bars[2]) & 1: |
1736 | - lower = lower + 1 |
1737 | - if int(bars[0]) & 2: |
1738 | - upper = upper + 4 |
1739 | - if int(bars[1]) & 2: |
1740 | - upper = upper + 2 |
1741 | - if int(bars[2]) & 2: |
1742 | - upper = upper + 1 |
1743 | - total_lower = total_lower + (lower % 6) |
1744 | - total_upper = total_upper + (upper % 6) |
1745 | - |
1746 | - total_lower = total_upper % 6 |
1747 | - total_upper = total_upper % 6 |
1748 | - |
1749 | - checkchar = check[total_upper][total_lower] |
1750 | - return checkchar |
1751 | - |
1752 | - def getStyle(self, index): |
1753 | - result = { 'width' : 2, 'write' : True, 'top' : int(self.y) } |
1754 | - if index==0: # Track Bar |
1755 | - result['top'] = result['top'] + 6 |
1756 | - result['height'] = 5 |
1757 | - elif index==1: # Decender Bar |
1758 | - result['top'] = result['top'] + 6 |
1759 | - result['height'] = 11 |
1760 | - elif index==2: # Accender Bar |
1761 | - result['height'] = 11 |
1762 | - elif index==3: # Full Bar |
1763 | - result['height'] = 17 |
1764 | - elif index==5: # White Space |
1765 | - result['write'] = False |
1766 | - return result |
1767 | + def encode(self, text): |
1768 | + result = '' |
1769 | + |
1770 | + self.height = 18 |
1771 | + text = text.upper() |
1772 | + text.replace('(', '') |
1773 | + text.replace(')', '') |
1774 | + |
1775 | + text = '(' + text + self.checksum(text) + ')' |
1776 | + |
1777 | + i = 0 |
1778 | + for char in text: |
1779 | + if map.has_key(char): |
1780 | + result = result + map[char] |
1781 | + |
1782 | + i = i + 1 |
1783 | + |
1784 | + self.inclabel = text |
1785 | + return result; |
1786 | + |
1787 | + # given a string of data, return the check character |
1788 | + def checksum(self, text): |
1789 | + total_lower = 0 |
1790 | + total_upper = 0 |
1791 | + for char in text: |
1792 | + if map.has_key(char): |
1793 | + bars = map[char][0:8:2] |
1794 | + lower = 0 |
1795 | + upper = 0 |
1796 | + |
1797 | + if int(bars[0]) & 1: |
1798 | + lower = lower + 4 |
1799 | + if int(bars[1]) & 1: |
1800 | + lower = lower + 2 |
1801 | + if int(bars[2]) & 1: |
1802 | + lower = lower + 1 |
1803 | + if int(bars[0]) & 2: |
1804 | + upper = upper + 4 |
1805 | + if int(bars[1]) & 2: |
1806 | + upper = upper + 2 |
1807 | + if int(bars[2]) & 2: |
1808 | + upper = upper + 1 |
1809 | + total_lower = total_lower + (lower % 6) |
1810 | + total_upper = total_upper + (upper % 6) |
1811 | + |
1812 | + total_lower = total_upper % 6 |
1813 | + total_upper = total_upper % 6 |
1814 | + |
1815 | + checkchar = check[total_upper][total_lower] |
1816 | + return checkchar |
1817 | + |
1818 | + def getStyle(self, index): |
1819 | + """Royal Mail Barcodes use a completely different style""" |
1820 | + result = { 'width' : 2, 'write' : True, 'top' : 0 } |
1821 | + if index == BAR_TRACK: # Track Bar |
1822 | + result['top'] = 6 |
1823 | + result['height'] = 5 |
1824 | + elif index == BAR_DOWN: # Decender Bar |
1825 | + result['top'] = 6 |
1826 | + result['height'] = 11 |
1827 | + elif index == BAR_UP: # Accender Bar |
1828 | + result['height'] = 11 |
1829 | + elif index == BAR_FULL: # Full Bar |
1830 | + result['height'] = 17 |
1831 | + elif index == WHITE_SPACE: # White Space |
1832 | + result['write'] = False |
1833 | + return result |
1834 | |
1835 | === modified file 'share/extensions/Barcode/UPCA.py' |
1836 | --- share/extensions/Barcode/UPCA.py 2010-07-22 22:18:09 +0000 |
1837 | +++ share/extensions/Barcode/UPCA.py 2010-12-30 04:23:15 +0000 |
1838 | @@ -1,59 +1,37 @@ |
1839 | -#!/usr/bin/env python |
1840 | -''' |
1841 | -Copyright (C) 2007 Martin Owens |
1842 | - |
1843 | -Thanks to Lineaire Chez of Inkbar ( www.inkbar.lineaire.net ) |
1844 | - |
1845 | -This program is free software; you can redistribute it and/or modify |
1846 | -it under the terms of the GNU General Public License as published by |
1847 | -the Free Software Foundation; either version 2 of the License, or |
1848 | -(at your option) any later version. |
1849 | - |
1850 | -This program is distributed in the hope that it will be useful, |
1851 | -but WITHOUT ANY WARRANTY; without even the implied warranty of |
1852 | -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1853 | -GNU General Public License for more details. |
1854 | - |
1855 | -You should have received a copy of the GNU General Public License |
1856 | -along with this program; if not, write to the Free Software |
1857 | -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
1858 | -''' |
1859 | - |
1860 | -import EAN13 |
1861 | -from EAN13 import mapLeftFaimly, guardBar, centerBar, mapRight |
1862 | -import sys |
1863 | - |
1864 | -class Object(EAN13.Object): |
1865 | - def encode(self, number): |
1866 | - result = '' |
1867 | - |
1868 | - if len(number) < 11 or len(number) > 12 or not number.isdigit(): |
1869 | - sys.stderr.write("Can not encode '" + number + "' into UPC-A Barcode, Size must be 11 numbers only, and 1 check digit (optional).\n") |
1870 | - return |
1871 | - |
1872 | - if len(number) == 11: |
1873 | - number = number + self.getChecksum(number) |
1874 | - else: |
1875 | - if not self.verifyChecksum(number): |
1876 | - sys.stderr.write("UPC-A Checksum not correct for this barcode, omit last character to generate new checksum.\n") |
1877 | - return |
1878 | - |
1879 | - result = result + guardBar |
1880 | - |
1881 | - i = 0 |
1882 | - for i in range(0,6): |
1883 | - result += mapLeftFaimly[0][int(number[i])] |
1884 | - |
1885 | - result += centerBar |
1886 | - |
1887 | - for i in range (6,12): |
1888 | - result += mapRight[int(number[i])] |
1889 | - |
1890 | - result = result + guardBar; |
1891 | - |
1892 | - self.label = number[0] + ' ' + number[1:6] + ' ' + number[6:11] + ' ' + number[11] |
1893 | - self.inclabel = self.label |
1894 | - return result; |
1895 | - |
1896 | - def fontSize(self): |
1897 | - return '10' |
1898 | +# |
1899 | +# Copyright (C) 2007 Martin Owens |
1900 | +# |
1901 | +# This program is free software; you can redistribute it and/or modify |
1902 | +# it under the terms of the GNU General Public License as published by |
1903 | +# the Free Software Foundation; either version 2 of the License, or |
1904 | +# (at your option) any later version. |
1905 | +# |
1906 | +# This program is distributed in the hope that it will be useful, |
1907 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
1908 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1909 | +# GNU General Public License for more details. |
1910 | +# |
1911 | +# You should have received a copy of the GNU General Public License |
1912 | +# along with this program; if not, write to the Free Software |
1913 | +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
1914 | +# |
1915 | +""" |
1916 | +Python barcode renderer for UPCA barcodes. Designed for use with Inkscape. |
1917 | +""" |
1918 | + |
1919 | +from BaseEan import EanBarcode |
1920 | + |
1921 | +class Object(EanBarcode): |
1922 | + """Provides a renderer for EAN12 aka UPC-A Barcodes""" |
1923 | + name = 'upca' |
1924 | + lengths = [ 11 ] |
1925 | + checks = [ 12 ] |
1926 | + |
1927 | + def _encode(self, n): |
1928 | + """Encode for a UPC-A Barcode""" |
1929 | + self.label = self.space(n[0:1], 3, n[1:6], 4, n[6:11], 3, n[11:]) |
1930 | + return self.enclose(self.encode_left(n[0:6]), self.encode_right(n[6:12])) |
1931 | + |
1932 | + def fontSize(self): |
1933 | + """We need a bigger barcode""" |
1934 | + return 10 |
1935 | |
1936 | === modified file 'share/extensions/Barcode/UPCE.py' |
1937 | --- share/extensions/Barcode/UPCE.py 2010-07-22 22:18:09 +0000 |
1938 | +++ share/extensions/Barcode/UPCE.py 2010-12-30 04:23:15 +0000 |
1939 | @@ -1,130 +1,103 @@ |
1940 | -#!/usr/bin/env python |
1941 | -''' |
1942 | -Copyright (C) 2007 Martin Owens |
1943 | - |
1944 | -Thanks to Lineaire Chez of Inkbar ( www.inkbar.lineaire.net ) |
1945 | - |
1946 | -This program is free software; you can redistribute it and/or modify |
1947 | -it under the terms of the GNU General Public License as published by |
1948 | -the Free Software Foundation; either version 2 of the License, or |
1949 | -(at your option) any later version. |
1950 | - |
1951 | -This program is distributed in the hope that it will be useful, |
1952 | -but WITHOUT ANY WARRANTY; without even the implied warranty of |
1953 | -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1954 | -GNU General Public License for more details. |
1955 | - |
1956 | -You should have received a copy of the GNU General Public License |
1957 | -along with this program; if not, write to the Free Software |
1958 | -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
1959 | -''' |
1960 | - |
1961 | -import EAN13 |
1962 | -from EAN13 import mapLeftFaimly, guardBar, centerBar |
1963 | +# |
1964 | +# Copyright (C) 2010 Martin Owens |
1965 | +# |
1966 | +# This program is free software; you can redistribute it and/or modify |
1967 | +# it under the terms of the GNU General Public License as published by |
1968 | +# the Free Software Foundation; either version 2 of the License, or |
1969 | +# (at your option) any later version. |
1970 | +# |
1971 | +# This program is distributed in the hope that it will be useful, |
1972 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
1973 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1974 | +# GNU General Public License for more details. |
1975 | +# |
1976 | +# You should have received a copy of the GNU General Public License |
1977 | +# along with this program; if not, write to the Free Software |
1978 | +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
1979 | +# |
1980 | +""" |
1981 | +Python barcode renderer for UPCE barcodes. Designed for use with Inkscape. |
1982 | +""" |
1983 | + |
1984 | +from BaseEan import EanBarcode |
1985 | import sys |
1986 | |
1987 | -mapFamily = [ '000111','001011','001101','001110','010011','011001','011100','010101','010110','011010' ] |
1988 | - |
1989 | -class Object(EAN13.Object): |
1990 | - def encode(self, number): |
1991 | - result = '' |
1992 | - |
1993 | - l = len(number) |
1994 | - |
1995 | - if (l != 6 and l != 7 and l != 11 and l != 12) or not number.isdigit(): |
1996 | - 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") |
1997 | - return |
1998 | - |
1999 | - echeck = None |
2000 | - if l==7 or l==12: |
2001 | - echeck = number[-1] |
2002 | - number = number[:-1] |
2003 | - sys.stderr.write("CHECKSUM FOUND!") |
2004 | - l -= 1 |
2005 | - |
2006 | - if l==6: |
2007 | - number = self.ConvertEtoA(number) |
2008 | - |
2009 | - if not echeck: |
2010 | - echeck = self.getChecksum(number) |
2011 | - else: |
2012 | - if not self.verifyChecksum(number + echeck): |
2013 | - sys.stderr.write("UPC-E Checksum not correct for this barcode, omit last character to generate new checksum.\n") |
2014 | - return |
2015 | - |
2016 | - number = self.ConvertAtoE(number) |
2017 | - if not number: |
2018 | - 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") |
2019 | - return |
2020 | - |
2021 | - number = number |
2022 | - |
2023 | - result = result + guardBar |
2024 | - # The check digit isn't stored as bars but as a mirroring system. :-( |
2025 | - family = mapFamily[int(echeck)] |
2026 | - |
2027 | - i = 0 |
2028 | - for i in range(0,6): |
2029 | - result += mapLeftFaimly[int(family[i])-1][int(number[i])] |
2030 | - |
2031 | - result = result + centerBar + '2'; |
2032 | - |
2033 | - self.label = '0 ' + number[:6] + ' ' + echeck |
2034 | - self.inclabel = self.label |
2035 | - return result; |
2036 | - |
2037 | - def fontSize(self): |
2038 | - return '10' |
2039 | - |
2040 | - def ConvertAtoE(self, number): |
2041 | - # Converting UPC-A to UPC-E |
2042 | - |
2043 | - # All UPC-E Numbers use number system 0 |
2044 | - if number[0] != '0' or len(number)!=11: |
2045 | - # If not then the code is invalid |
2046 | - return None |
2047 | - |
2048 | - # Most of the conversions deal |
2049 | - # with the specific code parts |
2050 | - manufacturer = number[1:6] |
2051 | - product = number[6:11] |
2052 | - |
2053 | - # There are 4 cases to convert: |
2054 | - if manufacturer[2:] == '000' or manufacturer[2:] == '100' or manufacturer[2:] == '200': |
2055 | - # Maxium number product code digits can be encoded |
2056 | - if product[:2]=='00': |
2057 | - return manufacturer[:2] + product[2:] + manufacturer[2] |
2058 | - elif manufacturer[3:5] == '00': |
2059 | - # Now only 2 product code digits can be used |
2060 | - if product[:3]=='000': |
2061 | - return manufacturer[:3] + product[3:] + '3' |
2062 | - elif manufacturer[4] == '0': |
2063 | - # With even more manufacturer code we have less room for product code |
2064 | - if product[:4]=='0000': |
2065 | - return manufacturer[0:4] + product[4] + '4' |
2066 | - elif product[:4]=='0000' and int(product[4]) > 4: |
2067 | - # The last recorse is to try and squeeze it in the last 5 numbers |
2068 | - # so long as the product is 00005-00009 so as not to conflict with |
2069 | - # the 0-4 used above. |
2070 | - return manufacturer + product[4] |
2071 | - else: |
2072 | - # Invalid UPC-A Numbe |
2073 | - return None |
2074 | - |
2075 | - def ConvertEtoA(self, number): |
2076 | - # Convert UPC-E to UPC-A |
2077 | - |
2078 | - # It's more likly to convert this without fault |
2079 | - # But we still must be mindful of the 4 conversions |
2080 | - if len(number)!=6: |
2081 | - return None |
2082 | - |
2083 | - if number[5]=='0' or number[5]=='1' or number[5]=='2': |
2084 | - return '0' + number[:2] + number[5] + '0000' + number[2:5] |
2085 | - elif number[5]=='3': |
2086 | - return '0' + number[:3] + '00000' + number[3:5] |
2087 | - elif number[5]=='4': |
2088 | - return '0' + number[:4] + '00000' + number[4] |
2089 | - else: |
2090 | - return '0' + number[:5] + '0000' + number[5] |
2091 | +# This is almost exactly the same as the standard FAMILIES |
2092 | +# But flipped around and with the first 111000 instead of 000000. |
2093 | +FAMS = [ '111000', '110100', '110010', '110001', '101100', |
2094 | + '100110', '100011', '101010', '101001', '100101' ] |
2095 | + |
2096 | +class Object(EanBarcode): |
2097 | + """Generate EAN6/UPC-E barcode generator""" |
2098 | + name = 'upce' |
2099 | + lengths = [ 6, 11 ] |
2100 | + checks = [ 7, 12 ] |
2101 | + |
2102 | + def _encode(self, n): |
2103 | + """Generate a UPC-E Barcode""" |
2104 | + self.label = self.space(['0'], 2, n[:6], 2, n[-1]) |
2105 | + code = self.encode_interleaved(n[-1], n[:6], FAMS) |
2106 | + # 202(guard) + code + 020(center) + 202(guard) |
2107 | + return self.enclose(code, center='020') |
2108 | + |
2109 | + def appendChecksum(self, number): |
2110 | + """Generate a UPCE Checksum""" |
2111 | + if len(number) == 6: |
2112 | + number = self.ConvertEtoA(number) |
2113 | + result = self.getChecksum(number) |
2114 | + return self.ConvertAtoE(number) + result |
2115 | + |
2116 | + def fontSize(self): |
2117 | + """We need a font size of 10""" |
2118 | + return 10 |
2119 | + |
2120 | + def ConvertAtoE(self, number): |
2121 | + """Converting UPC-A to UPC-E, may cause errors.""" |
2122 | + # All UPC-E Numbers use number system 0 |
2123 | + if number[0] != '0' or len(number)!=11: |
2124 | + # If not then the code is invalid |
2125 | + return None |
2126 | + |
2127 | + # Most of the conversions deal |
2128 | + # with the specific code parts |
2129 | + manufacturer = number[1:6] |
2130 | + product = number[6:11] |
2131 | + |
2132 | + # There are 4 cases to convert: |
2133 | + if manufacturer[2:] == '000' or manufacturer[2:] == '100' or manufacturer[2:] == '200': |
2134 | + # Maxium number product code digits can be encoded |
2135 | + if product[:2]=='00': |
2136 | + return manufacturer[:2] + product[2:] + manufacturer[2] |
2137 | + elif manufacturer[3:5] == '00': |
2138 | + # Now only 2 product code digits can be used |
2139 | + if product[:3]=='000': |
2140 | + return manufacturer[:3] + product[3:] + '3' |
2141 | + elif manufacturer[4] == '0': |
2142 | + # With even more manufacturer code we have less room for product code |
2143 | + if product[:4]=='0000': |
2144 | + return manufacturer[0:4] + product[4] + '4' |
2145 | + elif product[:4]=='0000' and int(product[4]) > 4: |
2146 | + # The last recorse is to try and squeeze it in the last 5 numbers |
2147 | + # so long as the product is 00005-00009 so as not to conflict with |
2148 | + # the 0-4 used above. |
2149 | + return manufacturer + product[4] |
2150 | + else: |
2151 | + # Invalid UPC-A Numbe |
2152 | + return None |
2153 | + |
2154 | + def ConvertEtoA(self, number): |
2155 | + """Convert UPC-E to UPC-A by padding with zeros""" |
2156 | + # It's more likly to convert this without fault |
2157 | + # But we still must be mindful of the 4 conversions |
2158 | + if len(number) != 6: |
2159 | + return None |
2160 | + |
2161 | + if number[5] in ['0', '1', '2']: |
2162 | + return '0' + number[:2] + number[5] + '0000' + number[2:5] |
2163 | + elif number[5] == '3': |
2164 | + return '0' + number[:3] + '00000' + number[3:5] |
2165 | + elif number[5] == '4': |
2166 | + return '0' + number[:4] + '00000' + number[4] |
2167 | + else: |
2168 | + return '0' + number[:5] + '0000' + number[5] |
2169 | |
2170 | |
2171 | === modified file 'share/extensions/Barcode/__init__.py' |
2172 | --- share/extensions/Barcode/__init__.py 2010-07-22 22:18:09 +0000 |
2173 | +++ share/extensions/Barcode/__init__.py 2010-12-30 04:23:15 +0000 |
2174 | @@ -1,39 +1,36 @@ |
2175 | -#!/usr/bin/env python |
2176 | -''' |
2177 | -Barcodes SVG Extention |
2178 | - |
2179 | -Supported Barcodes: EAN8, EAN13, Code39, Code39 Extended, Code93, Code128, RM4CC(RM4SCC) |
2180 | - |
2181 | -Copyright (C) 2007 Martin Owens |
2182 | - |
2183 | -This program is free software; you can redistribute it and/or modify |
2184 | -it under the terms of the GNU General Public License as published by |
2185 | -the Free Software Foundation; either version 2 of the License, or |
2186 | -(at your option) any later version. |
2187 | - |
2188 | -This program is distributed in the hope that it will be useful, |
2189 | -but WITHOUT ANY WARRANTY; without even the implied warranty of |
2190 | -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2191 | -GNU General Public License for more details. |
2192 | - |
2193 | -You should have received a copy of the GNU General Public License |
2194 | -along with this program; if not, write to the Free Software |
2195 | -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
2196 | -''' |
2197 | +# |
2198 | +# Copyright (C) 2010 Martin Owens |
2199 | +# |
2200 | +# This program is free software; you can redistribute it and/or modify |
2201 | +# it under the terms of the GNU General Public License as published by |
2202 | +# the Free Software Foundation; either version 2 of the License, or |
2203 | +# (at your option) any later version. |
2204 | +# |
2205 | +# This program is distributed in the hope that it will be useful, |
2206 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
2207 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2208 | +# GNU General Public License for more details. |
2209 | +# |
2210 | +# You should have received a copy of the GNU General Public License |
2211 | +# along with this program; if not, write to the Free Software |
2212 | +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
2213 | +# |
2214 | +""" |
2215 | +Renderer for barcodes, SVG extention for Inkscape. |
2216 | + |
2217 | +For supported barcodes see Barcode module directory. |
2218 | + |
2219 | +""" |
2220 | |
2221 | # This lists all known Barcodes missing from this package |
2222 | -# =========== UPC-Based =========== # |
2223 | -# ISBN (EAN13) |
2224 | # ===== UPC-Based Extensions ====== # |
2225 | # Code11 |
2226 | # ========= Code25-Based ========== # |
2227 | -# Code25 |
2228 | # Codabar |
2229 | # Postnet |
2230 | # ITF25 |
2231 | # ========= Alpha-numeric ========= # |
2232 | # Code39Mod |
2233 | -# EAN128 (Code128) |
2234 | # USPS128 |
2235 | # =========== 2D Based ============ # |
2236 | # PDF417 |
2237 | @@ -44,41 +41,44 @@ |
2238 | import sys |
2239 | |
2240 | def getBarcode(format, param={}): |
2241 | - if format: |
2242 | - format = str(format).lower() |
2243 | - format = format.replace('-', '') |
2244 | - format = format.replace(' ', '') |
2245 | - if format=='code39': |
2246 | - import Code39 |
2247 | - return Code39.Object(param) |
2248 | - elif format=='code39ext': |
2249 | - import Code39Ext |
2250 | - return Code39Ext.Object(param) |
2251 | - elif format=='code93': |
2252 | - import Code93 |
2253 | - return Code93.Object(param) |
2254 | - elif format=='code128': |
2255 | - import Code128 |
2256 | - return Code128.Object(param) |
2257 | - |
2258 | - elif format in ['rm4cc', 'rm4scc']: |
2259 | - import RM4CC |
2260 | - return RM4CC.Object(param) |
2261 | - |
2262 | - elif format == 'upca': |
2263 | - import UPCA |
2264 | - return UPCA.Object(param) |
2265 | - elif format == 'upce': |
2266 | - import UPCE |
2267 | - return UPCE.Object(param) |
2268 | - elif format in ['ean13', 'ucc13','jan']: |
2269 | - import EAN13 |
2270 | - return EAN13.Object(param) |
2271 | - elif format == 'ean5': |
2272 | - import EAN5 |
2273 | - return EAN5.Object(param) |
2274 | - elif format in ['ean8', 'ucc8']: |
2275 | - import EAN8 |
2276 | - return EAN8.Object(param) |
2277 | - sys.stderr.write("Invalid format for barcode: " + str(format) + "\n") |
2278 | + if format: |
2279 | + format = str(format).lower() |
2280 | + format = format.replace('-', '') |
2281 | + format = format.replace(' ', '') |
2282 | + if format=='code25i': |
2283 | + import Code25i |
2284 | + return Code25i.Object(param) |
2285 | + elif format=='code39': |
2286 | + import Code39 |
2287 | + return Code39.Object(param) |
2288 | + elif format=='code39ext': |
2289 | + import Code39Ext |
2290 | + return Code39Ext.Object(param) |
2291 | + elif format=='code93': |
2292 | + import Code93 |
2293 | + return Code93.Object(param) |
2294 | + elif format=='code128': |
2295 | + import Code128 |
2296 | + return Code128.Object(param) |
2297 | + |
2298 | + elif format in ['rm4cc', 'rm4scc']: |
2299 | + import RM4CC |
2300 | + return RM4CC.Object(param) |
2301 | + |
2302 | + elif format == 'upca': |
2303 | + import UPCA |
2304 | + return UPCA.Object(param) |
2305 | + elif format == 'upce': |
2306 | + import UPCE |
2307 | + return UPCE.Object(param) |
2308 | + elif format == 'ean5': |
2309 | + import EAN5 |
2310 | + return EAN5.Object(param) |
2311 | + elif format in ['ean8', 'ucc8']: |
2312 | + import EAN8 |
2313 | + return EAN8.Object(param) |
2314 | + elif format in ['ean13', 'ucc13','jan']: |
2315 | + import EAN13 |
2316 | + return EAN13.Object(param) |
2317 | + sys.stderr.write("Invalid format for barcode: " + str(format) + "\n") |
2318 | |
2319 | |
2320 | === modified file 'share/extensions/render_barcode.inx' |
2321 | --- share/extensions/render_barcode.inx 2009-12-21 23:48:17 +0000 |
2322 | +++ share/extensions/render_barcode.inx 2010-12-30 04:23:15 +0000 |
2323 | @@ -5,13 +5,14 @@ |
2324 | <dependency type="executable" location="extensions">inkex.py</dependency> |
2325 | <dependency type="executable" location="extensions">render_barcode.py</dependency> |
2326 | <param name="type" type="enum" _gui-text="Barcode Type:"> |
2327 | + <item value="ean5">EAN5</item> |
2328 | <item value="ean8">EAN8</item> |
2329 | <item value="ean13">EAN13</item> |
2330 | - <item value="ean5">EAN5</item> |
2331 | <item value="upca">UPC-A</item> |
2332 | <item value="upce">UPC-E</item> |
2333 | + <item value="code25i">Code25 Interleaved 2 of 5</item> |
2334 | <item value="code39">Code39</item> |
2335 | - <item value="code39ext">Code39Ext</item> |
2336 | + <item value="code39ext">Code39 Extended</item> |
2337 | <item value="code93">Code93</item> |
2338 | <item value="code128">Code128</item> |
2339 | <item value="rm4scc">RM4CC / RM4SCC</item> |
2340 | |
2341 | === modified file 'share/extensions/render_barcode.py' |
2342 | --- share/extensions/render_barcode.py 2010-07-22 22:18:09 +0000 |
2343 | +++ share/extensions/render_barcode.py 2010-12-30 04:23:15 +0000 |
2344 | @@ -39,15 +39,15 @@ |
2345 | |
2346 | def effect(self): |
2347 | x, y = self.view_center |
2348 | - object = getBarcode( self.options.type, { |
2349 | + bargen = getBarcode( self.options.type, { |
2350 | 'text' : self.options.text, |
2351 | 'height' : self.options.height, |
2352 | 'document' : self.document, |
2353 | 'x' : x, |
2354 | 'y' : y, |
2355 | } ) |
2356 | - if object is not None: |
2357 | - barcode = object.generate() |
2358 | + if bargen is not None: |
2359 | + barcode = bargen.generate() |
2360 | if barcode is not None: |
2361 | self.current_layer.append(barcode) |
2362 | else: |
2363 | |
2364 | === added file 'share/extensions/test/render_barcode.data' |
2365 | --- share/extensions/test/render_barcode.data 1970-01-01 00:00:00 +0000 |
2366 | +++ share/extensions/test/render_barcode.data 2010-12-30 04:23:15 +0000 |
2367 | @@ -0,0 +1,500 @@ |
2368 | +ean8:9493712:2020001011010001100010110111101020201000100110011011011001100110202 |
2369 | +ean8:2811738:2020010011011011100110010011001020201000100100001010010001011100202 |
2370 | +ean8:2248057:2020010011001001101000110110111020201110010100111010001001010000202 |
2371 | +ean8:0995042:2020001101000101100010110110001020201110010101110011011001110100202 |
2372 | +ean8:0262682:2020001101001001101011110010011020201010000100100011011001010000202 |
2373 | +ean8:2006346:2020010011000110100011010101111020201000010101110010100001000100202 |
2374 | +ean8:9892307:2020001011011011100010110010011020201000010111001010001001010000202 |
2375 | +ean8:7033691:2020111011000110101111010111101020201010000111010011001101000100202 |
2376 | +ean8:6587381:2020101111011000101101110111011020201000010100100011001101010000202 |
2377 | +ean8:4491441:2020100011010001100010110011001020201011100101110011001101000100202 |
2378 | +ean8:0099044:2020001101000110100010110001011020201110010101110010111001001000202 |
2379 | +ean8:7565347:2020111011011000101011110110001020201000010101110010001001000100202 |
2380 | +ean8:0764195:2020001101011101101011110100011020201100110111010010011101011100202 |
2381 | +ean8:4882328:2020100011011011101101110010011020201000010110110010010001110100202 |
2382 | +ean8:4635078:2020100011010111101111010110001020201110010100010010010001000100202 |
2383 | +ean8:8992114:2020110111000101100010110010011020201100110110011010111001101100202 |
2384 | +ean8:6658162:2020101111010111101100010110111020201100110101000011011001001000202 |
2385 | +ean8:7880049:2020111011011011101101110001101020201110010101110011101001010000202 |
2386 | +ean8:7782648:2020111011011101101101110010011020201010000101110010010001110010202 |
2387 | +ean8:8249002:2020110111001001101000110001011020201110010111001011011001000100202 |
2388 | +ean8:8735885:2020110111011101101111010110001020201001000100100010011101001000202 |
2389 | +ean8:9818050:2020001011011011100110010110111020201110010100111011100101110100202 |
2390 | +ean8:3410390:2020111101010001100110010001101020201000010111010011100101010000202 |
2391 | +ean8:9699144:2020001011010111100010110001011020201100110101110010111001101100202 |
2392 | +ean8:7628790:2020111011010111100100110110111020201000100111010011100101110100202 |
2393 | +ean8:2020310:2020010011000110100100110001101020201000010110011011100101001000202 |
2394 | +ean8:0429248:2020001101010001100100110001011020201101100101110010010001000100202 |
2395 | +ean8:3135528:2020111101001100101111010110001020201001110110110010010001001110202 |
2396 | +ean8:3182301:2020111101001100101101110010011020201000010111001011001101101100202 |
2397 | +ean8:0320063:2020001101011110100100110001101020201110010101000010000101010000202 |
2398 | +ean8:0865925:2020001101011011101011110110001020201110100110110010011101001110202 |
2399 | +ean8:3413434:2020111101010001100110010111101020201011100100001010111001011100202 |
2400 | +ean8:6730313:2020101111011101101111010001101020201000010110011010000101000100202 |
2401 | +ean8:4091215:2020100011000110100010110011001020201101100110011010011101001000202 |
2402 | +ean8:6504268:2020101111011000100011010100011020201101100101000010010001000100202 |
2403 | +ean8:0127593:2020001101001100100100110111011020201001110111010010000101000010202 |
2404 | +ean8:9214184:2020001011001001100110010100011020201100110100100010111001100110202 |
2405 | +ean8:4457000:2020100011010001101100010111011020201110010111001011100101101100202 |
2406 | +ean8:2575579:2020010011011000101110110110001020201001110100010011101001011100202 |
2407 | +ean8:3501739:2020111101011000100011010011001020201000100100001011101001011100202 |
2408 | +ean8:0733658:2020001101011101101111010111101020201010000100111010010001011100202 |
2409 | +ean8:6162818:2020101111001100101011110010011020201001000110011010010001101100202 |
2410 | +ean8:2397509:2020010011011110100010110111011020201001110111001011101001001110202 |
2411 | +ean8:3813610:2020111101011011100110010111101020201010000110011011100101001000202 |
2412 | +ean8:9488712:2020001011010001101101110110111020201000100110011011011001110100202 |
2413 | +ean8:1754326:2020011001011101101100010100011020201000010110110010100001101100202 |
2414 | +ean8:5221351:2020110001001001100100110011001020201000010100111011001101110100202 |
2415 | +ean8:6047658:2020101111000110101000110111011020201010000100111010010001010000202 |
2416 | +ean8:0475473:2020001101010001101110110110001020201011100100010010000101101100202 |
2417 | +ean8:0775368:2020001101011101101110110110001020201000010101000010010001001000202 |
2418 | +ean8:5825189:2020110001011011100100110110001020201100110100100011101001001000202 |
2419 | +ean8:9934666:2020001011000101101111010100011020201010000101000010100001110100202 |
2420 | +ean8:4849196:2020100011011011101000110001011020201100110111010010100001110100202 |
2421 | +ean8:6672405:2020101111010111101110110010011020201011100111001010011101010000202 |
2422 | +ean8:6368942:2020101111011110101011110110111020201110100101110011011001010000202 |
2423 | +ean8:0356360:2020001101011110101100010101111020201000010101000011100101100110202 |
2424 | +ean8:1506024:2020011001011000100011010101111020201110010110110010111001101100202 |
2425 | +ean8:0218852:2020001101001001100110010110111020201001000100111011011001101100202 |
2426 | +ean8:4357801:2020100011011110101100010111011020201001000111001011001101010000202 |
2427 | +ean8:8268643:2020110111001001101011110110111020201010000101110010000101000100202 |
2428 | +ean8:0117677:2020001101001100100110010111011020201010000100010010001001000010202 |
2429 | +ean8:8066330:2020110111000110101011110101111020201000010100001011100101110010202 |
2430 | +ean8:3074324:2020111101000110101110110100011020201000010110110010111001000010202 |
2431 | +ean8:7241642:2020111011001001101000110011001020201010000101110011011001010000202 |
2432 | +ean8:3375910:2020111101011110101110110110001020201110100110011011100101011100202 |
2433 | +ean8:5797167:2020110001011101100010110111011020201100110101000010001001011100202 |
2434 | +ean8:4413827:2020100011010001100110010111101020201001000110110010001001100110202 |
2435 | +ean8:0008083:2020001101000110100011010110111020201110010100100010000101001110202 |
2436 | +ean8:3240693:2020111101001001101000110001101020201010000111010010000101100110202 |
2437 | +ean8:3358989:2020111101011110101100010110111020201110100100100011101001000010202 |
2438 | +ean8:2525297:2020010011011000100100110110001020201101100111010010001001101100202 |
2439 | +ean8:9429514:2020001011010001100100110001011020201001110110011010111001010000202 |
2440 | +ean8:7496160:2020111011010001100010110101111020201100110101000011100101000010202 |
2441 | +ean8:2549811:2020010011011000101000110001011020201001000110011011001101110010202 |
2442 | +ean8:0366059:2020001101011110101011110101111020201110010100111011101001100110202 |
2443 | +ean8:7565529:2020111011011000101011110110001020201001110110110011101001000100202 |
2444 | +ean8:0544331:2020001101011000101000110100011020201000010100001011001101011100202 |
2445 | +ean8:5278325:2020110001001001101110110110111020201000010110110010011101001000202 |
2446 | +ean8:9659719:2020001011010111101100010001011020201000100110011011101001011100202 |
2447 | +ean8:6060276:2020101111000110101011110001101020201101100100010010100001000010202 |
2448 | +ean8:9983234:2020001011000101101101110111101020201101100100001010111001010000202 |
2449 | +ean8:9912723:2020001011000101100110010010011020201000100110110010000101000100202 |
2450 | +ean8:3934993:2020111101000101101111010100011020201110100111010010000101011100202 |
2451 | +ean8:9878705:2020001011011011101110110110111020201000100111001010011101110010202 |
2452 | +ean8:6099896:2020101111000110100010110001011020201001000111010010100001001110202 |
2453 | +ean8:9344302:2020001011011110101000110100011020201000010111001011011001110100202 |
2454 | +ean8:5779196:2020110001011101101110110001011020201100110111010010100001001000202 |
2455 | +ean8:2670364:2020010011010111101110110001101020201000010101000010111001110010202 |
2456 | +ean8:4049157:2020100011000110101000110001011020201100110100111010001001001000202 |
2457 | +ean8:6303180:2020101111011110100011010111101020201100110100100011100101001110202 |
2458 | +ean8:4252404:2020100011001001101100010010011020201011100111001010111001001110202 |
2459 | +ean8:6442834:2020101111010001101000110010011020201001000100001010111001001110202 |
2460 | +ean8:7330702:2020111011011110101111010001101020201000100111001011011001110010202 |
2461 | +ean8:6650523:2020101111010111101100010001101020201001110110110010000101001110202 |
2462 | +ean8:3261954:2020111101001001101011110011001020201110100100111010111001010000202 |
2463 | +ean8:1149083:2020011001001100101000110001011020201110010100100010000101001000202 |
2464 | +ean8:1227062:2020011001001001100100110111011020201110010101000011011001110010202 |
2465 | +ean8:7770854:2020111011011101101110110001101020201001000100111010111001110010202 |
2466 | +ean8:4841093:2020100011011011101000110011001020201110010111010010000101110100202 |
2467 | +ean8:9642244:2020001011010111101000110010011020201101100101110010111001100110202 |
2468 | +ean13:082432472648:20201101110010011010001101111010010011010001102020100010011011001010000101110010010001110010202 |
2469 | +ean13:867963203104:20201011110010001000101100001010100001001001102020111001010000101100110111001010111001001110202 |
2470 | +ean13:509274672682:20200011010010111001101101110110100011000010102020100010011011001010000100100011011001110010202 |
2471 | +ean13:137969745319:20201111010111011001011101011110010111001000102020101110010011101000010110011011101001101100202 |
2472 | +ean13:167788639568:20201011110111011001000101101110001001000010102020100001011101001001110101000010010001101100202 |
2473 | +ean13:763909437639:20201011110100001000101101001110001011001110102020100001010001001010000100001011101001110010202 |
2474 | +ean13:552090940230:20201100010011011010011100010110001101001011102020101110011100101101100100001011100101110100202 |
2475 | +ean13:064430020090:20201011110100011010001101111010001101000110102020110110011100101110010111010011100101001000202 |
2476 | +ean13:932131660272:20201111010011011011001101111010110011010111102020101000011100101101100100010011011001001000202 |
2477 | +ean13:697948544222:20200010110010001001011100111010110111011000102020101110010111001101100110110011011001110010202 |
2478 | +ean13:156973387097:20201100010101111001011101110110100001010000102020100100010001001110010111010010001001100110202 |
2479 | +ean13:742353933447:20201000110011011011110101110010111101001011102020100001010000101011100101110010001001001000202 |
2480 | +ean13:165804313397:20201011110110001000100100011010011101010000102020110011010000101000010111010010001001101100202 |
2481 | +ean13:142542648187:20201000110010011011100101000110011011000010102020101110010010001100110100100010001001101100202 |
2482 | +ean13:293746185362:20200010110111101001000100111010101111011001102020100100010011101000010101000011011001011100202 |
2483 | +ean13:079018947306:20201110110001011000110100110010110111000101102020101110010001001000010111001010100001110010202 |
2484 | +ean13:114714603442:20200110010100011001000100110010011101000010102020111001010000101011100101110011011001000100202 |
2485 | +ean13:886864480655:20201101110000101011011100001010011101010001102020100100011100101010000100111010011101011100202 |
2486 | +ean13:087399049352:20201101110111011011110100010110001011000110102020101110011101001000010100111011011001000010202 |
2487 | +ean13:680731212600:20201101110100111001000101000010011001001001102020110011011011001010000111001011100101001000202 |
2488 | +ean13:839853108496:20201111010010111011011101110010100001001100102020111001010010001011100111010010100001001000202 |
2489 | +ean13:759662798861:20201100010010111010111100001010010011001000102020111010010010001001000101000011001101011100202 |
2490 | +ean13:522030126885:20200100110011011010011101111010001101011001102020110110010100001001000100100010011101011100202 |
2491 | +ean13:872252192093:20201110110011011001001101110010011011001100102020111010011011001110010111010010000101011100202 |
2492 | +ean13:978323527315:20201110110001001010000100100110100001011000102020110110010001001000010110011010011101110100202 |
2493 | +ean13:594820728295:20200010110011101000100100100110001101001000102020110110010010001101100111010010011101000100202 |
2494 | +ean13:817309047999:20200110010010001011110101001110010111000110102020101110010001001110100111010011101001011100202 |
2495 | +ean13:529552650589:20200100110010111011100101100010010011000010102020100111011100101001110100100011101001000010202 |
2496 | +ean13:301953031072:20200011010011001001011101110010100001000110102020100001011001101110010100010011011001101100202 |
2497 | +ean13:279759074172:20201110110001011001000101110010001011010011102020100010010111001100110100010011011001011100202 |
2498 | +ean13:966269952443:20201011110000101001101101011110010111000101102020100111011011001011100101110010000101000100202 |
2499 | +ean13:393886491651:20200010110111101000100100010010000101010001102020111010011001101010000100111011001101110100202 |
2500 | +ean13:592818880852:20200010110011011000100100110010110111000100102020100100011100101001000100111011011001110010202 |
2501 | +ean13:629415132010:20200100110010111001110101100110110001001100102020100001011011001110010110011011100101001000202 |
2502 | +ean13:649798154930:20201000110010111001000100101110110111001100102020100111010111001110100100001011100101110100202 |
2503 | +ean13:106475417609:20200011010101111001110101110110111001001110102020110011010001001010000111001011101001110010202 |
2504 | +ean13:853904645292:20201100010100001000101101001110011101010111102020101110010011101101100111010011011001100110202 |
2505 | +ean13:431977667645:20201111010110011000101101110110010001000010102020101000010001001010000101110010011101000010202 |
2506 | +ean13:814819509497:20200110010011101011011101100110010111011000102020111001011101001011100111010010001001000100202 |
2507 | +ean13:308817835364:20200011010110111000100101100110010001011011102020100001010011101000010101000010111001011100202 |
2508 | +ean13:618801393027:20200110010001001000100101001110011001011110102020111010010000101110010110110010001001110010202 |
2509 | +ean13:164480667538:20201011110100011001110101101110100111000010102020101000010001001001110100001010010001011100202 |
2510 | +ean13:081023710137:20201101110011001000110100100110111101011101102020110011011100101100110100001010001001000100202 |
2511 | +ean13:493359422890:20200010110100001011110101100010010111001110102020110110011011001001000111010011100101110010202 |
2512 | +ean13:275532814865:20201110110110001011100101000010010011000100102020110011010111001001000101000010011101001000202 |
2513 | +ean13:111345042302:20200110010011001010000101000110111001010011102020101110011011001000010111001011011001001000202 |
2514 | +ean13:513537464719:20200110010100001011100101111010111011001110102020101000010111001000100110011011101001001110202 |
2515 | +ean13:766449694282:20201011110000101010001100111010001011000010102020111010010111001101100100100011011001110100202 |
2516 | +ean13:961792988802:20201011110110011001000100010110011011000101102020100100010010001001000111001011011001001110202 |
2517 | +ean13:866540005468:20201011110000101011000100111010100111000110102020111001010011101011100101000010010001101100202 |
2518 | +ean13:888983089059:20201101110001001000101100010010100001000110102020100100011101001110010100111011101001100110202 |
2519 | +ean13:722513175727:20200100110011011011000101100110111101011001102020100010010011101000100110110010001001110100202 |
2520 | +ean13:843297735811:20201000110100001001001100101110010001011101102020100001010011101001000110011011001101101100202 |
2521 | +ean13:627233353075:20200100110010001001101101000010111101011110102020100111010000101110010100010010011101110010202 |
2522 | +ean13:203591705672:20200011010111101011100100101110011001001000102020111001010011101010000100010011011001001110202 |
2523 | +ean13:686779501514:20201101110000101001000100100010001011011000102020111001011001101001110110011010111001001110202 |
2524 | +ean13:379483955591:20201110110001011001110100010010100001000101102020100111010011101001110111010011001101101100202 |
2525 | +ean13:576363706332:20201110110000101010000101011110111101001000102020111001010100001000010100001011011001000010202 |
2526 | +ean13:295226681860:20200010110110001001101100110110101111000010102020100100011001101001000101000011100101110100202 |
2527 | +ean13:901443422086:20200011010110011001110101000110100001010001102020110110011011001110010100100010100001000100202 |
2528 | +ean13:093300442985:20200010110111101011110100011010001101010001102020101110011011001110100100100010011101000010202 |
2529 | +ean13:517520551545:20200110010010001011100100100110001101011100102020100111011001101001110101110010011101000010202 |
2530 | +ean13:370982564882:20201110110001101001011100010010011011011000102020101000010111001001000100100011011001110010202 |
2531 | +ean13:640884610730:20201000110100111000100100010010100011010111102020110011011100101000100100001011100101001110202 |
2532 | +ean13:601211133573:20200011010110011001101101100110011001001100102020100001010000101001110100010010000101110100202 |
2533 | +ean13:772390839786:20201110110011011011110100101110001101000100102020100001011101001000100100100010100001110100202 |
2534 | +ean13:037823325554:20201111010111011011011100100110111101011110102020110110010011101001110100111010111001000010202 |
2535 | +ean13:636746415900:20201111010000101001000100111010101111010001102020110011010011101110100111001011100101000100202 |
2536 | +ean13:378365729312:20201110110110111010000100001010111001011101102020110110011101001000010110011011011001110010202 |
2537 | +ean13:588008084415:20201101110001001010011100011010110111010011102020100100010111001011100110011010011101000010202 |
2538 | +ean13:493847586062:20200010110100001011011101000110010001011100102020100100010100001110010101000011011001110010202 |
2539 | +ean13:661725378018:20201011110110011001000100110110110001011110102020100010010010001110010110011010010001110010202 |
2540 | +ean13:785941917380:20201101110111001000101100111010011001001011102020110011010001001000010100100011100101011100202 |
2541 | +ean13:476858945743:20201110110000101011011101100010001001001011102020101110010011101000100101110010000101010000202 |
2542 | +ean13:621022451023:20200100110110011010011100110110010011010001102020100111011001101110010110110010000101001000202 |
2543 | +ean13:738611126276:20201111010001001010111101100110011001011001102020110110010100001101100100010010100001110010202 |
2544 | +ean13:610023637901:20200110010100111010011100110110111101010111102020100001010001001110100111001011001101001000202 |
2545 | +ean13:310432899227:20200110010001101001110101000010011011011011102020111010011101001101100110110010001001110010202 |
2546 | +ean13:079481718507:20201110110001011010001101101110011001011101102020110011010010001001110111001010001001000010202 |
2547 | +ean13:794525704564:20200010110011101011000100110110110001001000102020111001010111001001110101000010111001010000202 |
2548 | +ean13:367079205365:20201011110111011010011100100010010111001001102020111001010011101000010101000010011101100110202 |
2549 | +ean13:791478205064:20200010110110011010001100100010110111001101102020111001010011101110010101000010111001000100202 |
2550 | +ean13:622805103976:20200100110011011000100101001110110001001100102020111001010000101110100100010010100001100110202 |
2551 | +ean13:659692878482:20201100010010111000010100101110010011011011102020100010010010001011100100100011011001011100202 |
2552 | +ean13:312673979722:20200110010010011000010100100010100001000101102020100010011101001000100110110011011001110010202 |
2553 | +ean13:634789369262:20201111010011101001000100010010001011011110102020101000011101001101100101000011011001000100202 |
2554 | +ean13:508031061191:20200011010001001010011101111010011001010011102020101000011001101100110111010011001101000100202 |
2555 | +ean13:617546677352:20200110010010001011100100111010101111010111102020100010010001001000010100111011011001000010202 |
2556 | +ean13:386750842077:20201101110101111001000101110010100111011011102020101110011011001110010100010010001001100110202 |
2557 | +ean13:217930060540:20200110010111011001011101000010001101010011102020101000011100101001110101110011100101100110202 |
2558 | +ean13:529453929533:20200100110010111001110101100010111101001011102020110110011101001001110100001010000101000010202 |
2559 | +ean13:403667633768:20200011010100001010111101011110010001000010102020100001010000101000100101000010010001110100202 |
2560 | +ean13:788401327704:20201101110001001010001101001110011001010000102020110110010001001000100111001010111001000100202 |
2561 | +ean13:316882500762:20200110010101111000100100010010011011011000102020111001011100101000100101000011011001101100202 |
2562 | +ean13:413254666172:20200110010100001001001101100010011101000010102020101000010100001100110100010011011001100110202 |
2563 | +ean13:666719764771:20201011110000101001000101100110001011011101102020101000010111001000100100010011001101100110202 |
2564 | +ean13:502326102133:20200011010011011010000100100110101111011001102020111001011011001100110100001010000101010000202 |
2565 | +ean13:690549661049:20200010110100111011100100111010001011010111102020101000011001101110010101110011101001001110202 |
2566 | +ean13:055572466568:20201100010110001011000101110110010011010001102020101000010100001001110101000010010001110100202 |
2567 | +ean13:636596356068:20201111010000101011100100101110101111011110102020100111010100001110010101000010010001000010202 |
2568 | +upce:844677:202000100100111010011101010111101110110111011020202 |
2569 | +upce:610879:202000010101100110001101011011101110110010111020202 |
2570 | +upce:982526:202001011100010010011011011000100100110101111020202 |
2571 | +upce:846420:202000100100111010101111010001100110110001101020202 |
2572 | +upce:322140:202010000100110110010011001100100111010001101020202 |
2573 | +upce:625042:202000010100100110110001010011101000110011011020202 |
2574 | +upce:996072:202001011100101110101111000110101110110011011020202 |
2575 | +upce:539996:202011100101000010001011000101100010110000101020202 |
2576 | +upce:340168:202010000100111010001101001100100001010110111020202 |
2577 | +upce:841913:202000100101000110100111000101101100110011001020202 |
2578 | +upce:124122:202011001100110110100011001100100110110010011020202 |
2579 | +upce:401968:202001110100011010110011000101101011110001001020202 |
2580 | +upce:225085:202001101100100110111001010011101101110110001020202 |
2581 | +upce:368038:202010000101011110001001010011101111010110111020202 |
2582 | +upce:817155:202000100100110010111011011001101100010111001020202 |
2583 | +upce:554120:202011100101110010100011011001100100110001101020202 |
2584 | +upce:113080:202011001101100110111101000110101101110100111020202 |
2585 | +upce:755380:202001000101100010110001011110100010010100111020202 |
2586 | +upce:201858:202001101100011010110011000100101100010110111020202 |
2587 | +upce:226567:202001101100100110000101011100101011110111011020202 |
2588 | +upce:507089:202011100101001110111011000110101101110010111020202 |
2589 | +upce:442680:202001110101000110011011010111101101110100111020202 |
2590 | +upce:557738:202011100101100010111011001000101000010110111020202 |
2591 | +upce:928720:202001011100100110001001011101100100110100111020202 |
2592 | +upce:395240:202010000100101110110001001101101000110001101020202 |
2593 | +upce:931548:202001011101111010110011011000101000110001001020202 |
2594 | +upce:729228:202001000100100110001011001001100110110001001020202 |
2595 | +upce:116746:202011001100110010000101011101100111010101111020202 |
2596 | +upce:293469:202001101100101110111101010001101011110010111020202 |
2597 | +upce:555569:202011100101100010111001011000100001010001011020202 |
2598 | +upce:786474:202001000100010010000101010001101110110100011020202 |
2599 | +upce:761950:202001000101011110110011000101101100010100111020202 |
2600 | +upce:585584:202011100101101110111001011000100010010100011020202 |
2601 | +upce:929816:202001011100110110001011011011100110010000101020202 |
2602 | +upce:311259:202010000100110010011001001101101110010001011020202 |
2603 | +upce:694531:202000010100101110011101011000101111010011001020202 |
2604 | +upce:375808:202010000100100010110001011011101101110011101020202 |
2605 | +upce:240462:202001101100111010001101010001100001010010011020202 |
2606 | +upce:309270:202010000100011010010111001001100100010001101020202 |
2607 | +upce:531272:202011100101111010110011001001101110110011011020202 |
2608 | +upce:910577:202001011100110010001101011100100100010111011020202 |
2609 | +upce:816561:202000100100110010000101011000100001010011001020202 |
2610 | +upce:805838:202000100100011010110001011011101000010001001020202 |
2611 | +upce:533215:202011100101000010111101001101100110010110001020202 |
2612 | +upce:346122:202010000101000110000101001100100100110011011020202 |
2613 | +upce:625930:202000010100100110110001001011101000010001101020202 |
2614 | +upce:952717:202001011101110010010011001000100110010111011020202 |
2615 | +upce:402896:202001110101001110010011011011100010110000101020202 |
2616 | +upce:295983:202001101100101110110001000101101101110100001020202 |
2617 | +upce:024592:202010011100100110011101011000100010110011011020202 |
2618 | +upce:289724:202001101101101110010111011101100100110011101020202 |
2619 | +upce:252704:202001101101110010011011011101100011010100011020202 |
2620 | +upce:273290:202001101101110110111101001101100010110100111020202 |
2621 | +upce:385633:202010000100010010110001010111101111010100001020202 |
2622 | +upce:549951:202011100100111010001011001011101100010011001020202 |
2623 | +upce:568347:202011100101011110110111010000100111010111011020202 |
2624 | +upce:214740:202001101100110010011101001000101000110001101020202 |
2625 | +upce:969934:202001011101011110010111000101101111010011101020202 |
2626 | +upce:832367:202000100101111010010011010000100001010111011020202 |
2627 | +upce:359222:202010000101100010001011001101100110110010011020202 |
2628 | +upce:508230:202011100101001110001001001001101111010001101020202 |
2629 | +upce:308002:202010000101001110110111010011100011010010011020202 |
2630 | +upce:318751:202010000100110010001001011101101110010011001020202 |
2631 | +upce:174459:202011001100100010011101010001101100010001011020202 |
2632 | +upce:403448:202001110101001110111101010001101000110001001020202 |
2633 | +upce:429459:202001110100100110010111010001101110010001011020202 |
2634 | +upce:271338:202001101100100010110011011110101111010110111020202 |
2635 | +upce:515949:202011100100110010110001001011101000110010111020202 |
2636 | +upce:066186:202010011101011110000101001100100010010101111020202 |
2637 | +upce:609466:202000010100011010001011001110101011110000101020202 |
2638 | +upce:857406:202000100101110010010001010001101011110100011020202 |
2639 | +upce:237382:202001101101111010111011010000101101110011011020202 |
2640 | +upce:260304:202001101100001010001101010000100011010100011020202 |
2641 | +upce:899152:202000100100101110010111001100101100010010011020202 |
2642 | +upce:773424:202001000100100010111101001110100100110100011020202 |
2643 | +upce:367789:202010000101011110111011011101100010010010111020202 |
2644 | +upce:344078:202010000100111010011101000110101110110110111020202 |
2645 | +upce:627031:202000010100100110010001000110101000010011001020202 |
2646 | +upce:146732:202011001100111010101111001000101111010010011020202 |
2647 | +upce:608666:202000010100011010001001000010101011110101111020202 |
2648 | +upce:855228:202000100101110010111001001001100100110110111020202 |
2649 | +upce:439192:202001110101000010010111001100100010110010011020202 |
2650 | +upce:917451:202001011100110010010001010001101110010011001020202 |
2651 | +upce:072613:202010011101110110100111010111100110010011011020202 |
2652 | +upce:813590:202000100100110010100001011000100010110100111020202 |
2653 | +upce:176138:202011001100100010101111001100101000010110111020202 |
2654 | +upce:690945:202000010100101110001101001011101000110110001020202 |
2655 | +upce:849613:202000100100111010001011010111101100110111101020202 |
2656 | +upce:269053:202001101101011110001011000110101110010100001020202 |
2657 | +upce:701050:202001000100011010011001010011101110010001101020202 |
2658 | +upce:074527:202010011101110110011101011000100110110111011020202 |
2659 | +upce:218296:202001101100110010001001001101100010110101111020202 |
2660 | +upce:874938:202000100100100010100011000101101111010001001020202 |
2661 | +upce:023936:202010011100110110111101000101101111010000101020202 |
2662 | +upce:896764:202000100100101110000101011101101011110100011020202 |
2663 | +upce:979612:202001011100100010001011010111101100110010011020202 |
2664 | +upce:137449:202011001101000010010001010001101000110001011020202 |
2665 | +upce:687160:202000010100010010010001001100101011110001101020202 |
2666 | +upce:839620:202000100101111010010111000010100100110001101020202 |
2667 | +upce:921800:202001011100100110110011000100100011010001101020202 |
2668 | +ean5:72823:010110010001010011011010110111010010011010111101 |
2669 | +ean5:19075:010110110011010001011010001101010010001010110001 |
2670 | +ean5:16659:010110011001010000101010101111010111001010001011 |
2671 | +ean5:54239:010110111001010100011010011011010111101010001011 |
2672 | +ean5:70848:010110111011010001101010001001010011101010110111 |
2673 | +ean5:75795:010110010001010110001010111011010001011010111001 |
2674 | +ean5:15726:010110011001010110001010010001010011011010101111 |
2675 | +ean5:58560:010110110001010110111010110001010000101010100111 |
2676 | +ean5:24670:010110011011010100011010101111010111011010100111 |
2677 | +ean5:24946:010110011011010100011010001011010100011010000101 |
2678 | +ean5:69776:010110000101010001011010010001010111011010101111 |
2679 | +ean5:74692:010110010001010100011010101111010010111010010011 |
2680 | +ean5:10925:010110110011010001101010001011010010011010111001 |
2681 | +ean5:63372:010110000101010111101010111101010111011010011011 |
2682 | +ean5:62942:010110101111010010011010010111010011101010010011 |
2683 | +ean5:35265:010110111101010110001010011011010101111010111001 |
2684 | +ean5:38088:010110111101010001001010001101010001001010110111 |
2685 | +ean5:50203:010110111001010100111010010011010001101010111101 |
2686 | +ean5:57111:010110111001010111011010011001010011001010110011 |
2687 | +ean5:64593:010110101111010100011010111001010001011010100001 |
2688 | +ean5:52424:010110110001010010011010011101010011011010100011 |
2689 | +ean5:77259:010110010001010111011010010011010111001010001011 |
2690 | +ean5:07028:010110001101010111011010100111010011011010110111 |
2691 | +ean5:50627:010110111001010001101010101111010011011010111011 |
2692 | +ean5:60414:010110000101010001101010011101010011001010100011 |
2693 | +ean5:86940:010110001001010101111010010111010100011010001101 |
2694 | +ean5:36095:010110111101010101111010100111010001011010111001 |
2695 | +ean5:01124:010110100111010011001010011001010011011010100011 |
2696 | +ean5:57346:010110111001010111011010100001010100011010101111 |
2697 | +ean5:79607:010110010001010001011010000101010001101010111011 |
2698 | +ean5:31184:010110111101010011001010110011010001001010100011 |
2699 | +ean5:29583:010110011011010001011010110001010110111010100001 |
2700 | +ean5:75568:010110111011010110001010111001010101111010001001 |
2701 | +ean5:53258:010110110001010100001010010011010111001010110111 |
2702 | +ean5:78345:010110010001010110111010111101010100011010111001 |
2703 | +ean5:56838:010110110001010000101010001001010111101010110111 |
2704 | +ean5:61031:010110101111010110011010001101010100001010011001 |
2705 | +ean5:98054:010110001011010110111010001101010111001010011101 |
2706 | +ean5:28204:010110010011010110111010010011010100111010011101 |
2707 | +ean5:18738:010110011001010001001010111011010100001010110111 |
2708 | +ean5:17221:010110110011010111011010010011010010011010110011 |
2709 | +ean5:02270:010110001101010011011010010011010010001010001101 |
2710 | +ean5:02378:010110001101010011011010100001010111011010110111 |
2711 | +ean5:15957:010110110011010110001010010111010110001010111011 |
2712 | +ean5:13621:010110011001010111101010000101010010011010110011 |
2713 | +ean5:98891:010110001011010001001010110111010010111010011001 |
2714 | +ean5:50554:010110110001010100111010110001010111001010100011 |
2715 | +ean5:22677:010110010011010010011010101111010010001010010001 |
2716 | +ean5:49420:010110011101010001011010100011010010011010100111 |
2717 | +ean5:57712:010110110001010010001010010001010011001010010011 |
2718 | +ean5:13839:010110011001010100001010110111010111101010010111 |
2719 | +ean5:36422:010110111101010101111010011101010010011010011011 |
2720 | +ean5:10137:010110011001010100111010110011010111101010111011 |
2721 | +ean5:22734:010110010011010011011010010001010111101010100011 |
2722 | +ean5:25562:010110010011010110001010110001010000101010011011 |
2723 | +ean5:49015:010110100011010010111010001101010110011010110001 |
2724 | +ean5:34620:010110100001010100011010000101010010011010001101 |
2725 | +ean5:74909:010110010001010100011010010111010001101010001011 |
2726 | +ean5:57115:010110110001010111011010110011010110011010110001 |
2727 | +ean5:84963:010110001001010011101010001011010101111010111101 |
2728 | +ean5:95948:010110001011010110001010010111010100011010001001 |
2729 | +ean5:36006:010110100001010101111010100111010001101010101111 |
2730 | +ean5:05457:010110100111010110001010100011010110001010010001 |
2731 | +ean5:54806:010110111001010100011010110111010001101010000101 |
2732 | +ean5:32152:010110100001010010011010110011010110001010010011 |
2733 | +ean5:64913:010110101111010100011010010111010011001010100001 |
2734 | +ean5:53560:010110111001010111101010111001010101111010001101 |
2735 | +ean5:57373:010110110001010111011010100001010111011010100001 |
2736 | +ean5:54685:010110110001010100011010101111010001001010111001 |
2737 | +ean5:75408:010110010001010110001010100011010100111010110111 |
2738 | +ean5:56632:010110111001010000101010101111010111101010010011 |
2739 | +ean5:22639:010110010011010010011010101111010100001010010111 |
2740 | +ean5:92955:010110010111010010011010001011010111001010110001 |
2741 | +ean5:75465:010110111011010111001010100011010000101010110001 |
2742 | +ean5:56506:010110111001010101111010110001010100111010101111 |
2743 | +ean5:22627:010110011011010010011010000101010010011010111011 |
2744 | +ean5:98251:010110010111010110111010010011010110001010110011 |
2745 | +ean5:90220:010110010111010001101010011011010010011010001101 |
2746 | +ean5:93426:010110010111010111101010100011010011011010101111 |
2747 | +ean5:74169:010110010001010100011010110011010101111010001011 |
2748 | +ean5:36259:010110100001010101111010011011010110001010001011 |
2749 | +ean5:71855:010110111011010110011010001001010110001010110001 |
2750 | +ean5:04584:010110001101010100011010111001010001001010100011 |
2751 | +ean5:01152:010110100111010011001010011001010110001010011011 |
2752 | +ean5:72757:010110111011010010011010111011010111001010010001 |
2753 | +ean5:28673:010110010011010001001010101111010111011010100001 |
2754 | +ean5:75084:010110010001010111001010001101010110111010100011 |
2755 | +ean5:10562:010110011001010100111010110001010101111010011011 |
2756 | +ean5:63726:010110000101010111101010111011010011011010101111 |
2757 | +ean5:04292:010110001101010100011010011011010001011010011011 |
2758 | +ean5:77513:010110111011010010001010110001010110011010111101 |
2759 | +ean5:17826:010110011001010111011010110111010011011010000101 |
2760 | +ean5:44790:010110011101010011101010111011010001011010001101 |
2761 | +ean5:39572:010110111101010010111010111001010111011010010011 |
2762 | +ean5:55321:010110111001010111001010111101010010011010011001 |
2763 | +ean5:89717:010110110111010001011010111011010110011010010001 |
2764 | +ean5:02126:010110001101010011011010011001010011011010101111 |
2765 | +ean5:30106:010110100001010100111010011001010001101010101111 |
2766 | +ean5:57489:010110110001010111011010011101010110111010010111 |
2767 | +ean5:26505:010110011011010000101010110001010001101010110001 |
2768 | +upca:40710631975:20201000110001101011101100110010001101010111102020100001011001101110100100010010011101100110202 |
2769 | +upca:80176224795:20201101110001101001100101110110101111001001102020110110010111001000100111010010011101100110202 |
2770 | +upca:92748137722:20200010110010011011101101000110110111001100102020100001010001001000100110110011011001010000202 |
2771 | +upca:32450677259:20201111010010011010001101100010001101010111102020100010010001001101100100111011101001110010202 |
2772 | +upca:40851674702:20201000110001101011011101100010011001010111102020100010010111001000100111001011011001001000202 |
2773 | +upca:59115174167:20201100010001011001100100110010110001001100102020100010010111001100110101000010001001100110202 |
2774 | +upca:84003578078:20201101110100011000110100011010111101011000102020100010010010001110010100010010010001001000202 |
2775 | +upca:95062540829:20200010110110001000110101011110010011011000102020101110011100101001000110110011101001010000202 |
2776 | +upca:64901078016:20201011110100011000101100011010011001000110102020100010010010001110010110011010100001110010202 |
2777 | +upca:48432140125:20201000110110111010001101111010010011001100102020101110011100101100110110110010011101010000202 |
2778 | +upca:17430588576:20200110010111011010001101111010001101011000102020100100010010001001110100010010100001001000202 |
2779 | +upca:63153964133:20201011110111101001100101100010111101000101102020101000010111001100110100001010000101010000202 |
2780 | +upca:74093932950:20201110110100011000110100010110111101000101102020100001011011001110100100111011100101001110202 |
2781 | +upca:57541363089:20201100010111011011000101000110011001011110102020101000010000101110010100100011101001000100202 |
2782 | +upca:07377087198:20200011010111011011110101110110111011000110102020100100010001001100110111010010010001110100202 |
2783 | +upca:05635524594:20200011010110001010111101111010110001011000102020110110010111001001110111010010111001001000202 |
2784 | +upca:70318362910:20201110110001101011110100110010110111011110102020101000011011001110100110011011100101011100202 |
2785 | +upca:36925218506:20201111010101111000101100100110110001001001102020110011010010001001110111001010100001001110202 |
2786 | +upca:45343236277:20201000110110001011110101000110111101001001102020100001010100001101100100010010001001110010202 |
2787 | +upca:03926388241:20200011010111101000101100100110101111011110102020100100010010001101100101110011001101101100202 |
2788 | +upca:64192083538:20201011110100011001100100010110010011000110102020100100010000101001110100001010010001100110202 |
2789 | +upca:25525653142:20200100110110001011000100100110110001010111102020100111010000101100110101110011011001110010202 |
2790 | +upca:38104462945:20201111010110111001100100011010100011010001102020101000011011001110100101110010011101001000202 |
2791 | +upca:09225889378:20200011010001011001001100100110110001011011102020100100011101001000010100010010010001000100202 |
2792 | +upca:93748811785:20200010110111101011101101000110110111011011102020110011011001101000100100100010011101001110202 |
2793 | +upca:30467816622:20201111010001101010001101011110111011011011102020110011010100001010000110110011011001110100202 |
2794 | +upca:74931591622:20201110110100011000101101111010011001011000102020111010011001101010000110110011011001000010202 |
2795 | +upca:92475784788:20200010110010011010001101110110110001011101102020100100010111001000100100100010010001110100202 |
2796 | +upca:40454544331:20201000110001101010001101100010100011011000102020101110010111001000010100001011001101000010202 |
2797 | +upca:35237883084:20201111010110001001001101111010111011011011102020100100010000101110010100100010111001100110202 |
2798 | +upca:75646706855:20201110110110001010111101000110101111011101102020111001010100001001000100111010011101000100202 |
2799 | +upca:82889483314:20201101110010011011011101101110001011010001102020100100010000101000010110011010111001101100202 |
2800 | +upca:73893633416:20201110110111101011011100010110111101010111102020100001010000101011100110011010100001001110202 |
2801 | +upca:10454576813:20200110010001101010001101100010100011011000102020100010010100001001000110011010000101101100202 |
2802 | +upca:33334522835:20201111010111101011110101111010100011011000102020110110011011001001000100001010011101110100202 |
2803 | +upca:45793591164:20201000110110001011101100010110111101011000102020111010011001101100110101000010111001110010202 |
2804 | +upca:18057726450:20200110010110111000110101100010111011011101102020110110010100001011100100111011100101000100202 |
2805 | +upca:96083152912:20200010110101111000110101101110111101001100102020100111011011001110100110011011011001001000202 |
2806 | +upca:16563181689:20200110010101111011000101011110111101001100102020100100011001101010000100100011101001101100202 |
2807 | +upca:51276473461:20201100010011001001001101110110101111010001102020100010010000101011100101000011001101011100202 |
2808 | +upca:08128913293:20200011010110111001100100100110110111000101102020110011010000101101100111010010000101011100202 |
2809 | +upca:34146752391:20201111010100011001100101000110101111011101102020100111011011001000010111010011001101000100202 |
2810 | +upca:97515692692:20200010110111011011000100110010110001010111102020111010011011001010000111010011011001000100202 |
2811 | +upca:97669919853:20200010110111011010111101011110001011000101102020110011011101001001000100111010000101010000202 |
2812 | +upca:18678734797:20200110010110111010111101110110110111011101102020100001010111001000100111010010001001110100202 |
2813 | +upca:74076303825:20201110110100011000110101110110101111011110102020111001010000101001000110110010011101000010202 |
2814 | +upca:08662387020:20200011010110111010111101011110010011011110102020100100010001001110010110110011100101010000202 |
2815 | +upca:26133671442:20200100110101111001100101111010111101010111102020100010011001101011100101110011011001000010202 |
2816 | +upca:87138605931:20201101110111011001100101111010110111010111102020111001010011101110100100001011001101001110202 |
2817 | +upca:67189289819:20201011110111011001100101101110001011001001102020100100011101001001000110011011101001110010202 |
2818 | +upca:09759720707:20200011010001011011101101100010001011011101102020110110011100101000100111001010001001000010202 |
2819 | +upca:56485529906:20201100010101111010001101101110110001011000102020110110011101001110100111001010100001110100202 |
2820 | +upca:58154525395:20201100010110111001100101100010100011011000102020110110010011101000010111010010011101001000202 |
2821 | +upca:67888609275:20201011110111011011011101101110110111010111102020111001011101001101100100010010011101010000202 |
2822 | +upca:15168153237:20200110010110001001100101011110110111001100102020100111010000101101100100001010001001110010202 |
2823 | +upca:74424730673:20201110110100011010001100100110100011011101102020100001011100101010000100010010000101110100202 |
2824 | +upca:45168971187:20201000110110001001100101011110110111000101102020100010011001101100110100100010001001000100202 |
2825 | +upca:12149723784:20200110010010011001100101000110001011011101102020110110010000101000100100100010111001011100202 |
2826 | +upca:33804286457:20201111010111101011011100011010100011001001102020100100010100001011100100111010001001101100202 |
2827 | +upca:27558248562:20200100110111011011000101100010110111001001102020101110010010001001110101000011011001011100202 |
2828 | +upca:92390267160:20200010110010011011110100010110001101001001102020101000010001001100110101000011100101000100202 |
2829 | +upca:63742039163:20201011110111101011101101000110010011000110102020100001011101001100110101000010000101101100202 |
2830 | +upca:67117098326:20201011110111011001100100110010111011000110102020111010010010001000010110110010100001010000202 |
2831 | +upca:32901624258:20201111010010011000101100011010011001010111102020110110010111001101100100111010010001001000202 |
2832 | +upca:88848685777:20201101110110111011011101000110110111010111102020100100010011101000100100010010001001101100202 |
2833 | +upca:57070085601:20201100010111011000110101110110001101000110102020100100010011101010000111001011001101100110202 |
2834 | +upca:83043128438:20201101110111101000110101000110111101001100102020110110010010001011100100001010010001010000202 |
2835 | +upca:52432147628:20201100010010011010001101111010010011001100102020101110010001001010000110110010010001001000202 |
2836 | +upca:15067795584:20200110010110001000110101011110111011011101102020111010010011101001110100100010111001100110202 |
2837 | +upca:27777156430:20200100110111011011101101110110111011001100102020100111010100001011100100001011100101100110202 |
2838 | +upca:82471218344:20201101110010011010001101110110011001001001102020110011010010001000010101110010111001011100202 |
2839 | +upca:94175044091:20200010110100011001100101110110110001000110102020101110010111001110010111010011001101010000202 |
2840 | +upca:34936749963:20201111010100011000101101111010101111011101102020101110011101001110100101000010000101110100202 |
2841 | +upca:46502492658:20201000110101111011000100011010010011010001102020111010011011001010000100111010010001100110202 |
2842 | +upca:47153985860:20201000110111011001100101100010111101000101102020100100010011101001000101000011100101010000202 |
2843 | +upca:79601763982:20201110110001011010111100011010011001011101102020101000010000101110100100100011011001110010202 |
2844 | +upca:91685238225:20200010110011001010111101101110110001001001102020100001010010001101100110110010011101110100202 |
2845 | +upca:46916417994:20201000110101111000101100110010101111010001102020110011010001001110100111010010111001011100202 |
2846 | +upca:30878845484:20201111010001101011011101110110110111011011102020101110010011101011100100100010111001110100202 |
2847 | +upca:39321907655:20201111010001011011110100100110011001000101102020111001010001001010000100111010011101011100202 |
2848 | +upca:48232524842:20201000110110111001001101111010010011011000102020110110010111001001000101110011011001010000202 |
2849 | +upca:94750199914:20200010110100011011101101100010001101001100102020111010011101001110100110011010111001010000202 |
2850 | +upca:28310653784:20200100110110111011110100110010001101010111102020100111010000101000100100100010111001100110202 |
2851 | +upca:00814405096:20200011010001101011011100110010100011010001102020111001010011101110010111010010100001000100202 |
2852 | +upca:60974743279:20201011110001101000101101110110100011011101102020101110010000101101100100010011101001011100202 |
2853 | +upca:45141255670:20201000110110001001100101000110011001001001102020100111010011101010000100010011100101010000202 |
2854 | +upca:62241294735:20201011110010011001001101000110011001001001102020111010010111001000100100001010011101001110202 |
2855 | +upca:67241197048:20201011110111011001001101000110011001001100102020111010010001001110010101110010010001110100202 |
2856 | +upca:57709892169:20201100010111011011101100011010001011011011102020111010011011001100110101000011101001000100202 |
2857 | +upca:49234133045:20201000110001011001001101111010100011001100102020100001010000101110010101110010011101010000202 |
2858 | +upca:44106865868:20201000110100011001100100011010101111011011102020101000010011101001000101000010010001001000202 |
2859 | +upca:07033900539:20200011010111011000110101111010111101000101102020111001011100101001110100001011101001000100202 |
2860 | +upca:63922260360:20201011110111101000101100100110010011001001102020101000011100101000010101000011100101110100202 |
2861 | +upca:63544942112:20201011110111101011000101000110100011000101102020101110011011001100110110011011011001001110202 |
2862 | +upca:52602007800:20201100010010011010111100011010010011000110102020111001010001001001000111001011100101001000202 |
2863 | +upca:94048257810:20200010110100011000110101000110110111001001102020100111010001001001000110011011100101101100202 |
2864 | +upca:82699181094:20201101110010011010111100010110001011001100102020100100011001101110010111010010111001000010202 |
2865 | +upca:94628599972:20200010110100011010111100100110110111011000102020111010011101001110100100010011011001011100202 |
2866 | +upca:09938844603:20200011010001011000101101111010110111011011102020101110010111001010000111001010000101010000202 |
2867 | +upca:37128560103:20201111010111011001100100100110110111011000102020101000011100101100110111001010000101110010202 |
2868 | |
2869 | === modified file 'share/extensions/test/render_barcode.test.py' |
2870 | --- share/extensions/test/render_barcode.test.py 2009-04-13 20:05:53 +0000 |
2871 | +++ share/extensions/test/render_barcode.test.py 2010-12-30 04:23:15 +0000 |
2872 | @@ -1,20 +1,39 @@ |
2873 | #!/usr/bin/env python |
2874 | - |
2875 | -# This is only the automatic generated test file for ../render_barcode.py |
2876 | -# This must be filled with real tests and this commentary |
2877 | -# must be cleared. |
2878 | -# If you want to help, read the python unittest documentation: |
2879 | -# http://docs.python.org/library/unittest.html |
2880 | +# |
2881 | +# Copyright (C) 2010 Martin Owens |
2882 | +# |
2883 | +# Written to test the coding of generating barcodes. |
2884 | +# |
2885 | |
2886 | import sys |
2887 | -sys.path.append('..') # this line allows to import the extension code |
2888 | - |
2889 | +import random |
2890 | import unittest |
2891 | + |
2892 | +# Allow import of the extension code and modules |
2893 | +sys.path.append('..') |
2894 | + |
2895 | from render_barcode import * |
2896 | |
2897 | +import Barcode.EAN5 |
2898 | +import Barcode.EAN8 |
2899 | +import Barcode.EAN13 |
2900 | +import Barcode.UPCA |
2901 | +import Barcode.UPCE |
2902 | + |
2903 | +digits = [ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' ] |
2904 | + |
2905 | class InsertBarcodeBasicTest(unittest.TestCase): |
2906 | - |
2907 | - #def setUp(self): |
2908 | + """Render Barcode""" |
2909 | + def setUp(self): |
2910 | + self.data = {} |
2911 | + fhl = open('render_barcode.data', 'r') |
2912 | + for line in fhl: |
2913 | + line = line.replace('\n', '').replace('\r', '') |
2914 | + (btype, text, code) = line.split(':') |
2915 | + if not self.data.has_key(btype): |
2916 | + self.data[btype] = [] |
2917 | + self.data[btype].append( [ text, code ] ) |
2918 | + fhl.close() |
2919 | |
2920 | def test_run_without_parameters(self): |
2921 | args = [ 'minimal-blank.svg' ] |
2922 | @@ -22,5 +41,36 @@ |
2923 | e.affect( args, False ) |
2924 | #self.assertEqual( e.something, 'some value', 'A commentary about that.' ) |
2925 | |
2926 | + def test_render_barcode_ian5(self): |
2927 | + """Barcode IAN5""" |
2928 | + self.barcode_test( 'ean5', Barcode.EAN5 ) |
2929 | + |
2930 | + def test_render_barcode_ian8(self): |
2931 | + """Barcode IAN5""" |
2932 | + self.barcode_test( 'ean8', Barcode.EAN8 ) |
2933 | + |
2934 | + def test_render_barcode_ian13(self): |
2935 | + """Barcode IAN5""" |
2936 | + self.barcode_test( 'ean13', Barcode.EAN13 ) |
2937 | + |
2938 | + def test_render_barcode_upca(self): |
2939 | + """Barcode IAN5""" |
2940 | + self.barcode_test( 'upca', Barcode.UPCA ) |
2941 | + |
2942 | + def test_render_barcode_upce(self): |
2943 | + """Barcode UPCE""" |
2944 | + self.barcode_test( 'upce', Barcode.UPCE ) |
2945 | + |
2946 | + def barcode_test(self, name, module): |
2947 | + """Base module for all barcode testing""" |
2948 | + for datum in self.data[name]: |
2949 | + (text, code) = datum |
2950 | + if not text or not code: |
2951 | + continue |
2952 | + code2 = module.Object( {'text': text} ).encode(text) |
2953 | + self.assertEqual(code, code2) |
2954 | + |
2955 | + |
2956 | if __name__ == '__main__': |
2957 | unittest.main() |
2958 | + |
Martin,
Thank you for the time you put into this. Works great! can we add this to all versions I can do it after the merge is approved.
I approve it, but it will have to be Admin to say OK I know.
Regards,
Leo Jackson