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