Closed missionfloyd closed 11 months ago
Please provide more information how you created the QR codes.
Those were made with my QR code extension for stable-diffusion-webui. https://github.com/missionfloyd/webui-qrcode-generator/blob/master/scripts/qrcode.py#L23
It works right if I exclude the empty fields or set them to None
. This generates the "After" image above.
import segno
from segno import helpers
data = helpers.make_vcard_data(displayname="", name="Doe;John;", email="john@example.com")
qrcode = segno.make(data, micro=False, error="H", boost_error=False)
qrcode.save('vcard.png', scale=4)
But not if I pass it an empty string.
import segno
from segno import helpers
data = helpers.make_vcard_data(displayname="", name="Doe;John;", email="john@example.com", phone="")
qrcode = segno.make(data, micro=False, error="H", boost_error=False)
qrcode.save('vcard.png', scale=4)
Because it's explicitly checking for None
, instead of falsy values.
https://github.com/heuer/segno/blob/184c7ec15734aff48f553fdd1d332fe1aaddbbb5/segno/helpers.py#L150-L155
Of course, I could work around it with a bunch of or None
's.
data = helpers.make_vcard_data(name, displayname=args["vcard_displayname"], nickname=args["vcard_nickname"], street=args["vcard_address"], city=args["vcard_city"], region=args["vcard_state"], zipcode=args["vcard_zipcode"], country=args["vcard_country"], birthday=args["vcard_birthday"], email=args["vcard_email"] or None, phone=args["vcard_phone"] or None, fax=args["vcard_fax"] or None, memo=args["vcard_memo"], org=args["vcard_organization"], title=args["vcard_title"] or None, cellphone=(args["vcard_phone_mobile"] or None), url=(args["vcard_url"] or None))
Ok, thank you. Much better solution (testing for falsy value). I'll add a test case and merge it asap
Thanks!
Can result in a less dense (and thus easier to scan) code.
Before:
After: