Thread – A single thread

class Thread(thread_p, parent=None)

Represents a single message thread.

Parameters:
  • thread_p – A pointer to an internal notmuch_thread_t Structure. These are not publicly exposed, so a user will almost never instantiate a Thread object herself. They are usually handed back as a result, e.g. when iterating through Threads. thread_p must be valid, we will raise an NullPointerError if it is None.
  • parent – A ‘parent’ object is passed which this message is derived from. We save a reference to it, so we can automatically delete the parent object once all derived objects are dead.
get_thread_id()

Get the thread ID of ‘thread’

The returned string belongs to ‘thread’ and will only be valid for as long as the thread is valid.

Returns:String with a message ID
Raises:NotInitializedError if the thread is not initialized.
get_total_messages()

Get the total number of messages in ‘thread’

Returns:The number of all messages in the database belonging to this thread. Contrast with get_matched_messages().
Raises:NotInitializedError if the thread is not initialized.
get_toplevel_messages()
Returns a Messages iterator for the top-level messages in

‘thread’

This iterator will not necessarily iterate over all of the messages in the thread. It will only iterate over the messages in the thread which are not replies to other messages in the thread.

Returns:Messages
Raises:NotInitializedError if query is not initialized
Raises:NullPointerError if search_messages failed
get_matched_messages()

Returns the number of messages in ‘thread’ that matched the query

Returns:The number of all messages belonging to this thread that matched the Query`from which this thread was created. Contrast with :meth:`get_total_messages.
Raises:NotInitializedError if the thread is not initialized.
get_authors()

Returns the authors of ‘thread’

The returned string is a comma-separated list of the names of the authors of mail messages in the query results that belong to this thread.

The returned string belongs to ‘thread’ and will only be valid for as long as this Thread() is not deleted.

get_subject()

Returns the Subject of ‘thread’

The returned string belongs to ‘thread’ and will only be valid for as long as this Thread() is not deleted.

get_oldest_date()

Returns time_t of the oldest message date

Returns:A time_t timestamp.
Return type:c_unit64
Raises:NotInitializedError if the message is not initialized.
get_newest_date()

Returns time_t of the newest message date

Returns:A time_t timestamp.
Return type:c_unit64
Raises:NotInitializedError if the message is not initialized.
get_tags()

Returns the message tags

In the Notmuch database, tags are stored on individual messages, not on threads. So the tags returned here will be all tags of the messages which matched the search and which belong to this thread.

The Tags object is owned by the thread and as such, will only be valid for as long as this Thread is valid (e.g. until the query from which it derived is explicitly deleted).

Returns:A Tags iterator.
Raises:NotInitializedError if query is not initialized
Raises:NullPointerError if search_messages failed
__str__()

Return str(self).