GMime.Parser¶
- Subclasses:
None
Methods¶
- Inherited:
- Structs:
class |
|
class |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Virtual Methods¶
- Inherited:
Properties¶
None
Signals¶
- Inherited:
Fields¶
- Inherited:
Name |
Type |
Access |
Description |
---|---|---|---|
parent_object |
r |
parent |
|
priv |
r |
private parser state |
Class Details¶
- class GMime.Parser(**kwargs)¶
- Bases:
- Abstract:
No
- Structure:
A MIME parser context.
- classmethod new()¶
- Returns:
a new parser object.
- Return type:
Creates a new parser object.
- classmethod new_with_stream(stream)¶
- Parameters:
stream (
GMime.Stream
) – raw message or part stream- Returns:
a new parser object.
- Return type:
Creates a new parser object preset to parse stream.
- construct_message(options)¶
- Parameters:
options (
GMime.ParserOptions
orNone
) – aGMime.ParserOptions
orNone
- Returns:
a MIME message or
None
on fail.- Return type:
Constructs a MIME message from self.
- construct_part(options)¶
- Parameters:
options (
GMime.ParserOptions
orNone
) – aGMime.ParserOptions
orNone
- Returns:
a MIME part based on self or
None
on fail.- Return type:
GMime.Object
orNone
Constructs a MIME part from self.
- eos()¶
-
Tests the end-of-stream indicator for self's internal stream.
- get_format()¶
- Returns:
the format that the parser is set to parse.
- Return type:
Gets the format that the parser is set to parse.
- get_headers_begin()¶
- Returns:
the offset of the beginning of the headers of the most recently parsed message or %-1 on error.
- Return type:
Gets the stream offset of the beginning of the headers of the most recently parsed message.
- get_headers_end()¶
- Returns:
the offset of the end of the headers of the most recently parsed message or %-1 on error.
- Return type:
Gets the stream offset of the end of the headers of the most recently parsed message.
- get_mbox_marker()¶
- Returns:
the mbox-style From-line of the most recently parsed message or
None
on error.- Return type:
Gets the mbox-style From-line of the most recently parsed message (gotten from
GMime.Parser.construct_message
()).
- get_mbox_marker_offset()¶
- Returns:
the offset of the most recently parsed mbox-style From-line or %-1 on error.
- Return type:
Gets the offset of the most recently parsed mbox-style From-line (gotten from
GMime.Parser.construct_message
()).
- get_persist_stream()¶
- Returns:
True
if the self will leave the content on disk orFalse
if it will load the content into memory.- Return type:
Gets whether or not the underlying stream is persistent.
- get_respect_content_length()¶
- Returns:
whether or not self is set to use Content-Length for determining the offset of the end of the message.
- Return type:
Gets whether or not self is set to use Content-Length for determining the offset of the end of the message.
- init_with_stream(stream)¶
- Parameters:
stream (
GMime.Stream
) – raw message or part stream
Initializes self to use stream.
WARNING: Initializing a parser with a stream is comparable to selling your soul (stream) to the devil (self). You are basically giving the parser complete control of the stream, this means that you had better not touch the stream so long as the parser is still using it. This means no reading, writing, seeking, or resetting of the stream. Anything that will/could change the current stream’s offset is PROHIBITED.
It is also recommended that you not use
GMime.Stream.tell
() because it will not necessarily give you the current self offset since self handles its own internal read-ahead buffer. Instead, it is recommended that you useGMime.Parser.tell
() if you have a reason to need the current offset of the self.
- set_format(format)¶
- Parameters:
format (
GMime.Format
) – aGMime.Format
Sets the format that the parser should expect the stream to be in.
- set_persist_stream(persist)¶
- Parameters:
persist (
bool
) – persist attribute
Sets whether or not the self's underlying stream is persistent.
If persist is
True
, the self will attempt to construct messages/parts whose content will remain on disk rather than being loaded into memory so as to reduce memory usage. This is the default.If persist is
False
, the self will always load message content into memory.Note: This attribute only serves as a hint to the self. If the underlying stream does not support seeking, then this attribute will be ignored.
By default, this feature is enabled if the underlying stream is seekable.
- set_respect_content_length(respect_content_length)¶
- Parameters:
respect_content_length (
bool
) –True
if the parser should use Content-Length headers orFalse
otherwise.
Sets whether or not self should respect Content-Length headers when deciding where to look for the start of the next message. Only used when the parser is also set to scan for From-lines.
Most notably useful when parsing broken Solaris mbox files (See http://www.jwz.org/doc/content-length.html for details).
By default, this feature is disabled.