aboutsummaryrefslogtreecommitdiff
path: root/bindings/python
diff options
context:
space:
mode:
authorDaniel Kahn Gillmor <dkg@fifthhorseman.net>2017-08-17 19:14:25 -0400
committerDavid Bremner <david@tethera.net>2017-08-23 07:38:37 -0300
commitb10ce6bc23002d48916b1b2f375480e7540e3164 (patch)
tree2c403d73fd6373bb943d08aa8a2303afb73dff16 /bindings/python
parent09fa51303c6ba5adfd2431d87663523aa799288b (diff)
database: add n_d_index_file (deprecates n_d_add_message)
We need a way to pass parameters to the indexing functionality on the first index, not just on reindexing. The obvious place is in notmuch_database_add_message. But since modifying the argument list would break both API and ABI, we needed a new name. I considered notmuch_database_add_message_with_params(), but the functionality we're talking about doesn't always add a message. It tries to index a specific file, possibly adding a message, but possibly doing other things, like adding terms to an existing message, or failing to deal with message objects entirely (e.g. because the file didn't contain a message). So i chose the function name notmuch_database_index_file. I confess i'm a little concerned about confusing future notmuch developers with the new name, since we already have a private _notmuch_message_index_file function, and the two do rather different things. But i think the added clarity for people linking against the future libnotmuch and the capacity for using index parameters makes this a worthwhile tradeoff. (that said, if anyone has another name that they strongly prefer, i'd be happy to go with it) This changeset also adjusts the tests so that we test whether the new, preferred function returns bad values (since the deprecated function just calls the new one). We can keep the deprecated n_d_add_message function around as long as we like, but at the next place where we're forced to break API or ABI we can probably choose to drop the name relatively safely. NOTE: there is probably more cleanup to do in the ruby and go bindings to complete the deprecation directly. I don't know those languages well enough to attempt a fix; i don't know how to test them; and i don't know the culture around those languages about API additions or deprecations.
Diffstat (limited to 'bindings/python')
-rw-r--r--bindings/python/docs/source/database.rst2
-rw-r--r--bindings/python/notmuch/database.py18
-rw-r--r--bindings/python/notmuch/directory.py2
-rw-r--r--bindings/python/notmuch/message.py2
4 files changed, 15 insertions, 9 deletions
diff --git a/bindings/python/docs/source/database.rst b/bindings/python/docs/source/database.rst
index 5f1cdc14..079dc754 100644
--- a/bindings/python/docs/source/database.rst
+++ b/bindings/python/docs/source/database.rst
@@ -25,7 +25,7 @@
.. automethod:: get_directory
- .. automethod:: add_message
+ .. automethod:: index_file
.. automethod:: remove_message
diff --git a/bindings/python/notmuch/database.py b/bindings/python/notmuch/database.py
index 8f918069..a2c025eb 100644
--- a/bindings/python/notmuch/database.py
+++ b/bindings/python/notmuch/database.py
@@ -285,7 +285,7 @@ class Database(object):
"""Does this database need to be upgraded before writing to it?
If this function returns `True` then no functions that modify the
- database (:meth:`add_message`,
+ database (:meth:`index_file`,
:meth:`Message.add_tag`, :meth:`Directory.set_mtime`,
etc.) will work unless :meth:`upgrade` is called successfully first.
@@ -399,12 +399,13 @@ class Database(object):
# return the Directory, init it with the absolute path
return Directory(abs_dirpath, dir_p, self)
- _add_message = nmlib.notmuch_database_add_message
- _add_message.argtypes = [NotmuchDatabaseP, c_char_p,
+ _index_file = nmlib.notmuch_database_index_file
+ _index_file.argtypes = [NotmuchDatabaseP, c_char_p,
+ c_void_p,
POINTER(NotmuchMessageP)]
- _add_message.restype = c_uint
+ _index_file.restype = c_uint
- def add_message(self, filename, sync_maildir_flags=False):
+ def index_file(self, filename, sync_maildir_flags=False):
"""Adds a new message to the database
:param filename: should be a path relative to the path of the
@@ -455,7 +456,7 @@ class Database(object):
"""
self._assert_db_is_initialized()
msg_p = NotmuchMessageP()
- status = self._add_message(self._db, _str(filename), byref(msg_p))
+ status = self._index_file(self._db, _str(filename), c_void_p(None), byref(msg_p))
if not status in [STATUS.SUCCESS, STATUS.DUPLICATE_MESSAGE_ID]:
raise NotmuchError(status)
@@ -467,6 +468,11 @@ class Database(object):
msg.maildir_flags_to_tags()
return (msg, status)
+ def add_message(self, filename, sync_maildir_flags=False):
+ """Deprecated alias for :meth:`index_file`
+ """
+ self.index_file(self, filename, sync_maildir_flags=sync_maildir_flags)
+
_remove_message = nmlib.notmuch_database_remove_message
_remove_message.argtypes = [NotmuchDatabaseP, c_char_p]
_remove_message.restype = c_uint
diff --git a/bindings/python/notmuch/directory.py b/bindings/python/notmuch/directory.py
index 7f86b1ac..b30c9e35 100644
--- a/bindings/python/notmuch/directory.py
+++ b/bindings/python/notmuch/directory.py
@@ -93,7 +93,7 @@ class Directory(object):
* Read the mtime of a directory from the filesystem
- * Call :meth:`Database.add_message` for all mail files in
+ * Call :meth:`Database.index_file` for all mail files in
the directory
* Call notmuch_directory_set_mtime with the mtime read from the
diff --git a/bindings/python/notmuch/message.py b/bindings/python/notmuch/message.py
index fc177eb2..cce377d0 100644
--- a/bindings/python/notmuch/message.py
+++ b/bindings/python/notmuch/message.py
@@ -566,7 +566,7 @@ class Message(Python3StringMixIn):
logical OR operator.)
As a convenience, you can set the sync_maildir_flags parameter in
- :meth:`Database.add_message` to implicitly call this.
+ :meth:`Database.index_file` to implicitly call this.
:returns: a :class:`STATUS`. In short, you want to see
notmuch.STATUS.SUCCESS here. See there for details."""