GMime.Part

g GMime.Object GMime.Object GMime.Part GMime.Part GMime.Object->GMime.Part GObject.Object GObject.Object GObject.Object->GMime.Object

Subclasses:

GMime.ApplicationPkcs7Mime, GMime.MessagePartial, GMime.TextPart

Methods

Inherited:

GMime.Object (28), GObject.Object (37)

Structs:

GObject.ObjectClass (5)

class

new ()

class

new_with_type (type, subtype)

get_best_content_encoding (constraint)

get_content ()

get_content_description ()

get_content_encoding ()

get_content_id ()

get_content_location ()

get_content_md5 ()

get_filename ()

get_openpgp_data ()

is_attachment ()

openpgp_decrypt (flags, session_key)

openpgp_encrypt (sign, userid, flags, recipients)

openpgp_sign (userid)

openpgp_verify (flags)

set_content (content)

set_content_description (description)

set_content_encoding (encoding)

set_content_id (content_id)

set_content_location (content_location)

set_content_md5 (content_md5)

set_filename (filename)

set_openpgp_data (data)

verify_content_md5 ()

Virtual Methods

Inherited:

GMime.Object (8), GObject.Object (7)

do_set_content (content)

Properties

None

Signals

Inherited:

GObject.Object (1)

Fields

Inherited:

GObject.Object (1)

Name

Type

Access

Description

content

GMime.DataWrapper

r

a GMime.DataWrapper representing the MIME part’s content

content_description

str

r

Content-Description string

content_location

str

r

Content-Location string

content_md5

str

r

Content-MD5 string

encoding

GMime.ContentEncoding

r

a GMime.ContentEncoding

openpgp

GMime.OpenPGPData

r

a GMime.OpenPGPData

parent_object

GMime.Object

r

parent GMime.Object

Class Details

class GMime.Part(**kwargs)
Bases:

GMime.Object

Abstract:

No

Structure:

GMime.PartClass

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:

GMime.Part

Creates a new MIME Part object with a default content-type of application/octet-stream.

classmethod new_with_type(type, subtype)
Parameters:
  • type (str) – content-type string

  • subtype (str) – content-subtype string

Returns:

an empty MIME Part object with the specified content-type.

Return type:

GMime.Part

Creates a new MIME Part with a sepcified type.

get_best_content_encoding(constraint)
Parameters:

constraint (GMime.EncodingConstraint) – a GMime.EncodingConstraint

Returns:

the best content encoding for the specified mime part.

Return type:

GMime.ContentEncoding

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:

GMime.DataWrapper

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:

str

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:

GMime.ContentEncoding

Gets the content encoding of the mime part.

get_content_id()
Returns:

the content id for the specified mime part.

Return type:

str

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:

str

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:

str

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:

str

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:

a GMime.OpenPGPData.

Return type:

GMime.OpenPGPData

Gets whether or not (and what type) of OpenPGP data is contained within the GMime.Part.

is_attachment()
Returns:

True if the part is an attachment, otherwise False.

Return type:

bool

Determines whether or not the part is an attachment based on the value of the Content-Disposition header.

openpgp_decrypt(flags, session_key)
Parameters:
Raises:

GLib.Error

Returns:

a GMime.DecryptResult on success or None on error.

Return type:

GMime.DecryptResult or None

Decrypts the content of the self and then replaces the content with the new, decrypted, content.

openpgp_encrypt(sign, userid, flags, recipients)
Parameters:
Raises:

GLib.Error

Returns:

True on success or False on error.

Return type:

bool

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:

GLib.Error

Returns:

True on success or False on error.

Return type:

bool

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 of GMime.VerifyFlags

Raises:

GLib.Error

Returns:

a GMime.SignatureList on success or None on error.

Return type:

GMime.SignatureList or None

Verifies the OpenPGP signature of the self and then replaces the content with the original, raw, content.

set_content(content)
Parameters:

content (GMime.DataWrapper) – a GMime.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) – a GMime.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)
Parameters:

content_md5 (str) – content md5 or None to generate the md5 digest.

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) – a GMime.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 or False otherwise. Note: will return False if the mime part does not contain a Content-MD5.

Return type:

bool

Verify the content md5 for the specified mime part.

do_set_content(content) virtual
Parameters:

content (GMime.DataWrapper) – a GMime.DataWrapper content object

Sets the content on the mime part.