""" app/utils/qr.py --------------- Generic QR-code SVG helper (phase38). Mirrors qr_svg() in app/utils/mfa.py (which is TOTP-specific and mirrored in control/mfa.py — do not touch those; this is the general-purpose variant for facility QR codes and any future QR needs). """ import io import qrcode import qrcode.image.svg def qr_svg(data: str) -> str: """Return an inline SVG string encoding `data` (no Pillow needed). The SVG carries its own width/height attrs; size it via CSS on the containing element (svg { width:…; height:…; }) when embedding. """ buf = io.BytesIO() qrcode.make(data, image_factory=qrcode.image.svg.SvgPathImage).save(buf) return buf.getvalue().decode('utf-8')