Code

281702c1ee457a5270f599a6e8de5cb41d3edacd
[inkscape.git] / share / extensions / Barcode / __init__.py
1 #!/usr/bin/env python
2 '''
3 Barcodes SVG Extention
5 Supported Barcodes: EAN8, EAN13, Code39, Code39 Extended, Code93, Code128, RM4CC(RM4SCC)
7 Copyright (C) 2007 Martin Owens
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.
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.
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 '''
24 # This lists all known Barcodes missing from this package
25 # =========== UPC-Based =========== #
26 # ISBN (EAN13)
27 # ===== UPC-Based Extensions ====== #
28 # Code11
29 # ========= Code25-Based ========== #
30 # Code25
31 # Codabar
32 # Postnet
33 # ITF25
34 # ========= Alpha-numeric ========= #
35 # Code39Mod
36 # EAN128 (Code128)
37 # USPS128 
38 # =========== 2D Based ============ #
39 # PDF417
40 # PDF417-Macro
41 # PDF417-Truncated
42 # PDF417-GLI
44 import sys
46 def getBarcode(format, param={}):
47         if format:
48                 format = str(format).lower()
49                 format = format.replace('-', '')
50                 format = format.replace(' ', '')
51                 if 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 in ['ean13', 'ucc13','jan']:
75                         import EAN13
76                         return EAN13.Object(param)
77                 elif format == 'ean5':
78                         import EAN5
79                         return EAN5.Object(param)
80                 elif format in ['ean8', 'ucc8']:
81                         import EAN8
82                         return EAN8.Object(param)
83         sys.stderr.write("Invalid format for barcode: " + str(format) + "\n")