From 819dee4e7dbaa860ef18f6f51093fccfe085ac3f Mon Sep 17 00:00:00 2001 From: Pavol Rusnak Date: Sun, 24 Apr 2011 19:04:07 +0200 Subject: [PATCH] finish barcode generator --- barcodes.py | 12 ++++++++++-- brmbar.c | 8 ++++---- items.txt | 38 +++++++++++++++++++------------------- 3 files changed, 33 insertions(+), 25 deletions(-) diff --git a/barcodes.py b/barcodes.py index 081ec2f..cfafe28 100755 --- a/barcodes.py +++ b/barcodes.py @@ -25,8 +25,14 @@ f.close() items = map(lambda x: x.strip(), items) itemss = map(lambda x: x[0:3], items) -items += ['credit 20', 'credit 50', 'credit 100', 'credit 200', 'credit 500', 'credit 1000', 'RESET'] -itemss += ['$02','$05','$10','$20','$50','$1k','RST'] + +f = open('items.txt','r') +for l in f.readlines(): + l = l.strip().split(';') + if int(l[2]) >= 0: + items += [l[1]] + itemss += [l[0]] +f.close() f = open('barcodes.svg','w') f.write(svghead) @@ -37,6 +43,8 @@ for idx in xrange(len(items)): elem = Popen(('zint','--directsvg','-d', itemss[idx]), 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, 52+i*160 , 14+j*100) ) + elem[21] = elem[21].replace(' y="59.00" ', ' y="69.00" ') + elem[22] = elem[22].replace(' font-size="8.0" ', ' font-size="14.0" ') elem[23] = items[idx] f.write('\n'.join(elem)) i += 1 diff --git a/brmbar.c b/brmbar.c index aaf1c1e..962e5e1 100644 --- a/brmbar.c +++ b/brmbar.c @@ -42,10 +42,10 @@ void fill_items() //Read the item EAN while (i < BUFSIZE) { - if (buf[i] == '\t') { + if (buf[i] == ';') { buf[i] = 0; strcpy(items[items_count].ean, &buf[begin]); - buf[i] = '\t'; + buf[i] = ';'; begin = i + 1; break; } @@ -55,10 +55,10 @@ void fill_items() //Read the item name i = begin; while (i < BUFSIZE) { - if (buf[i] == '\t') { + if (buf[i] == ';') { buf[i] = 0; strcpy(items[items_count].name, &buf[begin]); - buf[i] = '\t'; + buf[i] = ';'; begin = i+1; break; } diff --git a/items.txt b/items.txt index 54f936d..7edda55 100644 --- a/items.txt +++ b/items.txt @@ -1,19 +1,19 @@ -$02 Credit 20 -$05 Credit 50 -$10 Credit 100 -$20 Credit 200 -$50 Credit 500 -$1k Credit 1000 -RST RESET 0 -4029764001807 Club Mate 0.5L -35 -4029764001821 Club Mate 0.33L -25 -5018374350930 Tesco Baked Beans in Tomato Sauce -20 -7622300331436 Delissa mlecna -10 -7622300331498 Delissa oriskova -10 -8593868000555 Pivo Branik 10% svetle -25 -8594404000329 Pivo Gambrinus 10% svetle -25 -8594404001241 Pivo Radegast 10% svetle -25 -8594001021512 Matonni perliva 1,5L -20 -5449000000286 Coca-Cola 2L -50 -8801043263108 Shin Cup Noodle Soup -25 -8934646229308 Lucky Beef Flavor -10 +$02;Credit 20;20 +$05;Credit 50;50 +$10;Credit 100;100 +$20;Credit 200;200 +$50;Credit 500;500 +$1k;Credit 1000;1000 +STS;Show status;0 +4029764001807;Club Mate 0.5L;-35 +4029764001821;Club Mate 0.33L;-25 +5018374350930;Tesco Baked Beans in Tomato Sauce;-20 +7622300331436;Delissa mlecna;-10 +7622300331498;Delissa oriskova;-10 +8593868000555;Pivo Branik 10% svetle;-25 +8594404000329;Pivo Gambrinus 10% svetle;-25 +8594404001241;Pivo Radegast 10% svetle;-25 +8594001021512;Matonni perliva 1,5L;-20 +5449000000286;Coca-Cola 2L;-50 +8801043263108;Shin Cup Noodle Soup;-25 +8934646229308;Lucky Beef Flavor;-10