|
@@ -11,12 +11,13 @@ QR_MAX_BYTES = {
|
|
ERROR_CORRECT_L: 2953,
|
|
ERROR_CORRECT_L: 2953,
|
|
}
|
|
}
|
|
QR_QUALITY_MAP = {
|
|
QR_QUALITY_MAP = {
|
|
- q: locals().get(f'ERROR_CORRECT_{q}') for q in (
|
|
|
|
- 'H', 'Q', 'M', 'L'
|
|
|
|
- )
|
|
|
|
|
|
+ 'H': ERROR_CORRECT_H,
|
|
|
|
+ 'Q': ERROR_CORRECT_Q,
|
|
|
|
+ 'M': ERROR_CORRECT_M,
|
|
|
|
+ 'L': ERROR_CORRECT_L,
|
|
}
|
|
}
|
|
def get_qr_code(data: Union[bytes, str], fallback: Union[bytes, str] = None, err_lvl='H'):
|
|
def get_qr_code(data: Union[bytes, str], fallback: Union[bytes, str] = None, err_lvl='H'):
|
|
- err_lvl = QR_QUALITY_MAP.get(err_lvl, err_lvl)
|
|
|
|
|
|
+ err_lvl = QR_QUALITY_MAP.get(err_lvl, ERROR_CORRECT_H)
|
|
qr = QRCode(error_correction=err_lvl)
|
|
qr = QRCode(error_correction=err_lvl)
|
|
if data is not None and isinstance(data, str):
|
|
if data is not None and isinstance(data, str):
|
|
data = data.encode('utf-8')
|
|
data = data.encode('utf-8')
|