aboutsummaryrefslogtreecommitdiff
path: root/bindings/python/docs/source/index.rst
blob: f7d3d6058e3b058a171da31a365d57b2b02abd0f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
.. notmuch documentation master file, created by
   sphinx-quickstart on Tue Feb  2 10:00:47 2010.

.. currentmodule:: notmuch

Welcome to :mod:`notmuch`'s documentation
===========================================

The :mod:`notmuch` module provides an interface to the `notmuch <http://notmuchmail.org>`_ functionality, directly interfacing to a shared notmuch library.
Within :mod:`notmuch`, the classes :class:`Database`, :class:`Query` provide most of the core functionality, returning :class:`Threads`, :class:`Messages` and :class:`Tags`.

.. moduleauthor:: Sebastian Spaeth <Sebastian@SSpaeth.de>

:License: This module is covered under the GNU GPL v3 (or later).

This page contains the main API overview of notmuch |release|. 

Notmuch can be imported as::

 import notmuch

or::

 from notmuch import Query, Database

 db = Database('path',create=True)
 msgs = Query(db,'from:myself').search_messages()

 for msg in msgs:
    print (msg)

More information on specific topics can be found on the following pages:

.. toctree::
   :maxdepth: 1

   status_and_errors
   notmuch   

:mod:`notmuch` -- The Notmuch interface
=================================================

.. automodule:: notmuch

:class:`notmuch.Database` -- The underlying notmuch database
---------------------------------------------------------------------

.. autoclass:: notmuch.Database([path=None[, create=False[, mode=MODE.READ_ONLY]]])

   .. automethod:: create

   .. automethod:: open(path, status=MODE.READ_ONLY)

   .. automethod:: get_path

   .. automethod:: get_version

   .. automethod:: needs_upgrade

   .. automethod:: upgrade

   .. automethod:: begin_atomic

   .. automethod:: end_atomic

   .. automethod:: get_directory

   .. automethod:: add_message

   .. automethod:: remove_message

   .. automethod:: find_message

   .. automethod:: find_message_by_filename

   .. automethod:: get_all_tags

   .. automethod:: create_query

   .. attribute:: Database.MODE

     Defines constants that are used as the mode in which to open a database.

     MODE.READ_ONLY
       Open the database in read-only mode

     MODE.READ_WRITE
       Open the database in read-write mode

   .. autoattribute:: db_p


:class:`notmuch.Query` -- A search query
-------------------------------------------------

.. autoclass:: notmuch.Query

   .. automethod:: create

   .. attribute:: Query.SORT

     Defines constants that are used as the mode in which to open a database.

     SORT.OLDEST_FIRST
       Sort by message date, oldest first.

     SORT.NEWEST_FIRST
       Sort by message date, newest first.

     SORT.MESSAGE_ID
       Sort by email message ID.

     SORT.UNSORTED
       Do not apply a special sort order (returns results in document id     
       order). 

   .. automethod:: set_sort

   .. attribute::  sort

      Instance attribute :attr:`sort` contains the sort order (see
      :attr:`Query.SORT`) if explicitely specified via
      :meth:`set_sort`. By default it is set to `None`.

   .. automethod:: search_threads

   .. automethod:: search_messages

   .. automethod:: count_messages


:class:`Messages` -- A bunch of messages
----------------------------------------

.. autoclass:: Messages

   .. automethod:: collect_tags

   .. method:: __len__()

   .. warning::
   
      :meth:`__len__` was removed in version 0.6 as it exhausted the iterator and broke
      list(Messages()). Use the :meth:`Query.count_messages` function or use `len(list(msgs))`.

:class:`Message` -- A single message
----------------------------------------

.. autoclass:: Message

   .. automethod:: get_message_id

   .. automethod:: get_thread_id

   .. automethod:: get_replies

   .. automethod:: get_filename

   .. automethod:: get_filenames

   .. attribute:: FLAG

        FLAG.MATCH 
          This flag is automatically set by a
	  Query.search_threads on those messages that match the
	  query. This allows us to distinguish matches from the rest
	  of the messages in that thread.

   .. automethod:: get_flag

   .. automethod:: set_flag
   
   .. automethod:: get_date

   .. automethod:: get_header

   .. automethod:: get_tags

   .. automethod:: maildir_flags_to_tags

   .. automethod:: tags_to_maildir_flags

   .. automethod:: remove_tag

   .. automethod:: add_tag

   .. automethod:: remove_all_tags

   .. automethod:: freeze

   .. automethod:: thaw

   .. automethod:: format_message_as_json

   .. automethod:: format_message_as_text

   .. automethod:: __str__


:class:`Tags` -- Notmuch tags
-----------------------------

.. autoclass:: Tags
   :members:

   .. method:: __len__

       .. warning::

            :meth:`__len__` was removed in version 0.6 as it exhausted the iterator and broke
            list(Tags()). Use :meth:`len(list(msgs))` instead if you need to know the number of
            tags.

   .. automethod:: __str__


:class:`notmuch.Threads` -- Threads iterator
-----------------------------------------------------

.. autoclass:: notmuch.Threads

   .. automethod:: __len__

   .. automethod:: __str__

:class:`Thread` -- A single thread
------------------------------------

.. autoclass:: Thread

  .. automethod:: get_thread_id

  .. automethod:: get_total_messages

  .. automethod:: get_toplevel_messages

  .. automethod:: get_matched_messages

  .. automethod:: get_authors

  .. automethod:: get_subject

  .. automethod:: get_oldest_date

  .. automethod:: get_newest_date

  .. automethod:: get_tags

  .. automethod:: __str__


:class:`Filenames` -- An iterator over filenames
------------------------------------------------

.. autoclass:: notmuch.database.Filenames

   .. automethod:: notmuch.database.Filenames.__len__

:class:`notmuch.database.Directoy` -- A directory entry in the database
------------------------------------------------------------------------

.. autoclass:: notmuch.database.Directory

   .. automethod:: notmuch.database.Directory.get_child_files

   .. automethod:: notmuch.database.Directory.get_child_directories

   .. automethod:: notmuch.database.Directory.get_mtime

   .. automethod:: notmuch.database.Directory.set_mtime

   .. autoattribute:: notmuch.database.Directory.mtime

   .. autoattribute:: notmuch.database.Directory.path


The `next page <status_and_errors.html>`_ contains information on possible Status and Error values.

Indices and tables
==================

* :ref:`genindex`
* :ref:`search`