View source on GitHub |
Wrapper for a payload that contains encoding information.
Inherits From: expected_type
google.appengine.api.mail.EncodedPayload(
payload: bytes, charset=None, encoding=None
)
When an email is received, it is usually encoded using a certain character set, then possibly further encoded using a transfer encoding in that character set. Most of the time, it is possible to decode the encoded payload as-is; however, in the case where it is not, the encoded payload and the original encoding information must be preserved.
Args | |
---|---|
payload
|
Maps to an attribute of the same name. |
charset
|
Maps to an attribute of the same name. |
encoding
|
Maps to an attribute of the same name. |
Attributes | |
---|---|
payload
|
The original encoded payload. |
charset
|
The character set of the encoded payload. To specify that you want
to use the default character set, set this argument to None .
|
encoding
|
The transfer encoding of the encoded payload. To specify that you
do not want the content to be encoded, set this argument to None .
|
Methods
copy_to
copy_to(
mime_message
)
Copies the contents of a message to a MIME message payload.
If no content transfer encoding is specified and the character set does not equal the overall message encoding, the payload will be base64-encoded.
Args | |
---|---|
mime_message
|
Message instance that will receive the new payload. |
decode
decode()
Attempts to decode the encoded data.
This function attempts to use Python's codec library
_ to decode the
payload. All exceptions are passed back to the caller.
Returns | |
---|---|
The binary or Unicode version of the payload content. |
.. _Python's codec library: https://docs.python.org/2/library/codecs.html
to_mime_message
to_mime_message()
Converts a message to a MIME message.
Returns | |
---|---|
The MIME message instance of the payload. |
__eq__
__eq__(
other
)
Equality operator.
Args | |
---|---|
other
|
The other EncodedPayload object with which to compare. Comparison
with other object types are not implemented.
|
Returns | |
---|---|
True if the payload and encodings are equal; otherwise returns False .
|