|
|
@ -1,6 +1,7 @@
|
|
|
|
# bureau
|
|
|
|
# bureau
|
|
|
|
import functools
|
|
|
|
import functools
|
|
|
|
import inspect
|
|
|
|
import inspect
|
|
|
|
|
|
|
|
import io
|
|
|
|
import json
|
|
|
|
import json
|
|
|
|
import logging
|
|
|
|
import logging
|
|
|
|
import os.path
|
|
|
|
import os.path
|
|
|
@ -12,6 +13,7 @@ import textwrap
|
|
|
|
#import traceback
|
|
|
|
#import traceback
|
|
|
|
import threading
|
|
|
|
import threading
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import barcode
|
|
|
|
import lmdb
|
|
|
|
import lmdb
|
|
|
|
import PIL
|
|
|
|
import PIL
|
|
|
|
import weasyprint
|
|
|
|
import weasyprint
|
|
|
@ -219,6 +221,26 @@ class Bureau(object):
|
|
|
|
db = KeyValStore(self.dbenv, name)
|
|
|
|
db = KeyValStore(self.dbenv, name)
|
|
|
|
return db
|
|
|
|
return db
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def bc_svg(self, code, tofile=False, outfile=None):
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
generate a CODE128 barcode as an SVG
|
|
|
|
|
|
|
|
returns a string or can write to a tmp file or specific
|
|
|
|
|
|
|
|
file given arguments
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
fp = io.BytesIO()
|
|
|
|
|
|
|
|
barcode.generate("CODE128", code, writer=barcode.writer.SVGWriter(), output=fp)
|
|
|
|
|
|
|
|
# TODO: add file output
|
|
|
|
|
|
|
|
return fp.read().decode()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def bc_png(self, code, outfile=None):
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
generate a code128 barcode as a png
|
|
|
|
|
|
|
|
returns the full path to the file
|
|
|
|
|
|
|
|
if file is not specified, uses a tmp file
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
# TODO: implement this (its like 5 lines!)
|
|
|
|
|
|
|
|
raise NotImplemented("png generation not implemented!")
|
|
|
|
|
|
|
|
|
|
|
|
def load_config(self):
|
|
|
|
def load_config(self):
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
load (or reload) config data from file
|
|
|
|
load (or reload) config data from file
|
|
|
|