Add QR codes for Web UI
This commit is contained in:
parent
5a5202e6f5
commit
a822ea5184
@ -17,6 +17,7 @@ import os
|
||||
import glob
|
||||
import sys
|
||||
from PIL import Image
|
||||
import segno
|
||||
|
||||
def touch(path):
|
||||
with open(path, 'a'):
|
||||
@ -197,6 +198,18 @@ def parse(filename, output_dir, partnum, dstype, weburl, extra):
|
||||
else:
|
||||
img = None
|
||||
|
||||
fprint("Making QR code for part " + partnum)
|
||||
partnumqr = partnum.replace(" ", "%20")
|
||||
if dstype == "Alphawire":
|
||||
partnumqr = "AW" + partnumqr
|
||||
if dstype == "Belden":
|
||||
partnumqr = "BL" + partnumqr
|
||||
qrcode = segno.make('HTTPS://BLDN.APP/' + partnumqr,micro=False,boost_error=False,error="L",mask=3)
|
||||
#out = io.BytesIO()
|
||||
qrx, _ = qrcode.symbol_size(1,0)
|
||||
qrcode.save(output_dir + "/qrcode.png", scale=500.0/qrx, kind="PNG", border=0, light="#00000000")
|
||||
qrpath = weburl + find_file_noext(output_dir, prefix="qrcode")[0]
|
||||
|
||||
# Table parsing and reordring
|
||||
tables = dict()
|
||||
torename = dict()
|
||||
@ -369,13 +382,14 @@ def parse(filename, output_dir, partnum, dstype, weburl, extra):
|
||||
else:
|
||||
output_table["brand"] = dstype
|
||||
output_table["datasheet"] = weburl + "datasheet.pdf"
|
||||
output_table["qrcode"] = qrpath
|
||||
if img is not None:
|
||||
output_table["image"] = img
|
||||
output_table["fullspecs"] = {"partnum": partnum, "id": id, "brand": output_table["brand"], "image": img, "datasheet": weburl + "datasheet.pdf", **tables}
|
||||
output_table["searchspecs"] = {"partnum": partnum, "brand": output_table["brand"], "image": img, "datasheet": weburl + "datasheet.pdf", **flatten(tables)}
|
||||
output_table["fullspecs"] = {"partnum": partnum, "id": id, "brand": output_table["brand"], "image": img, "datasheet": weburl + "datasheet.pdf", "qrcode": qrpath, **tables}
|
||||
output_table["searchspecs"] = {"partnum": partnum, "brand": output_table["brand"], "image": img, "datasheet": weburl + "datasheet.pdf", "qrcode": qrpath, **flatten(tables)}
|
||||
else:
|
||||
output_table["fullspecs"] = {"partnum": partnum, "id": id, "brand": output_table["brand"], "datasheet": weburl + "datasheet.pdf", **tables}
|
||||
output_table["searchspecs"] = {"partnum": partnum, "brand": output_table["brand"], "datasheet": weburl + "datasheet.pdf", **flatten(tables)}
|
||||
output_table["fullspecs"] = {"partnum": partnum, "id": id, "brand": output_table["brand"], "datasheet": weburl + "datasheet.pdf", "qrcode": qrpath, **tables}
|
||||
output_table["searchspecs"] = {"partnum": partnum, "brand": output_table["brand"], "datasheet": weburl + "datasheet.pdf", "qrcode": qrpath, **flatten(tables)}
|
||||
|
||||
if "short_description" in extra:
|
||||
output_table["short_description"] = extra["short_description"]
|
||||
|
Loading…
x
Reference in New Issue
Block a user