MCPcopy Index your code
hub / github.com/python/cpython / set_message_content

Function set_message_content

Lib/email/contentmanager.py:186–215  ·  view source on GitHub ↗
(msg, message, subtype="rfc822", cte=None,
                       disposition=None, filename=None, cid=None,
                       params=None, headers=None)

Source from the content-addressed store, hash-verified

184
185
186def set_message_content(msg, message, subtype="rfc822", cte=None,
187 disposition=None, filename=None, cid=None,
188 params=None, headers=None):
189 if subtype == 'partial':
190 raise ValueError("message/partial is not supported for Message objects")
191 if subtype == 'rfc822':
192 if cte not in (None, '7bit', '8bit', 'binary'):
193 # http://tools.ietf.org/html/rfc2046#section-5.2.1 mandate.
194 raise ValueError(
195 "message/rfc822 parts do not support cte={}".format(cte))
196 # 8bit will get coerced on serialization if policy.cte_type='7bit'. We
197 # may end up claiming 8bit when it isn't needed, but the only negative
198 # result of that should be a gateway that needs to coerce to 7bit
199 # having to look through the whole embedded message to discover whether
200 # or not it actually has to do anything.
201 cte = '8bit' if cte is None else cte
202 elif subtype == 'external-body':
203 if cte not in (None, '7bit'):
204 # http://tools.ietf.org/html/rfc2046#section-5.2.3 mandate.
205 raise ValueError(
206 "message/external-body parts do not support cte={}".format(cte))
207 cte = '7bit'
208 elif cte is None:
209 # http://tools.ietf.org/html/rfc2046#section-5.2.4 says all future
210 # subtypes should be restricted to 7bit, so assume that.
211 cte = '7bit'
212 _prepare_set(msg, 'message', subtype, headers)
213 msg.set_payload([message])
214 msg['Content-Transfer-Encoding'] = cte
215 _finalize_set(msg, disposition, filename, cid, params)
216raw_data_manager.add_set_handler(email.message.Message, set_message_content)
217
218

Callers

nothing calls this directly

Calls 4

_prepare_setFunction · 0.85
_finalize_setFunction · 0.85
set_payloadMethod · 0.80
formatMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…