(self, inp)
| 1728 | return self.encode(ret) |
| 1729 | |
| 1730 | def encode(self, inp): |
| 1731 | # |
| 1732 | # Invoke binascii.b2a_base64 iteratively with |
| 1733 | # short even length buffers, strip the trailing |
| 1734 | # line feed from the result and append. "Even" |
| 1735 | # means a number that factors to both 6 and 8, |
| 1736 | # so when it gets to the end of the 8-bit input |
| 1737 | # there's no partial 6-bit output. |
| 1738 | # |
| 1739 | oup = b'' |
| 1740 | if isinstance(inp, str): |
| 1741 | inp = inp.encode('utf-8') |
| 1742 | while inp: |
| 1743 | if len(inp) > 48: |
| 1744 | t = inp[:48] |
| 1745 | inp = inp[48:] |
| 1746 | else: |
| 1747 | t = inp |
| 1748 | inp = b'' |
| 1749 | e = binascii.b2a_base64(t) |
| 1750 | if e: |
| 1751 | oup = oup + e[:-1] |
| 1752 | return oup |
| 1753 | |
| 1754 | def decode(self, inp): |
| 1755 | if not inp: |
no outgoing calls
no test coverage detected