From 84881dece382c26446054a77d190d1fe5e0f9b68 Mon Sep 17 00:00:00 2001 From: Mrkva Date: Mon, 11 May 2015 02:04:11 +0200 Subject: [PATCH] * merge barcode-generator to master * quick howto on how current barcodes are generated --- barcode-generator/.gitignore | 2 + barcode-generator/barcode-generator.py | 51 ++++++++++++++++++++++++++ barcode-generator/howto.txt | 9 +++++ 3 files changed, 62 insertions(+) create mode 100644 barcode-generator/.gitignore create mode 100755 barcode-generator/barcode-generator.py create mode 100644 barcode-generator/howto.txt diff --git a/barcode-generator/.gitignore b/barcode-generator/.gitignore new file mode 100644 index 0000000..e6936f1 --- /dev/null +++ b/barcode-generator/.gitignore @@ -0,0 +1,2 @@ +barcodes*.svg +barcode-generator.txt diff --git a/barcode-generator/barcode-generator.py b/barcode-generator/barcode-generator.py new file mode 100755 index 0000000..f2d30a3 --- /dev/null +++ b/barcode-generator/barcode-generator.py @@ -0,0 +1,51 @@ +#!/usr/bin/python +# +# requires zint binary from zint package +# + +from subprocess import Popen, PIPE +import sys + +svghead = """ + + +""" + +svgfoot = """ +""" + +width = 5 +scalex = 0.8 +scaley = 0.8 + +p = 0 +i = 0 +j = 0 +f = None + +lines = sys.stdin.readlines() + +for idx in xrange(len(lines)): + items = lines[idx].strip().split(';') + if idx % 30 == 0: + if f and not f.closed: + f.write(svgfoot) + f.close() + f = open('barcodes' + str(p) + '.svg','w') + p += 1 + i = 0 + j = 0 + f.write(svghead) + elem = Popen(('./zint','--directsvg','--notext', '-d', items[1]), stdout = PIPE).communicate()[0].split('\n') + elem = elem[8:-2] + elem[0] = elem[0].replace('id="barcode"', 'transform="matrix(%f,0,0,%f,%f,%f)"' % (scalex, scaley, 50+i*140 , 180+j*140) ) + elem.insert(-1, ' %s' % items[0]) + f.write('\n'.join(elem)+'\n\n') + i += 1 + if i >= width: + i = 0 + j += 1 + +if not f.closed: + f.write(svgfoot) + f.close() diff --git a/barcode-generator/howto.txt b/barcode-generator/howto.txt new file mode 100644 index 0000000..4dfba63 --- /dev/null +++ b/barcode-generator/howto.txt @@ -0,0 +1,9 @@ +on brmbar: +select distinct barcode from barcodes b, transactions t, accounts a where t.responsible=a.id and time>'2015-01-01' and b.account=a.id order by barcode asc; + +run this locally and paste output of previous command: + +while read tmp; do echo "$tmp;$tmp";done|grep -v overflow|python2 ./barcode-generator.py + +print resulting SVG files +