Commit graph

552 commits

Author SHA1 Message Date
Justus Winter
4bb9f59ff6 python: fix the projects name and update years of the copyright notice in the sphinx docs
Signed-off-by: Justus Winter <4winter@informatik.uni-hamburg.de>
2012-02-20 21:48:35 +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
ab2f9fd828 python: remove trailing whitespace within the documentation source files
Signed-off-by: Justus Winter <4winter@informatik.uni-hamburg.de>
2012-02-18 01:41:23 +01:00
Justus Winter
bf6039e34e python: improve Query.count_messages docstring
Signed-off-by: Justus Winter <4winter@informatik.uni-hamburg.de>
2012-02-18 01:39:39 +01:00
Justus Winter
ff8f864245 python: wrap notmuch_query_count_threads as Query.count_threads
Signed-off-by: Justus Winter <4winter@informatik.uni-hamburg.de>
2012-02-18 01:39:39 +01:00
Justus Winter
4315ac015a python: refactor Query class
Put each libnotmuch function reference right in front of the
corresponding python wrapper.

Signed-off-by: Justus Winter <4winter@informatik.uni-hamburg.de>
2012-02-18 01:13:06 +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
ff287531ca python: remove unused but imported symbol
Signed-off-by: Justus Winter <4winter@informatik.uni-hamburg.de>
2012-02-18 01:01:33 +01:00
Justus Winter
c471d44837 python: remove unused but imported symbol
Signed-off-by: Justus Winter <4winter@informatik.uni-hamburg.de>
2012-02-18 00:57:59 +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
Justus Winter
ae376c774e python: mock out the ctypes library
This allows rtfd.org to build the documentation without libnotmuch.

Signed-off-by: Justus Winter <4winter@informatik.uni-hamburg.de>
2012-02-10 18:55:33 +01:00
Justus Winter
8c5be7d12d python: Add a Mock class to the sphinx config that can be used to mock modules
Signed-off-by: Justus Winter <4winter@informatik.uni-hamburg.de>
2012-02-10 18:54:49 +01:00
David Bremner
d43f6c00b3 Merge commit '0.11.1'
Conflicts:
	NEWS
	bindings/python/notmuch/database.py
	bindings/python/notmuch/message.py
	notmuch.1

NEWS merged by hand, others taken from master.
2012-02-04 12:01:46 -05:00
David Bremner
c10b780b44 version: bump to 0.11.1
also semi-automatically update man page and python bindings versions.
2012-02-03 08:32:49 -04:00
Justus Winter
221c7e0b38 python: fix error handling
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.
2012-01-23 07:44:08 -04:00
Justus Winter
8015cbff26 python: fix error handling
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.
2012-01-22 06:14:57 +01:00
Justus Winter
7ddd849015 py3k: add a specialized version of _str for python3
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>
2012-01-16 13:43:11 +01:00
David Bremner
0bbfc5ce8b Merge branch 'release'
Conflicts:
	notmuch-reply.c
	notmuch.1
2012-01-13 20:52:01 -04:00
David Bremner
9ada8335c6 Update version to 0.11 2012-01-13 19:58:36 -04:00
David Bremner
310608f279 version: update to 0.11~rc3
We found another serious-ish bug during freeze.
2012-01-09 07:05:40 -04:00
Sebastian Spaeth
228d8c0528 python: str.decode() doesn't like kwargs in python 2.5
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>
2012-01-02 17:07:53 +01:00
Justus Winter
ada246aa20 python: make the result of Message.get_replies() more pythonic
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.
2012-01-02 17:01:40 +01:00
Justus Winter
e32c8a5e6b python: refactor print_messages into format_messages and print_messages 2012-01-02 16:55:53 +01:00
Justus Winter
83b256b12b python: add missing conversions from and to utf-8 2012-01-02 16:34:56 +01:00
Justus Winter
4a6642a2a1 py3k: Add and use a mixin class that implements __str__
Amended by Sebastian Spaeth <Sebastian@SSpaeth.de> to include the
required sys import in globals.py.
2012-01-02 16:33:29 +01:00
Justus Winter
26d52cf6cf py3k: Rename .next() to __next__(), add python2.x compatibility alias 2012-01-02 16:12:28 +01:00
Justus Winter
9c32ee5372 py3k: All strings are unicode strings in py3k 2012-01-02 16:11:52 +01:00
Justus Winter
4ed0362d41 py3k: The ConfigParser module has been renamed to configparser 2012-01-02 16:08:32 +01:00
Justus Winter
676ce952d3 py3k: The execfile built-in has been removed in python 3 2012-01-02 16:06:59 +01:00
David Bremner
ff58a06e83 version: bump to 0.11~rc2
This to "celebrate" pushing a bugfix in at the last minute.
2012-01-02 06:50:07 -04:00
David Bremner
c616ada489 version: update version to 0.11~rc1
and keep python, man page, and debian package in sync.
2011-12-25 23:09:17 -04:00
David Bremner
f0e0053149 Merge branch 'release'
Conflicts:
	NEWS

Conflicts resolved by inserting the 0.10.2 stanza before 0.11
2011-12-06 19:39:33 -04:00
Patrick Totzke
c4d824bc1e fix format string in Message.__unicode__
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.
2011-12-06 21:56:40 +01:00
Sebastian Spaeth
50b0d0b8ad python: Remove stray debug comment
This slipped in wrongly in commit 71e0082eff (due to my fault).

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2011-12-06 13:36:48 +01:00
Thomas Jost
71e0082eff python: use wrapped notmuch_*_t types instead of raw pointers
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
2011-12-06 13:34:30 +01:00
Patrick Totzke
672b6337b4 errors='ignore' when decode to unicode 2011-12-06 13:28:39 +01:00
Patrick Totzke
ffe3097e58 use __unicode__ for string representation 2011-12-06 13:27:08 +01:00
Patrick Totzke
2b01161191 clean up Thread.__str__ 2011-12-06 13:21:42 +01:00
Sebastian Spaeth
ecf8da35e2 python: Return a STATUS value in tags_to_flags and flags_to_tags
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>
2011-12-06 12:38:52 +01:00
Patrick Totzke
86b0aeb1ca remove unused imports 2011-12-06 12:28:35 +01:00
Patrick Totzke
12ebf87947 fix sphinx compile-time warnings
no changes to the code, only makes compiling the docs smoother
as some rsT syntax errors were fixed
2011-12-06 12:23:50 +01:00
Patrick Totzke
4292b1197d pep8 fixes
no changes to the code, only fixed stuff denounced by `pep8 *py`
2011-12-06 12:20:45 +01:00
David Bremner
d7276c6241 version: bump for bugfix release 0.10.2 2011-12-05 18:07:00 -04:00
Justus Winter
3434d19402 python: annotate all calls into libnotmuch with types
Add type information to the ctypes._FuncPtr wrappers and
use the wrapper classes instead of c_void_p for pointers
to notmuch_*_t.

This enables the ctypes library to type check parameters
being handed to functions from the notmuch library.

Signed-off-by: Justus Winter <4winter@informatik.uni-hamburg.de>
2011-12-01 22:24:19 +01:00
Justus Winter
e92b438f46 python: add classes to wrap all notmuch_*_t types
Signed-off-by: Justus Winter <4winter@informatik.uni-hamburg.de>
2011-12-01 22:24:12 +01:00
David Bremner
f3ad20b20a version: update to 0.10.1 2011-11-25 12:11:04 -05:00
David Bremner
1915c14a3a version: update to 0.10 2011-11-23 07:37:02 -04:00
David Bremner
eb88cd977b version: update version info for 0.10~rc2
Arguably editing debian/changelog violates the "do one thing at a
time" rule, but all of these versions need to be kept in sync.
2011-11-19 08:24:30 -04:00
David Bremner
6b8fd9dd41 version: update to 0.10~rc1
and the usual dance with the python bindings version.
2011-11-15 19:46:08 -04:00
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
Ali Polatel
5c00af46ec ruby: Fix macros, use quoting
Fix Data_Get_Notmuch_* macro definitions broken by prev. commit
Adequate quoting for Data_Get_Notmuch_* macros
Remove duplicated RSTRING_PTR() macros, move it to defs.h
2011-10-04 16:57:33 +03:00
Ali Polatel
c8a88fe95d ruby: Really add wrappers for database_find_message*
Commit 898613116d only added wrapper
functions but did not register them. Register the functions in module's
initialization function.
2011-10-04 16:48:34 +03:00
Ali Polatel
05dddf883d ruby: be consistent with notmuch's coding style
No functional change, just indentation
2011-10-04 16:43:40 +03:00
Ali Polatel
898613116d ruby: Add wrappers for database_find_message*
Two new wrappers:
Notmuch::Database.find_message(id) => Notmuch::Message or nil
Notmuch::Database.find_message_by_filename(path) => Notmuch::Message or nil
2011-10-04 16:06:20 +03: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
Ali Polatel
59d2457bcc ruby: New exception Notmuch::UnbalancedAtomicError
This exception wraps NOTMUCH_STATUS_UNBALANCED_ATOMIC which was added
with the commit e59cc0031f.
2011-09-24 15:54:45 +03:00
Ali Polatel
bbb41081d7 ruby: Wrap notmuch_database_{begin,end}_atomic
Adding ruby wrappers for functions:
- notmuch_database_begin_atomic()
- notmuch_database_end_atomic()
added by 957f1ba3fc

New functions:
Notmuch::Database.begin_atomic()
Notmuch::Database.end_atomic()
2011-09-24 15:43:43 +03:00
Ali Polatel
a08aa32b44 ruby: Rename destroy to destroy!
According to the common Ruby function naming convention, potentially
dangerous functions or functions which operate on the object itself are
suffixed with an exclamation mark. Both of these are true for object
destroying functions.

The following modules are affected:
- Notmuch::Directory
- Notmuch::FileNames
- Notmuch::Query
- Notmuch::Threads
- Notmuch::Thread
- Notmuch::Messages
- Notmuch::Message
- Notmuch::Tags
2011-09-24 15:25:24 +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
Ali Polatel
20aa9b1b7e ruby: Fix typo in documentation
It's Notmuch::FileNames not Notmuch::Filenames
2011-07-29 09:45:16 +03:00
Ali Polatel
e213439cdc ruby: Remove the split file hack from rdoc.sh 2011-07-29 09:44:44 +03:00
Ali Polatel
6ef8e018f8 ruby: Add markers to method definitions to help rdoc
rdoc is dumb and needs markers in method definitions so that she can
find which source file the method is defined in
2011-07-29 09:29:54 +03:00
Ali Polatel
666ef9f5f6 ruby: Document remaining undocumented constants 2011-07-29 09:16:12 +03:00
Ali Polatel
517faab24e ruby: Document constants and exceptions right before definition 2011-07-29 09:09:28 +03:00
Ali Polatel
00dfa0a17d ruby: Add list of classes to main documentation 2011-07-29 08:53:02 +03: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
David Bremner
c39b492c19 Do not import notmuch in setup.py.
Importing notmuch loads the notmuch shared library. When building
without a system install of notmuch, this requires e.g. setting
LD_LIBRARY_PATH for building and fails completely for cleaning.
2011-06-20 09:45:43 +02:00
Sebastian Spaeth
12d6f90e77 Simplify (& fix) Message().__str__()
We were still using len(self.get_replies()) for the __str__ summary of a
mail, but 1) len(Messages()) has just gone away 2) the number of replies
can not be retrieved when we got the message via search_messages()
anyway, and 3) it is likely quite expensive to pull all replies for all
messages that we display a summary of.

So we fix this by simplifying str(Message()) to omit the number of replies.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2011-06-16 17:33:47 +02:00
Sebastian Spaeth
995303c21b python: Bulletproof Database() path parameter
libnotmuch (and python) crashed when I accidently passed in an invalid
value as path argument to the Database() instantiation.

Therefore, we now check via assert that the handed in path is actually a
real string (or None).

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2011-06-16 15:51:13 +02:00
Sebastian Spaeth
0817f0e168 python: Improve API documentation
Various API doc cleanups and improvements. No code change.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2011-06-16 15:41:48 +02:00
Sebastian Spaeth
d8c0e0c72d Implement Message.tags_to_maildir_flags
and also maildir_flags_to_tags. The methods will be invoked by
db.add_message() and also (if not overridden via function parameter) by
add|remove_tag and remove_all_tags. Documentation on the usage has been
updated.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2011-06-16 14:41:02 +02:00
Sebastian Spaeth
b4049316cc python: Improve documentation
Improve the documentation with regard to the new __cmp__ and __hash__
methods and the implications of doing set arithmetic with Messages()
objects.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2011-06-15 21:36:26 +02:00
Sebastian Spaeth
4557af3064 python: Implement Message.__cmp__ and __hash__
We can now do: if msg1 == msg2, and we can use set arithmetic on
Messages():
  s1, s2= msgs1, msgs2
  s1.union(s2)
  s2 -= s1

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2011-06-15 15:05:47 +02:00
Sebastian Spaeth
8866a89e3c python: Remove Messages().__len__
Messages.__len__() exhausted the iterator and list() inherently calls
len(), so we could not invoke list(msgs) without getting errors. Fix
this by implementing __nonzero__ but removing __len__ on Messages.

Use Query.count_messages() or len(list(msgs)) if you need to know the
number.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2011-06-15 14:25:33 +02:00
Sebastian Spaeth
6ae4e7d88b bindings/python: Bump bindings version to 0.6
To match the upcoming release, and with the updated API to match the
current libnotmuch, bump the python version number (notmuch.__VERSION__)
to 0.6.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2011-06-02 17:44:23 +02:00
Sebastian Spaeth
aeecafa694 bindings/python: Implement Tags().__nonzero__()
Analog to Threads.__nonzero__ this allows us to perform list() on a Threads() object and to repeatedly call "if Tags():" or "bool(Tags())" without implicitly invoking len(), thus exhausting our iterator.

While touching this code, I added a small micro-optimization to the Tag next() function. There is no need to explicitly check _is_valid, as _get implicitly does check for validness and returns None, if there is no more Tag to fetch. This avoids some roundtrips into the library when iterating through Tags.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2011-06-02 17:28:50 +02:00
Sebastian Spaeth
01cc4a3115 bindings/python: implement Threads().__nonzero__
__nonzero__ checks if Threads() contains at least one more valid thread

 The existence of this function makes 'if Threads(): foo' work, as that
 previously implicitely called len() exhausting the iterator. This
 function makes `bool(Threads())` work repeatedly.

For further info, see http://docs.python.org/reference/datamodel.html.
Credits for the hint go to Brian May.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2011-06-02 16:28:00 +02:00
Sebastian Spaeth
4d406d9c25 bindings/python: Include the new get_filenames in the API docs
They had accidentally been left out, so we should also include the
function docs for get_messages in the API docs.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2011-06-02 09:20:56 +02:00
Sebastian Spaeth
b31247c354 bindings/python: Implement Message().get_filenames()
Message().get_filenames() will return a generator that allows to
iterator over the recorded filenames for a certain Message. Do ntoe that
as all generators, these are one-time use only. You will have to reget
them to perform various actions. So this works::

  len(Message().get_filenames())
  list(Message().get_filenames())
  for n in Message().get_filenames():
    print n

But this won't::

  names = Message().get_filenames()
  len(names) #uses up the iterator
  list(names) #outch, already used up...

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2011-06-02 09:03:18 +02:00
Carl Worth
f35db275c4 python: Update README to talkabout notmuch, not cnotmuch
The old instructions were telling users to do "easy_install cnotmuch"
which installed some old, stale bindings. The new instructions should
be much more effective.
2011-05-24 13:08:18 -07:00
James Vasile
74bc93f02d python: Remove completed TODO item
Really just a left-over TODO item in the code, nothing spectacular to
see here.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2011-03-16 10:14:30 +01:00
Sebastien Binet
62725a5b59 update for go-release-2011-02-01:
* M bindings/go/cmds/notmuch-addrlookup.go
    log.Exitf -> log.Fatalf
2011-02-03 09:36:58 +01:00
Ali Polatel
ca69ce2397 ruby: Add generated files to .gitignore 2011-02-03 01:40:38 +02:00
Sebastien Binet
38ce0dbf82 Migrate to goconfig pkg 2011-01-26 15:59:19 +10:00
Sebastien Binet
2fcfb1aa50 bindings/go: Add a todo file 2011-01-26 15:59:19 +10:00
Sebastien Binet
a6411b133f A minor, cosmetic change
Just trying to keep the line lengths in check.
2011-01-26 15:59:19 +10:00
Sebastien Binet
c234f8f972 Initial import of Go bindings for notmuch 2011-01-26 15:59:19 +10:00
Ali Polatel
90a66779e1 ruby: Add wrapper for message_get_filenames 2011-01-25 12:03:41 +02:00
Ali Polatel
02369d031c ruby: Add wrappers for maildir sync. interface
New wrappers:
notmuch_message_maildir_flags_to_tags(): MESSAGE.maildir_flags_to_tags
notmuch_message_tags_to_maildir_flags(): MESSAGE.tags_to_maildir_flags
2011-01-25 12:03:37 +02:00
Ali Polatel
ed38940323 ruby: Add wrappers for query_get_s{ort,tring}
New wrappers:
notmuch_query_get_sort(): QUERY.sort
notmuch_query_get_query_string(): QUERY.to_s
2011-01-25 12:03:32 +02:00
Sebastian Spaeth
3c7a52890c python: Update metainformation to point to new URL and version number
Convert the meta information to point to the notmuchmail.org repository, rather
than the old cnotmuch location. I will delete the "cnotmuch" package
from http://pypi.python.org/pypi/cnotmuch and create a new "notmuch"
package there that contains the current versions.

Also bump the version number to 0.4. I will need to upgrade the API
first before I can release the 0.5 of the bindings, there are still some
methods missing.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2011-01-13 12:35:59 +01:00
Carl Worth
44ea57a0d1 Merge in ruby bindings.
Thanks to Ali Polatel for these bindings. This code was fetched from
the ruby branch of:

	git://github.com/alip/notmuch.git
2010-11-08 10:08:34 -08:00
Sebastian Spaeth
c8bdd29895 python: lambda(p) is not P3k-compliant
Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2010-10-28 12:12:10 -07:00
Sebastian Spaeth
35042e0696 python: Import explicit including package name
To make python3 happy

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2010-10-28 12:12:04 -07:00
Ali Polatel
5c9e385591 ruby: Don't barf if an object is destroyed more than once
Raise RuntimeError instead.
Also revise Notmuch::Database a bit.
Add Notmuch::Database.open singleton method.
2010-06-06 09:18:00 +03:00
Ali Polatel
d2a457a5d8 ruby: Use rb_scan_args() 2010-06-06 09:17:57 +03:00
Ali Polatel
c7893408bb ruby: Kill garbage collection related cruft.
Let the user destroy objects that she wants explicitly.
It's not possible to specify the order objects are garbage collected.
See id:86y6f8v838.fsf@harikalardiyari.ev on ruby-talk for more
information.
2010-06-06 09:17:47 +03:00
Ali Polatel
35925e6e5b ruby: First attempt at fixing gc for ruby-1.9 2010-06-06 09:17:30 +03:00
Ali Polatel
8312e7efea ruby: fix documentation of DB.upgrade! 2010-06-06 09:17:06 +03:00
Ali Polatel
06bf04500b Initial ruby bindings 2010-06-06 09:16:53 +03:00
Sebastian Spaeth
c50524efd5 python: have docs reflect current return value behavior
Database.find_message() used to be able to reliably indicate whether a
message exists or not (in which case it returns None). However, the
recent API change of the notmuch library means we will return None
even for all Xapian exceptions, which happens e.g. when the current
Database has been modified by another project. Therefore the return
value of None cannot be reliably be used to indicate whether a message
exists or not. Make the docs state that explicitely.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2010-05-18 11:11:59 -07:00
Sebastian Spaeth
af8664689a python: Add UNSORTED as Query.SORT option
Keep up to date with the libnotmuch.so API.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2010-04-23 13:40:38 +02:00
Sebastian Spaeth
be7b24eb21 python: Delete unused files
No more .hg files needed in the git repo.
No stock notmuch-test suite needed in a subdirectory.
We have the real one in this repository

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2010-04-23 13:40:29 +02:00
Carl Worth
3b558de781 Move everything down into a bindings/python directory.
In preparation for merging the python bindings into the notmuch
repository.
2010-04-21 17:29:34 -07:00