summaryrefslogtreecommitdiffstats
path: root/share/extensions/Barcode/__init__.py
diff options
context:
space:
mode:
authorRichard White <rwhite8282@gmail.com>2016-05-19 01:17:29 +0000
committerRichard White <rwhite8282@gmail.com>2016-05-19 01:17:29 +0000
commit1fe9c2603c33fddcd9f2688b30e843f91e1a86fa (patch)
tree13289cbe033a46a40eb829437e115b5393e2ca84 /share/extensions/Barcode/__init__.py
parentCorrected frame extension stroke and fill values on 64 bit machine. (diff)
parentGTK3: Another widget named. (diff)
downloadinkscape-1fe9c2603c33fddcd9f2688b30e843f91e1a86fa.tar.gz
inkscape-1fe9c2603c33fddcd9f2688b30e843f91e1a86fa.zip
Merge from Inkscape trunk.
(bzr r14668.1.3)
Diffstat (limited to 'share/extensions/Barcode/__init__.py')
-rw-r--r--share/extensions/Barcode/__init__.py18
1 files changed, 11 insertions, 7 deletions
diff --git a/share/extensions/Barcode/__init__.py b/share/extensions/Barcode/__init__.py
index e4e328ae3..fcfcfdbad 100644
--- a/share/extensions/Barcode/__init__.py
+++ b/share/extensions/Barcode/__init__.py
@@ -13,7 +13,7 @@
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
"""
Renderer for barcodes, SVG extention for Inkscape.
@@ -39,19 +39,23 @@ For supported barcodes see Barcode module directory.
import sys
-def getBarcode(code, **kwargs):
+class NoBarcode(object):
+ """Simple class for no barcode"""
+ def generate(self):
+ return None
+
+def getBarcode(code, **kw):
"""Gets a barcode from a list of available barcode formats"""
if not code:
return sys.stderr.write("No barcode format given!\n")
-
code = str(code).replace('-', '').strip()
+ mod = 'Barcode'
try:
- barcode = getattr(__import__('Barcode.'+code, fromlist=['Barcode']), code)
- return barcode(kwargs)
+ return getattr(__import__(mod+'.'+code, fromlist=[mod]), code)(kw)
except ImportError:
sys.stderr.write("Invalid type of barcode: %s\n" % code)
except AttributeError:
- raise
- sys.stderr.write("Barcode module is missing the barcode class: %s\n" % code)
+ sys.stderr.write("Barcode module is missing barcode class: %s\n" % code)
+ return NoBarcode()