(self, buffer)
| 442 | return len(self.data) |
| 443 | |
| 444 | def write(self, buffer): |
| 445 | if self.mode == MODE_NUMBER: |
| 446 | for i in range(0, len(self.data), 3): |
| 447 | chars = self.data[i : i + 3] |
| 448 | bit_length = NUMBER_LENGTH[len(chars)] |
| 449 | buffer.put(int(chars), bit_length) |
| 450 | elif self.mode == MODE_ALPHA_NUM: |
| 451 | for i in range(0, len(self.data), 2): |
| 452 | chars = self.data[i : i + 2] |
| 453 | if len(chars) > 1: |
| 454 | buffer.put( |
| 455 | ALPHA_NUM.find(chars[0]) * 45 + ALPHA_NUM.find(chars[1]), 11 |
| 456 | ) |
| 457 | else: |
| 458 | buffer.put(ALPHA_NUM.find(chars), 6) |
| 459 | else: |
| 460 | # Iterating a bytestring in Python 3 returns an integer, |
| 461 | # no need to ord(). |
| 462 | data = self.data |
| 463 | for c in data: |
| 464 | buffer.put(c, 8) |
| 465 | |
| 466 | def __repr__(self): |
| 467 | return repr(self.data) |
no test coverage detected