Commit graph

86 commits

Author SHA1 Message Date
Jonas Bernoulli
6c84dee531 Fix typos 2020-08-09 21:14:36 -03:00
Doan Tran Cong Danh
816633e636 python: support relative path in default database
From notmuch 0.28, notmuch support relative database path in
notmuch-config(1), but python binding haven't taught this yet.

afew denied to work with a perfectly fine notmuch-config due to this.
2019-04-24 07:10:53 -03:00
Daniel Kahn Gillmor
54982e520c fix typos 2018-01-04 20:35:58 -04:00
Daniel Kahn Gillmor
6aec7a76b9 python: add decrypt_policy argument to Database.index_file()
We adopt a pythonic idiom here with an optional argument, rather than
exposing the user to the C indexopts object directly.

This now includes a simple test to ensure that the decrypt_policy
argument works as expected.
2017-12-24 09:47:35 -04:00
l-m-h@web.de
3444c731d2 python: Rename get_config_list to get_configs
The old name has a bit of a feeling of hungarian notation.  Also many
generators in the core are named with the suffix "s" to indicate
iterables: dict.items, dict.keys for example.
2017-12-19 06:42:11 -04:00
l-m-h@web.de
e745857c4a python: turn get_config_list into a generator
This mimics the behaviour of the underlying C function more closely as
it also does not store all values in memory.
2017-12-19 06:40:47 -04:00
l-m-h@web.de
c536de3afb python: add default arg to get_config_list
It makes the function a little more intuitive to use and does not
diverge much from the original function signature.

Also an example is added to the docstring.
2017-12-19 06:39:32 -04:00
l-m-h@web.de
6c6b0f13ff python: add bindings to access config
The C functions notmuch_database_get_config,
notmuch_database_get_config_list and notmuch_database_set_config are
part of the official C bindings.  So there should also be some python
bindings for them.

Also they are the only way to access the named queries introduced in
b9bf3f44.

The interface of the python functions is designed to be close to the C
functions.
2017-12-19 06:36:30 -04:00
Gaute Hope
227ecf4949 python: deprecated add_message calls index_file correctly and returns result
The deprecated Database.add_message now calls the new index_file with
correct number of arguments (without an extra `self`), and returns the
tuple from index_file - as it used to do before.

This change also adds a DeprecationWarning to the function.
2017-09-12 15:21:40 -03:00
Daniel Kahn Gillmor
b10ce6bc23 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.
2017-08-23 07:38:37 -03:00
Gaute Hope
a39a1ee152 bindings/python: add bindings for notmuch_database_get_revision
Database.get_revision () returns a tuple with the current database
revision and the UUID string representing the database.
2017-03-09 10:20:50 -04:00
Daniel Kahn Gillmor
6a833a6e83 Use https instead of http where possible
Many of the external links found in the notmuch source can be resolved
using https instead of http.  This changeset addresses as many as i
could find, without touching the e-mail corpus or expected outputs
found in tests.
2016-06-05 08:32:17 -03:00
Daniel Kahn Gillmor
fa0bc2ef91 notmuch.Database.remove_message should raise exception on failure
The notmuch python bindings document that database.remove_message
should raise an exception when the message removal fails, but they
don't actually do it.
2016-02-11 20:41:54 +01:00
Justus Winter
a5c1536d9a python: cleanup imports
Drop unused imports, and avoid warning about unused imports when we
import something on behalf of another module.

Signed-off-by: Justus Winter <4winter@informatik.uni-hamburg.de>
2016-01-08 13:58:33 +01:00
Daniel Kahn Gillmor
8881a61fe7 python: add notmuch.Database.status_string()
This gives some additional access to debugging information when using
the python bindings.

Signed-off-by: Justus Winter <4winter@informatik.uni-hamburg.de>
2015-12-11 17:05:32 +01:00
Peter Wang
ea90d8e043 python: handle return status of database close and destroy
Throw an exception if notmuch_database_close or notmuch_database_destroy
fail.
2014-09-16 20:16:52 +02:00
Justus Winter
c8cb2beda7 python: fix the creation of notmuch databases
Remove the superfluous mode argument given to notmuch_database_create
fixing the creation of notmuch databases using python code.

Signed-off-by: Justus Winter <4winter@informatik.uni-hamburg.de>
2013-01-23 18:12:04 +01:00
Justus Winter
8728340644 python: remove Database.db_p
The function has been marked as deprecated in 0.14 and is now removed.

Signed-off-by: Justus Winter <4winter@informatik.uni-hamburg.de>
2012-12-21 10:56:06 +01:00
David Bremner
6d44c5af65 Merge branch 'release'
merge 0.13.1 bugfix patches back to master, fixes for emacs reply and
spurious directory document creation.
2012-05-23 22:48:16 -03:00
Austin Clements
54508eb78d python: Remove find_message_by_filename workaround
Now that notmuch_database_find_message_by_filename works on read-only
databases, remove the workaround that disabled it on read-write
databases.

This also adds a regression test for find_message_by_filename.
2012-05-23 22:32:02 -03:00
Austin Clements
f1f1e39639 python: Update Database.get_directory documentation
notmuch_database_get_directory no longer returns an error for
read-only databases, so remove ReadOnlyDatabaseError from the list of
get_directory exceptions.
2012-05-23 22:31:36 -03:00
Justus Winter
892bb1ee6d python: deprecate Database.db_p
Signed-off-by: Justus Winter <4winter@informatik.uni-hamburg.de>
2012-05-17 19:09:25 +02:00
Justus Winter
8e3faa7f18 python: add a file abstracting away differences between python 2 and 3
Signed-off-by: Justus Winter <4winter@informatik.uni-hamburg.de>
2012-05-17 18:23:11 +02:00
Justus Winter
8dc8495010 python: Fix the remaining broken NULL pointer tests
Signed-off-by: Justus Winter <4winter@informatik.uni-hamburg.de>
2012-05-17 17:15:49 +02:00
Justus Winter
05c3e83bd2 python: use relative imports
Signed-off-by: Justus Winter <4winter@informatik.uni-hamburg.de>
2012-05-17 16:58:53 +02:00
Austin Clements
ed4f73a080 python: Update for changes to notmuch_database_get_directory
notmuch_database_get_directory now returns
NOTMUCH_STATUS_READ_ONLY_DATABASE on its own (rather than crashing) so
the workaround in Database.get_directory is no longer necessary.
2012-05-15 08:58:47 -03:00
Austin Clements
0a357fe410 python: Update Python bindings for new notmuch_database_{open, create} signatures 2012-05-05 10:13:57 -03:00
Justus Winter
fcfb619b44 python: remove a note stating wrong things about the memory management
Signed-off-by: Justus Winter <4winter@informatik.uni-hamburg.de>
2012-04-30 19:51:16 +02:00
Justus Winter
ca1e232e5f python: document the Database.close function
Put a prominent warning into the docstring of Database.close, make the
function show up in the sphinx doc and refer to the warning in the
paragraph mentioning the context manager protocol.

Signed-off-by: Justus Winter <4winter@informatik.uni-hamburg.de>
2012-04-30 19:48:45 +02:00
Justus Winter
162687a99e python: fix NULL pointer tests
Fix the NULL pointer tests in the destructors of all classes and
Database.create.

Signed-off-by: Justus Winter <4winter@informatik.uni-hamburg.de>
2012-04-30 19:24:34 +02:00
Justus Winter
1f08664a6b python: strip superfluous single quote from copyright notices
Signed-off-by: Justus Winter <4winter@informatik.uni-hamburg.de>
2012-04-29 16:33:06 +02:00
Justus Winter
7bfc4bf501 python: wrap and use notmuch_database_destroy as destructor
Adapt the python bindings to the notmuch_database_close split.

Signed-off-by: Justus Winter <4winter@informatik.uni-hamburg.de>
2012-04-28 09:31:12 -03:00
Justus Winter
a7561cc20b python: move the exception classes into error.py
Signed-off-by: Justus Winter <4winter@informatik.uni-hamburg.de>
2012-02-23 00:11:22 +01:00
Justus Winter
ba95980cf1 python: refactor the python bindings
Move the Directory class into its own file, merge the two Filenames
classes into one, deprecate Filenames.as_iterator, update the
documentation accordingly.

Signed-off-by: Justus Winter <4winter@informatik.uni-hamburg.de>
2012-02-22 22:06:45 +01:00
Justus Winter
1736488ecf python: work around libnotmuch calling exit(3) in Database.find_message_by_filename
Signed-off-by: Justus Winter <4winter@informatik.uni-hamburg.de>
2012-02-22 21:14:35 +01:00
Justus Winter
05cdb3d7b7 python: improve the docstring of Database.find_message_by_filename
Signed-off-by: Justus Winter <4winter@informatik.uni-hamburg.de>
2012-02-22 21:14:35 +01:00
Justus Winter
fcf19ad029 python: work around libnotmuch calling exit(3) in Database.get_directory
Signed-off-by: Justus Winter <4winter@informatik.uni-hamburg.de>
2012-02-22 21:14:35 +01:00
Justus Winter
35ceaf496f python: Improve the docstring of Database.get_directory
Signed-off-by: Justus Winter <4winter@informatik.uni-hamburg.de>
2012-02-22 21:14:35 +01:00
Justus Winter
92983dd14e python: avoid using a magic value for database mode in Database.__init__
Signed-off-by: Justus Winter <4winter@informatik.uni-hamburg.de>
2012-02-22 21:14:35 +01:00
Justus Winter
0b2ff308ec python: fix the type nonsense of the first parameter of class Directory
Signed-off-by: Justus Winter <4winter@informatik.uni-hamburg.de>
2012-02-21 01:06:15 +01:00
Justus Winter
c1094bc2d7 python: allow an empty path as parameter to Database.get_directory
Signed-off-by: Justus Winter <4winter@informatik.uni-hamburg.de>
2012-02-21 00:56:07 +01:00
Justus Winter
786f9882e8 python: remove :returns: keywords from functions returning nothing
Signed-off-by: Justus Winter <4winter@informatik.uni-hamburg.de>
2012-02-21 00:15:59 +01:00
Justus Winter
1737ff5290 python: rework Directory.set_mtime
Fix the indentation within the docstring, remove useless remarks, do
some trivial refactoring.

Signed-off-by: Justus Winter <4winter@informatik.uni-hamburg.de>
2012-02-21 00:13:20 +01:00
Justus Winter
798b74e859 python: harmonize the sphinx keyword for exceptions
Signed-off-by: Justus Winter <4winter@informatik.uni-hamburg.de>
2012-02-21 00:01:23 +01:00
Justus Winter
a1442952d4 python: refactor the error handling machinery
Raise specific error classes instead of a generic NotmuchError with an
magic status value (e.g. NotmuchError(STATUS.NULL_POINTER) ->
NullPointerError()), update the documentation accordingly.

Signed-off-by: Justus Winter <4winter@informatik.uni-hamburg.de>
2012-02-20 23:49:07 +01:00
Justus Winter
be851ad39d python: more error handling fixes
This is a follow up commit to 221c7e0b38
fixing more NULL pointer checks.

Signed-off-by: Justus Winter <4winter@informatik.uni-hamburg.de>
2012-02-19 00:36:15 +01:00
Justus Winter
5d69d272c3 python: move Query class to its own file
Signed-off-by: Justus Winter <4winter@informatik.uni-hamburg.de>
2012-02-18 01:10:45 +01:00
Justus Winter
36ce7e3c98 python: implement the context manager protocol for database objects
Signed-off-by: Justus Winter <4winter@informatik.uni-hamburg.de>
2012-02-15 22:41:16 +01:00
Justus Winter
b2734519db python: provide a Database.close function
Rename Database.__del__ to Database.close, move it just below the open
function and call close() in a newly created destructor just below the
constructor.

Signed-off-by: Justus Winter <4winter@informatik.uni-hamburg.de>
2012-02-15 22:25:13 +01:00
Justus Winter
bb514d7862 py3k: Fix decoding of default database name in Database._get_user_default_db
Signed-off-by: Justus Winter <4winter@informatik.uni-hamburg.de>
2012-02-10 22:34:47 +01:00