Code

Extensions. Barcode extension refactoring (see https://code.launchpad.net/~doctormo...
[inkscape.git] / share / extensions / Barcode / __init__.py
1 #
2 # Copyright (C) 2010 Martin Owens
3 #
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 2 of the License, or
7 # (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17 #
18 """
19 Renderer for barcodes, SVG extention for Inkscape. 
21 For supported barcodes see Barcode module directory.
23 """
25 # This lists all known Barcodes missing from this package
26 # ===== UPC-Based Extensions ====== #
27 # Code11
28 # ========= Code25-Based ========== #
29 # Codabar
30 # Postnet
31 # ITF25
32 # ========= Alpha-numeric ========= #
33 # Code39Mod
34 # USPS128 
35 # =========== 2D Based ============ #
36 # PDF417
37 # PDF417-Macro
38 # PDF417-Truncated
39 # PDF417-GLI
41 import sys
43 def getBarcode(format, param={}):
44     if format:
45         format = str(format).lower()
46         format = format.replace('-', '')
47         format = format.replace(' ', '')
48         if format=='code25i':
49             import Code25i
50             return Code25i.Object(param)
51         elif format=='code39':
52             import Code39
53             return Code39.Object(param)
54         elif format=='code39ext':
55             import Code39Ext
56             return Code39Ext.Object(param)
57         elif format=='code93':
58             import Code93
59             return Code93.Object(param)
60         elif format=='code128':
61             import Code128
62             return Code128.Object(param)
64         elif format in ['rm4cc', 'rm4scc']:
65             import RM4CC
66             return RM4CC.Object(param)
68         elif format == 'upca':
69             import UPCA
70             return UPCA.Object(param)
71         elif format == 'upce':
72             import UPCE
73             return UPCE.Object(param)
74         elif format == 'ean5':
75             import EAN5
76             return EAN5.Object(param)
77         elif format in ['ean8', 'ucc8']:
78             import EAN8
79             return EAN8.Object(param)
80         elif format in ['ean13', 'ucc13','jan']:
81             import EAN13
82             return EAN13.Object(param)
83     sys.stderr.write("Invalid format for barcode: " + str(format) + "\n")