Commit graph

16 commits

Author SHA1 Message Date
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
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
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
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