1 .. notmuch documentation master file, created by
2 sphinx-quickstart on Tue Feb 2 10:00:47 2010.
4 .. currentmodule:: notmuch
6 Welcome to :mod:`notmuch`'s documentation
7 ===========================================
9 The :mod:`notmuch` module provides an interface to the `notmuch <http://notmuchmail.org>`_ functionality, directly interfacing to a shared notmuch library.
10 Within :mod:`notmuch`, the classes :class:`Database`, :class:`Query` provide most of the core functionality, returning :class:`Threads`, :class:`Messages` and :class:`Tags`.
12 .. moduleauthor:: Sebastian Spaeth <Sebastian@SSpaeth.de>
14 :License: This module is covered under the GNU GPL v3 (or later).
16 This page contains the main API overview of notmuch |release|.
18 Notmuch can be imported as::
24 from notmuch import Query, Database
26 db = Database('path',create=True)
27 msgs = Query(db,'from:myself').search_messages()
32 More information on specific topics can be found on the following pages:
40 :mod:`notmuch` -- The Notmuch interface
41 =================================================
43 .. automodule:: notmuch
45 :class:`Database` -- The underlying notmuch database
46 ---------------------------------------------------------------------
48 .. autoclass:: Database([path=None[, create=False[, mode=MODE.READ_ONLY]]])
50 .. automethod:: create
52 .. automethod:: open(path, status=MODE.READ_ONLY)
54 .. automethod:: get_path
56 .. automethod:: get_version
58 .. automethod:: needs_upgrade
60 .. automethod:: upgrade
62 .. automethod:: begin_atomic
64 .. automethod:: end_atomic
66 .. automethod:: get_directory
68 .. automethod:: add_message
70 .. automethod:: remove_message
72 .. automethod:: find_message
74 .. automethod:: find_message_by_filename
76 .. automethod:: get_all_tags
78 .. automethod:: create_query
80 .. attribute:: Database.MODE
82 Defines constants that are used as the mode in which to open a database.
85 Open the database in read-only mode
88 Open the database in read-write mode
90 .. autoattribute:: db_p
93 :class:`Query` -- A search query
94 -------------------------------------------------
98 .. automethod:: create
100 .. attribute:: Query.SORT
102 Defines constants that are used as the mode in which to open a database.
105 Sort by message date, oldest first.
108 Sort by message date, newest first.
111 Sort by email message ID.
114 Do not apply a special sort order (returns results in document id
117 .. automethod:: set_sort
121 Instance attribute :attr:`sort` contains the sort order (see
122 :attr:`Query.SORT`) if explicitely specified via
123 :meth:`set_sort`. By default it is set to `None`.
125 .. automethod:: search_threads
127 .. automethod:: search_messages
129 .. automethod:: count_messages
131 .. automethod:: count_threads
134 :class:`Messages` -- A bunch of messages
135 ----------------------------------------
137 .. autoclass:: Messages
139 .. automethod:: collect_tags
141 .. method:: __len__()
145 :meth:`__len__` was removed in version 0.6 as it exhausted the iterator and broke
146 list(Messages()). Use the :meth:`Query.count_messages` function or use `len(list(msgs))`.
148 :class:`Message` -- A single message
149 ----------------------------------------
151 .. autoclass:: Message
153 .. automethod:: get_message_id
155 .. automethod:: get_thread_id
157 .. automethod:: get_replies
159 .. automethod:: get_filename
161 .. automethod:: get_filenames
166 This flag is automatically set by a
167 Query.search_threads on those messages that match the
168 query. This allows us to distinguish matches from the rest
169 of the messages in that thread.
171 .. automethod:: get_flag
173 .. automethod:: set_flag
175 .. automethod:: get_date
177 .. automethod:: get_header
179 .. automethod:: get_tags
181 .. automethod:: maildir_flags_to_tags
183 .. automethod:: tags_to_maildir_flags
185 .. automethod:: remove_tag
187 .. automethod:: add_tag
189 .. automethod:: remove_all_tags
191 .. automethod:: freeze
195 .. automethod:: format_message_as_json
197 .. automethod:: format_message_as_text
199 .. automethod:: __str__
202 :class:`Tags` -- Notmuch tags
203 -----------------------------
212 :meth:`__len__` was removed in version 0.6 as it exhausted the iterator and broke
213 list(Tags()). Use :meth:`len(list(msgs))` instead if you need to know the number of
216 .. automethod:: __str__
219 :class:`Threads` -- Threads iterator
220 -----------------------------------------------------
222 .. autoclass:: Threads
224 .. automethod:: __len__
226 .. automethod:: __str__
228 :class:`Thread` -- A single thread
229 ------------------------------------
231 .. autoclass:: Thread
233 .. automethod:: get_thread_id
235 .. automethod:: get_total_messages
237 .. automethod:: get_toplevel_messages
239 .. automethod:: get_matched_messages
241 .. automethod:: get_authors
243 .. automethod:: get_subject
245 .. automethod:: get_oldest_date
247 .. automethod:: get_newest_date
249 .. automethod:: get_tags
251 .. automethod:: __str__
254 :class:`Filenames` -- An iterator over filenames
255 ------------------------------------------------
257 .. autoclass:: Filenames
259 .. automethod:: Filenames.__len__
261 .. automethod:: Filenames.as_generator
263 :class:`Directoy` -- A directory entry in the database
264 ------------------------------------------------------------------------
266 .. autoclass:: Directory
268 .. automethod:: Directory.get_child_files
270 .. automethod:: Directory.get_child_directories
272 .. automethod:: Directory.get_mtime
274 .. automethod:: Directory.set_mtime
276 .. autoattribute:: Directory.mtime
278 .. autoattribute:: Directory.path
281 The `next page <status_and_errors.html>`_ contains information on possible Status and Error values.