GMime.HeaderList

g GMime.HeaderList GMime.HeaderList GObject.Object GObject.Object GObject.Object->GMime.HeaderList

Subclasses:

None

Methods

Inherited:

GObject.Object (37)

Structs:

GObject.ObjectClass (5)

class

new (options)

append (name, value, charset)

clear ()

contains (name)

get_count ()

get_header (name)

get_header_at (index)

prepend (name, value, charset)

remove (name)

remove_at (index)

set (name, value, charset)

to_string (options)

write_to_stream (options, stream)

Virtual Methods

Inherited:

GObject.Object (7)

Properties

None

Signals

Inherited:

GObject.Object (1)

Fields

Inherited:

GObject.Object (1)

Name

Type

Access

Description

array

[object]

r

changed

object

r

hash

{object: object}

r

options

GMime.ParserOptions

r

parent_object

GObject.Object

r

Class Details

class GMime.HeaderList(**kwargs)
Bases:

GObject.Object

Abstract:

No

Structure:

GMime.HeaderListClass

A list of message or mime-part headers.

classmethod new(options)
Parameters:

options (GMime.ParserOptions or None) – a GMime.ParserOptions or None

Returns:

a new header list object.

Return type:

GMime.HeaderList

Creates a new GMime.HeaderList object.

append(name, value, charset)
Parameters:
  • name (str) – header name

  • value (str) – header value

  • charset (str) – a charset

Appends a header. If value is None, a space will be set aside for it (useful for setting the order of headers before values can be obtained for them) otherwise the header will be unset.

clear()

Removes all of the headers from the GMime.HeaderList.

contains(name)
Parameters:

name (str) – header name

Returns:

True if the specified header exists or False otherwise.

Return type:

bool

Checks whether or not a header exists.

get_count()
Returns:

the number of headers in the header list.

Return type:

int

Gets the number of headers contained within the header list.

get_header(name)
Parameters:

name (str) – header name

Returns:

a GMime.Header for the specified name.

Return type:

GMime.Header

Gets the first header with the specified name.

get_header_at(index)
Parameters:

index (int) – the 0-based index of the header

Returns:

the header at position index.

Return type:

GMime.Header

Gets the header at the specified index within the list.

prepend(name, value, charset)
Parameters:
  • name (str) – header name

  • value (str) – header value

  • charset (str) – a charset

Prepends a header. If value is None, a space will be set aside for it (useful for setting the order of headers before values can be obtained for them) otherwise the header will be unset.

remove(name)
Parameters:

name (str) – header name

Returns:

True if the header was successfully removed or False if the specified header could not be found.

Return type:

bool

Remove the first instance of the specified header.

remove_at(index)
Parameters:

index (int) – the 0-based index of the header to remove

Removes the header at the specified index from self.

set(name, value, charset)
Parameters:
  • name (str) – header name

  • value (str) – header value

  • charset (str) – a charset

Set the value of the specified header. If value is None and the header, name, had not been previously set, a space will be set aside for it (useful for setting the order of headers before values can be obtained for them) otherwise the header will be unset.

Note: If there are multiple headers with the specified field name, the first instance of the header will be replaced and further instances will be removed.

to_string(options)
Parameters:

options (GMime.FormatOptions or None) – a GMime.FormatOptions or None

Returns:

a string containing the header block.

Return type:

str

Allocates a string buffer containing the raw rfc822 headers contained in self.

write_to_stream(options, stream)
Parameters:
Returns:

the number of bytes written or %-1 on fail.

Return type:

int

Write the headers to a stream.