mirror of
https://github.com/brmlab/misc.git
synced 2025-06-08 01:44:47 +02:00
barcodes.py -b: Wrap labels in 'brm lab' only if this switch is passed
This commit is contained in:
parent
1d59480cf0
commit
5612275fc8
1 changed files with 10 additions and 1 deletions
11
barcodes.py
11
barcodes.py
|
@ -5,12 +5,20 @@
|
||||||
#
|
#
|
||||||
# example: seq -f %06g 0 1000 | ./barcodes.py
|
# example: seq -f %06g 0 1000 | ./barcodes.py
|
||||||
#
|
#
|
||||||
|
# options:
|
||||||
|
# -b: label has format "brm - NUMER - lab" (for inventory stickers)
|
||||||
|
#
|
||||||
# requires zint binary from zint package
|
# requires zint binary from zint package
|
||||||
#
|
#
|
||||||
|
|
||||||
from subprocess import Popen, PIPE
|
from subprocess import Popen, PIPE
|
||||||
|
import argparse
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
parser = argparse.ArgumentParser()
|
||||||
|
parser.add_argument('-b', '--brmlabel', action='store_true')
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
svghead = """<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
svghead = """<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
<svg xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:cc="http://creativecommons.org/ns#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" width="1052.3622" height="744.09448" version="1.1" id="svg2" inkscape:version="0.47 r22583" sodipodi:docname="barcodes.svg">
|
<svg xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:cc="http://creativecommons.org/ns#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" width="1052.3622" height="744.09448" version="1.1" id="svg2" inkscape:version="0.47 r22583" sodipodi:docname="barcodes.svg">
|
||||||
"""
|
"""
|
||||||
|
@ -34,7 +42,8 @@ try:
|
||||||
elem = Popen(('zint','--directsvg','-d', data), stdout = PIPE).communicate()[0].split('\n')
|
elem = Popen(('zint','--directsvg','-d', data), stdout = PIPE).communicate()[0].split('\n')
|
||||||
elem = elem[8:-2]
|
elem = elem[8:-2]
|
||||||
elem[0] = elem[0].replace('id="barcode"', 'transform="matrix(%f,0,0,%f,%f,%f)"' % (scalex, scaley, 42+i*150 , 14+j*74.3) )
|
elem[0] = elem[0].replace('id="barcode"', 'transform="matrix(%f,0,0,%f,%f,%f)"' % (scalex, scaley, 42+i*150 , 14+j*74.3) )
|
||||||
elem[23] = 'brm - ' + elem[23].strip() + ' - lab'
|
if args.brmlabel:
|
||||||
|
elem[23] = 'brm - ' + elem[23].strip() + ' - lab'
|
||||||
f.write('\n'.join(elem))
|
f.write('\n'.join(elem))
|
||||||
except EOFError:
|
except EOFError:
|
||||||
pass
|
pass
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue