Formerly all the constants were set to zero since in golang constants
are set to the previous value if no new value is specified. Use the
iota operator that is incremented after each use to fix this issue.
Signed-off-by: Justus Winter <4winter@informatik.uni-hamburg.de>
notmuch.OpenDatabase now returns a status indicating success or
failure. Use this information to inform the user of any failures.
Signed-off-by: Justus Winter <4winter@informatik.uni-hamburg.de>
We've changed the APIs of notmuch_database_open,
notmuch_database_create, and notmuch_database_close.
Amended by db: also bump string in bindings/python/notmuch/globals.py
The signature of notmuch_database_find_message was changed in 02a30767
to report errors and the Go bindings were never updated. This brings
the Go bindings in sync with that change and at least makes them
compile with Go r60.3, the last release before Go 1.
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>
This code adds functionality at the python level that is unlikely to
be useful for anyone. Furthermore the python bindings strive to be a
thin wrapper around libnotmuch, so this code will be removed in
notmuch 0.14.
Signed-off-by: Justus Winter <4winter@informatik.uni-hamburg.de>
Cleanup the code, reword the docstring and use the same implementation
in the Threads, Tags and Messages classes.
__nonzero__ implements truth value testing. If __nonzero__ is not
implemented, the python runtime would fall back to `len(..) > 0` thus
exhausting the iterator.
Signed-off-by: Justus Winter <4winter@informatik.uni-hamburg.de>
Formerly the documentation was overly verbose. Reword the comment and
use the same for both functions.
Signed-off-by: Justus Winter <4winter@informatik.uni-hamburg.de>
Remove the function Filenames.as_generator that has been marked as
deprecated in 0.12.
The class Filenames implements the iterator protocol so you can
directly iterate over such objects instead.
Signed-off-by: Justus Winter <4winter@informatik.uni-hamburg.de>
Move each classes documentation into its own file and thus into its
own page in the generated documentation.
Signed-off-by: Justus Winter <4winter@informatik.uni-hamburg.de>
Remove the notmuch prefix from classes in the documentation. This
change makes the table of contents look much nicer.
Signed-off-by: Justus Winter <4winter@informatik.uni-hamburg.de>
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>
Fix the indentation within the docstring, remove useless remarks, do
some trivial refactoring.
Signed-off-by: Justus Winter <4winter@informatik.uni-hamburg.de>
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>
Put each libnotmuch function reference right in front of the
corresponding python wrapper.
Signed-off-by: Justus Winter <4winter@informatik.uni-hamburg.de>
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>
Before 3434d1940 the return values of libnotmuch functions were
declared as c_void_p and the code checking for errors compared the
returned value to None, which is the ctypes equivalent of a NULL
pointer.
But said commit wrapped all the data types in python classes and the
semantic changed in a subtle way. If a function returns NULL, the
wrapped python value is falsish, but no longer equal to None.
Backported from master to 0.11.
Before 3434d1940 the return values of libnotmuch functions were
declared as c_void_p and the code checking for errors compared the
returned value to None, which is the ctypes equivalent of a NULL
pointer.
But said commit wrapped all the data types in python classes and the
semantic changed in a subtle way. If a function returns NULL, the
wrapped python value is falsish, but no longer equal to None.
All strings are unicode strings in python 3 and the basestring and
unicode types are removed hence the need for a specialized version.
Signed-off-by: Justus Winter <4winter@informatik.uni-hamburg.de>
Recent changes introduced lots of unicodification of strings, mostly in
the form of .decode('utf-8', errors='ignore'). However, python 2.5 does
not like the errors keyword argument and complains. It does work when
used as a simple arg though, so that's what this patch does.
Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
Formerly Message.get_replies() returned an iterator or None forcing
users to check the result before iterating over it leading to strange
looking code at the call site.
Fix this flaw by adding an EmptyMessagesResult class that behaves like
the Messages class but immediatly raises StopIteration if used as an
iterator and returning objects of this type from Message.get_replies()
to indicate that there are no replies.
Since 2b01161191, Message.__str__ doesn't
construct a hash containing the thread data before
constructing the formatstring. This changes the formatstring
to accept positional parameters instead of a hash.
Now that types are checked correctly, we also need to make sure that all the
arguments actually are instances of these types. Otherwise the function calls
will fail and raise an exception similar to this one:
ctypes.ArgumentError: argument 3: <type 'exceptions.TypeError'>: expected
LP_LP_NotmuchMessageS instance instead of pointer to c_void_p
We were not returning anything at all, which does not match the API
documentation. Fixed. Thanks to Patrick Totzke for the heads up.
Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>