If ``mode`` isn't provided, the most compact QR data type possible is chosen.
(self, data, mode=None, check_data=True)
| 420 | """ |
| 421 | |
| 422 | def __init__(self, data, mode=None, check_data=True): |
| 423 | """ |
| 424 | If ``mode`` isn't provided, the most compact QR data type possible is |
| 425 | chosen. |
| 426 | """ |
| 427 | if check_data: |
| 428 | data = to_bytestring(data) |
| 429 | |
| 430 | if mode is None: |
| 431 | self.mode = optimal_mode(data) |
| 432 | else: |
| 433 | self.mode = mode |
| 434 | if mode not in (MODE_NUMBER, MODE_ALPHA_NUM, MODE_8BIT_BYTE): |
| 435 | raise TypeError(f"Invalid mode ({mode})") # pragma: no cover |
| 436 | if check_data and mode < optimal_mode(data): # pragma: no cover |
| 437 | raise ValueError(f"Provided data can not be represented in mode {mode}") |
| 438 | |
| 439 | self.data = data |
| 440 | |
| 441 | def __len__(self): |
| 442 | return len(self.data) |
nothing calls this directly
no test coverage detected