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

Function set_bytes_content

Lib/email/contentmanager.py:232–250  ·  view source on GitHub ↗
(msg, data, maintype, subtype, cte='base64',
                     disposition=None, filename=None, cid=None,
                     params=None, headers=None)

Source from the content-addressed store, hash-verified

230
231
232def set_bytes_content(msg, data, maintype, subtype, cte='base64',
233 disposition=None, filename=None, cid=None,
234 params=None, headers=None):
235 _prepare_set(msg, maintype, subtype, headers)
236 if cte == 'base64':
237 data = _encode_base64(data, max_line_length=msg.policy.max_line_length)
238 elif cte == 'quoted-printable':
239 # XXX: quoprimime.body_encode won't encode newline characters in data,
240 # so we can't use it. This means max_line_length is ignored. Another
241 # bug to fix later. (Note: encoders.quopri is broken on line ends.)
242 data = binascii.b2a_qp(data, istext=False, header=False, quotetabs=True)
243 data = data.decode('ascii')
244 elif cte == '7bit':
245 data = data.decode('ascii')
246 elif cte in ('8bit', 'binary'):
247 data = data.decode('ascii', 'surrogateescape')
248 msg.set_payload(data)
249 msg['Content-Transfer-Encoding'] = cte
250 _finalize_set(msg, disposition, filename, cid, params)
251for typ in (bytes, bytearray, memoryview):
252 raw_data_manager.add_set_handler(typ, set_bytes_content)
253del typ

Callers

nothing calls this directly

Calls 5

_prepare_setFunction · 0.85
_finalize_setFunction · 0.85
set_payloadMethod · 0.80
_encode_base64Function · 0.70
decodeMethod · 0.45

Tested by

no test coverage detected