MCPcopy Index your code
hub / github.com/RustPython/RustPython / encode

Method encode

Lib/imaplib.py:1731–1753  ·  view source on GitHub ↗
(self, inp)

Source from the content-addressed store, hash-verified

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

Callers 3

processMethod · 0.95
_CRAM_MD5_AUTHMethod · 0.45
imaplib.pyFile · 0.45

Calls 2

isinstanceFunction · 0.85
lenFunction · 0.85

Tested by

no test coverage detected