Commit graph

72 commits

Author SHA1 Message Date
David Bremner
8603396861 version: bump to 0.9
also bump python bindings version.
2011-10-11 21:50:56 -03:00
David Bremner
af1dc7ef48 version: bump to 0.9~rc2
We continue to keep the python bindings version in sync manually
2011-10-07 22:42:18 -03:00
Sebastian Spaeth
dba9c31335 python: Set status in the class definitions
Technically, this is a superfluous change, as the self.status variable
currently gets set in NotmuchErrors's __new__ function. However, in the
long run I would like to get rid of the weird __new__ implementation which
might be somewhat confusing for users (NotmuchError(status) returns a
different class, e.g. OutOfMemoryError)

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2011-10-05 17:57:46 +02:00
Sebastian Spaeth
5e75398c80 python: help function Query._assert_query_is_initialized
Remove code duplication by using the new helper function. Also raise the
new fine grained exceptions in many cases, rather than the more generic
NotmuchErrors.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2011-10-05 17:55:30 +02:00
Sebastian Spaeth
42f184c236 python: clean up docstrings and API documentation
Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2011-10-05 17:54:09 +02:00
Sebastian Spaeth
a8db280f58 python: whitespace fixed in docstrings
Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2011-10-05 17:05:37 +02:00
Sebastian Spaeth
2b43a65c1c python: Add the new exception types in the API documentation
as they should be documented...

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2011-10-05 16:58:13 +02:00
Sebastian Spaeth
05926adf73 python: Catch up with find_message(by_filename) API changes
message is now an out parameter, and we get an additional status code as
a result. Hurray \o/.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2011-10-05 16:44:35 +02:00
Sebastian Spaeth
70479753a6 python: also use libnotmuch.so.2
Catch up with the major version bump. I wonder if this could somehow be
automatically made the correct version number. Oh well, I hope it
doesn't change too often :-).

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2011-10-05 15:46:03 +02:00
Thomas Jost
a859d1c866 python: fix Message.get_filenames()
Previously, the Filenames generator only yielded *one* filename before
returning, making Message.get_filenames() behave as Message.get_filename(). This
commit fixes this incorrect behavior: now the generator yields all the
filenames, as expected.
2011-10-01 00:40:20 +02:00
Sebastian Spaeth
8c51525e82 python: rework creating of Subclasses
Add some smart magic, so that when we invoke a
NotmuchError(STATUSVALUE), a nicely derived subclass is created, e.g. a
OutOfMemoryError. This way users can easily distinguish between error
types, while still catching NotmuchError.

I have tested this, and hope it works for others too.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2011-09-30 16:04:42 +02:00
Justus Winter
b6a01735d2 python: provide more exception classes
To make the exception handling more effective in code using the
python bindings it is necessary to differentiate between the
different kind of failures.

Add an exception class for each status code and add a decode
classmethod to the NotmuchError class that acts as a factory.

Import the new classes in __init__.py so they can be easily
imported by anyone.

Patch modifed by Sebastian Spaeth.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
Signed-off-by: Justus Winter <4winter@informatik.uni-hamburg.de>
2011-09-30 13:58:03 +02:00
Justus Winter
a378a91ba2 python: fix docstring of Message.get_header()
Update the docstring from notmuch.h.

Signed-off-by: Justus Winter <4winter@informatik.uni-hamburg.de>
2011-09-30 11:08:51 +02:00
Sebastian Spaeth
f63d605835 python: Add new functions in API documentation
Add documentation for the three new functions and add in which version
they have been added.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2011-09-29 11:00:43 +02:00
Sebastian Spaeth
eb4cd33e6b python: Improve code documentation
1) Fix added .gitignore from commit dc8a1745 to work on the docs folder
2) Improve in-code developer documentation to produce better
   sphinx-generated documentation. No code changes.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2011-09-29 10:47:28 +02:00
Justus Winter
19daa117b9 properly raise exceptions in python bindings
There are various locations where exceptions are constructed but
not raised. This patch adds the necessary raise statements.

Signed-off-by: Justus Winter <4winter@informatik.uni-hamburg.de>
2011-09-29 09:48:06 +02:00
Justus Winter
34990908e7 python: raise a more specific error in Messages.print_messages
Raising Exception is considered bad since the only way to catch
it is to do 'except Exception'. Raising a TypeError is more
appropriate.

Since the format parameter has already been validated, checking
it again is not necessary. Simplify this conditional.

Signed-off-by: Justus Winter <4winter@informatik.uni-hamburg.de>
2011-09-29 09:39:45 +02:00
Justus Winter
f88d985e50 python: rename _verify_dir_initialized to _assert_dir_is_initialized
Rename the function to clarify its effect and remove all the comments
accompanying each call to the function.

Modified by Sebastian Spaeth to apply cleanly again and remove some
blank lines.

Signed-off-by: Justus Winter <4winter@informatik.uni-hamburg.de>
Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2011-09-29 09:29:17 +02:00
Justus Winter
94a1bb88aa python: rename _verify_initialized_db to _assert_db_is_initialized
Rename the function to clarify its effect and remove all the comments
accompanying each call to the function.

Modified slightly by Sebastian Spaeth to catch all new instances and
remove some blank lines too.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
Signed-off-by: Justus Winter <4winter@informatik.uni-hamburg.de>
2011-09-29 09:23:13 +02:00
Justus Winter
c16e47fe23 python: fix NotmuchError.__str__ if status == None
Passing None to STATUS.status2str raises an ArgumentError. Add a
check for this case and provide a generic message.

Signed-off-by: Justus Winter <4winter@informatik.uni-hamburg.de>
2011-09-29 09:16:34 +02:00
Justus Winter
fc2d353eeb python: add status and message attributes to NotmuchError
Providing exception objects with meaningful attribute names
is much nicer than using e.args[].

Signed-off-by: Justus Winter <4winter@informatik.uni-hamburg.de>
2011-09-29 09:07:11 +02:00
Justus Winter
dc8a1745e1 python: add a .gitignore file and refine the toplevel one
The line 'notmuch' in the toplevel .gitignore file is to broad
and matches bindings/python/notmuch making it cumbersome to
git-add files within that directory.

Refine the toplevel file to only match the generated notmuch
executable and add a more specialized .gitignore file to the
python directory.

Signed-off-by: Justus Winter <4winter@informatik.uni-hamburg.de>
2011-09-29 09:04:50 +02:00
Sebastian Spaeth
0241a68e9e python: add begin|end_atomic bindings
* Add UNBALANCED_ATOMIC status code
  Catch up with the notmuch status codes, and add the UNBALANCED_ATOMIC
  one.
* Add the begin_atomic and end_atomic calls to libnotmuch

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2011-09-28 18:31:49 +02:00
Sebastian Spaeth
2c76279cda python: Add database_find_message_by_filename bindings
Add it :-)

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2011-09-28 18:31:36 +02:00
David Bremner
78d39a0908 version: bump to 0.9~rc1
This version number change should not be taken as definitive, rather
refer to the signed tag.
2011-09-24 20:00:29 -03:00
Martin Owens
8e7a108363 python: Ensure that we pass utf-8 encoded string to libnotmuch
If we use unicode objects, libnotmuch would not cope with null bytes in
the byte array, so we need to make sure they are nicely formatted as
utf-8.

Introduce a helper function _str which does this throughout the code.

Patch slightly modified by Sebastian Spaeth.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2011-09-16 13:19:14 +02:00
David Bremner
24fc8f97e8 update versions for release 0.8
See commit 6979b65 for more discussion.
2011-09-10 08:55:33 -03:00
David Bremner
6979b6533a update versions for release candidate
we now have three files to keep in sync. That seems wrong, but I guess
we will live with it for now.

The main problem is that the python code is distributed separately, so
it can't get the version from 'version'.

The choice ~rcX is for convenience with debian versioning.
2011-09-06 22:55:01 -03:00
Sebastian Spaeth
e2e0d487ba python: Make Database take unicode paths
Decode and Encode from/to unicode objects as required to be able to take
unicode path names. Previously we would error out when an unicode object
were handed it.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2011-09-05 15:52:12 +02:00
Sebastian Spaeth
5dc189c82d python: Have setup.py read the version number without importing
Importing the notmuch module in setup.py is a no-no, and we want
to auto-generate the version number in the release process.

Outsource __VERSION__ to the new version.py which contains nothing else
and which can therefor easily be autogenerated. Have setup.py read in
the file via execfile and test if importing the version number actually
worked.

This should make all happy.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2011-08-24 09:13:34 +02:00
Sebastian Spaeth
2fceb738c7 python: Updated development status and wording in setup.py
We are beyond pre-alpha, and the Requirements wording could take some
tweaking. Done.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2011-08-24 09:01:50 +02:00
Sebastian Spaeth
73f104445b Revert "python: Simplify setup.py"
This reverts commit 8826fc2d7b.

It seems that importing the module in setup.py is controversial at best,
as it will fail for users that don't have all dependencies
installed. This was the case in e.g. the Ubuntu autobuilder, so building
notmuch failed. The plan is to create an autogenerated setup.py that can
be used for version information.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2011-08-24 08:54:58 +02:00
Sebastian Spaeth
8826fc2d7b python: Simplify setup.py
We were using a template setup.py which parsed __init__.py in complex
ways just to find out the version number. Simply import notmuch and use
__VERSION__ directly. Also adapt some wording and setup.py values while
going through.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2011-08-23 09:30:49 +02:00
pazz
f10ec87cc3 python: Fix unsafe utf-8 decodings
This prevents unsafe calls to decode for return value None in
get_authors/get_subject which would current throw an Exception. Original
patch modified by Sebastian Spaeth.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2011-08-17 14:44:45 +02:00
patrick
ee4579ad27 decode headers from utf-8 to unicode
as mail headers are stored as utf-8 in the index,
it is safe to return them as unicode strings directly
2011-08-15 15:48:50 +02:00
Sebastian Spaeth
dc6b2b4382 python: remove Tags().__len__() implementation
len() exhausts the tag iterator and e.g. list() or "".join(tags)
implicitly call len() if existing and then failing. So, we remove
Tags.__len__().

If you need to know the number of tags a message has, do use
len(list(tags)). It would be nicer to be able to support len() directly...

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2011-08-09 17:48:27 +02:00
Sebastian Spaeth
94c5edd064 python: Do explicitly check if the next tag exists
If we try to pull a non-existing tag, Tags._get will return None and the
appended .decode() command will fail. So make sure that there is a tag to
be fetched before fetching it.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2011-08-09 17:45:44 +02:00
pazz
e75fd0d937 python: pep8 compliance for __init__.py 2011-08-09 17:28:24 +02:00
pazz
61b96f2c24 python: pep8 compliance for thread.py 2011-08-09 17:28:24 +02:00
pazz
be7947f459 python: pep8 compliance for tag.py 2011-08-09 17:28:24 +02:00
pazz
c49bcfd4e2 python: pep8 compliance for globals.py 2011-08-09 17:28:24 +02:00
pazz
8176326f30 python: pep8 compliance for filename.py 2011-08-09 17:28:24 +02:00
pazz
e69e30edd7 python: pep8 compliance for database.py 2011-08-09 17:28:24 +02:00
pazz
61f0184707 python: pep8 compliance for message.py 2011-08-09 17:28:24 +02:00
Sebastian Spaeth
9562c7d1fb python: Really throw an error if search_threads() fails
In case, search_threads returns an error we are supposed to throw an
Exception. But we did not "raise" it, this was an oversight and this
commit fixes it.

There is still the problem that there is often output to stderr by
libnotmuch detailing the xapian error and this is simply printed
out. But this requires fixing at the libnotmuch level...

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2011-08-09 16:51:03 +02:00
Cedric Cabessa
805d737029 python: Fix copy'n paste typo
we accessed a wrong attribute due to a copy and paste error. Thanks for
catching this.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2011-08-09 16:34:02 +02:00
Sebastian Spaeth
687366b920 python: represent message tags as unicode instances
Rather than returning simply strings and having to guess their encoding,
return explicit unicode() strings for the tags. Xapian stores UTF8, so
we know that they come as UTF8 encoded string.

Note: I tried to directly use the c_wchar_p type of the ctypes library
which translates directly into an unicode type, but that did not work
out so well, so we take c_char_p and .decode() them manually.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2011-07-11 15:02:12 +02:00
Sebastian Spaeth
504b6242d1 python: Encode query string as a utf-8 byte array
If we pass in an unicode instance as query string, we would probably get
weird behavior (and indeed do so, see mail
id:"20110707113700.GA16347@megatron"). If a unicode instance is passed
in, make sure we encode it properly to an utf-8 encoded byte string.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2011-07-11 11:46:54 +02:00
Sebastian Spaeth
3545a2960d python: Fix Database().needs_upgrade()
A stupid typo was preventing this from ever working and it was not
detected until now. Patrick noted the typo and proposed the fix in mail
id:"20110704203926.GA20238@brick.lan".

Patch-by: Patrick Totzke <patricktotzke@googlemail.com>
Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2011-07-08 22:47:06 +02:00
Sebastian Spaeth
e59eaa5ddd python: Do not implicitely call maildir_flags_to_tags etc
In order to remain consistent with the underlying C API, we do not
automatically synchronize notmuch tags and maildir flags anymore.

The underlying functions Message.maildir_flags_to_tags and
Message.tags_to_maildir_flags still exist and are available to the user.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2011-06-24 08:44:06 +02:00