GMime.Part¶
- Subclasses:
GMime.ApplicationPkcs7Mime
,GMime.MessagePartial
,GMime.TextPart
Methods¶
- Inherited:
- Structs:
class |
|
class |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Virtual Methods¶
- Inherited:
|
Properties¶
None
Signals¶
- Inherited:
Fields¶
- Inherited:
Name |
Type |
Access |
Description |
---|---|---|---|
content |
r |
a |
|
content_description |
r |
Content-Description string |
|
content_location |
r |
Content-Location string |
|
content_md5 |
r |
Content-MD5 string |
|
encoding |
r |
||
openpgp |
r |
||
parent_object |
r |
parent |
Class Details¶
- class GMime.Part(**kwargs)¶
- Bases:
- Abstract:
No
- Structure:
A leaf-node MIME part object.
- classmethod new()¶
- Returns:
an empty MIME Part object with a default content-type of application/octet-stream.
- Return type:
Creates a new MIME Part object with a default content-type of application/octet-stream.
- classmethod new_with_type(type, subtype)¶
- Parameters:
- Returns:
an empty MIME Part object with the specified content-type.
- Return type:
Creates a new MIME Part with a sepcified type.
- get_best_content_encoding(constraint)¶
- Parameters:
constraint (
GMime.EncodingConstraint
) – aGMime.EncodingConstraint
- Returns:
the best content encoding for the specified mime part.
- Return type:
Calculates the most efficient content encoding for the self given the constraint.
- get_content()¶
- Returns:
the data-wrapper for the mime part’s contents.
- Return type:
Gets the internal data-wrapper of the specified mime part, or
None
on error.
- get_content_description()¶
- Returns:
the content description for the specified mime part.
- Return type:
Gets the value of the Content-Description for the specified mime part if it exists or
None
otherwise.
- get_content_encoding()¶
- Returns:
the content encoding for the specified mime part.
- Return type:
Gets the content encoding of the mime part.
- get_content_id()¶
- Returns:
the content id for the specified mime part.
- Return type:
Gets the content-id of the specified mime part if it exists, or
None
otherwise.
- get_content_location()¶
- Returns:
the content location for the specified mime part.
- Return type:
Gets the value of the Content-Location header if it exists, or
None
otherwise.
- get_content_md5()¶
- Returns:
the content md5 for the specified mime part.
- Return type:
Gets the md5sum contained in the Content-Md5 header of the specified mime part if it exists, or
None
otherwise.
- get_filename()¶
- Returns:
the filename of the specified self or
None
if neither of the parameters is set. If a file name is set, the returned string will be in UTF-8.- Return type:
Gets the filename of the specificed mime part, or
None
if the self does not have the filename or name parameter set.
- get_openpgp_data()¶
- Returns:
- Return type:
Gets whether or not (and what type) of OpenPGP data is contained within the
GMime.Part
.
- is_attachment()¶
-
Determines whether or not the part is an attachment based on the value of the Content-Disposition header.
- openpgp_decrypt(flags, session_key)¶
- Parameters:
flags (
GMime.DecryptFlags
) – a set ofGMime.DecryptFlags
- Raises:
- Returns:
a
GMime.DecryptResult
on success orNone
on error.- Return type:
Decrypts the content of the self and then replaces the content with the new, decrypted, content.
- openpgp_encrypt(sign, userid, flags, recipients)¶
- Parameters:
sign (
bool
) –True
if the content should also be signed; otherwise,False
userid (
str
orNone
) – the key id (or email address) to use when signing (assuming sign isTrue
)flags (
GMime.EncryptFlags
) – a set ofGMime.EncryptFlags
recipients ([
str
]) – an array of recipient key ids and/or email addresses
- Raises:
- Returns:
- Return type:
Encrypts (and optionally signs) the content of the self and then replaces the content with the new, encrypted, content.
- openpgp_sign(userid)¶
- Parameters:
userid (
str
) – the key id (or email address) to use for signing- Raises:
- Returns:
- Return type:
Signs the content of the self and then replaces the content with the new, signed, content.
- openpgp_verify(flags)¶
- Parameters:
flags (
GMime.VerifyFlags
) – a set ofGMime.VerifyFlags
- Raises:
- Returns:
a
GMime.SignatureList
on success orNone
on error.- Return type:
Verifies the OpenPGP signature of the self and then replaces the content with the original, raw, content.
- set_content(content)¶
- Parameters:
content (
GMime.DataWrapper
) – aGMime.DataWrapper
content object
Sets the content on the mime part.
- set_content_description(description)¶
- Parameters:
description (
str
) – content description
Set the content description for the specified mime part.
- set_content_encoding(encoding)¶
- Parameters:
encoding (
GMime.ContentEncoding
) – aGMime.ContentEncoding
Set the content encoding for the specified mime part.
- set_content_id(content_id)¶
- Parameters:
content_id (
str
) – content id
Set the content id for the specified mime part.
- set_content_location(content_location)¶
- Parameters:
content_location (
str
) – content location
Set the content location for the specified mime part.
- set_content_md5(content_md5)¶
-
Set the content md5 for the specified mime part.
- set_filename(filename)¶
- Parameters:
filename (
str
) – the file name
Sets the “filename” parameter on the Content-Disposition and also sets the “name” parameter on the Content-Type.
Note: The filename string should be in UTF-8.
- set_openpgp_data(data)¶
- Parameters:
data (
GMime.OpenPGPData
) – aGMime.OpenPGPData
Sets whether or not (and what type) of OpenPGP data is contained within the
GMime.Part
.
- verify_content_md5()¶
- Returns:
True
if the md5 is valid orFalse
otherwise. Note: will returnFalse
if the mime part does not contain a Content-MD5.- Return type:
Verify the content md5 for the specified mime part.
- do_set_content(content) virtual¶
- Parameters:
content (
GMime.DataWrapper
) – aGMime.DataWrapper
content object
Sets the content on the mime part.