aboutsummaryrefslogtreecommitdiffhomepage
path: root/bindings/python/notmuch/message.py
Commit message (Collapse)AuthorAge
* python: fix Message.get_headerGravatar Justus Winter2012-05-17
| | | | | | | | | | | | 8dc8495010057202b725ac029831c03f4e3ab6bd introduced a bug, if the requested header is not set the underlying notmuch function returns an empty string that also made the expression true resulting in an exception being raised. Partly revert the commit to fix this issue. Testing for equality with None is correct in this case since the restype of the function Message._get_header is c_char_p so NULL pointers are in fact converted to None in this case. Signed-off-by: Justus Winter <4winter@informatik.uni-hamburg.de>
* python: Fix the remaining broken NULL pointer testsGravatar Justus Winter2012-05-17
| | | | Signed-off-by: Justus Winter <4winter@informatik.uni-hamburg.de>
* python: remove unused import of the json moduleGravatar Justus Winter2012-05-17
| | | | Signed-off-by: Justus Winter <4winter@informatik.uni-hamburg.de>
* python: remove functions that have been marked as deprecated in 0.13Gravatar Justus Winter2012-05-16
| | | | | | | | | | | Removes Message.format_message_{internal,as_json,as_text}. 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. The code has been marked as deprecated in 0.13 and is now removed. Signed-off-by: Justus Winter <4winter@informatik.uni-hamburg.de>
* python: deprecate code formatting messages as text and jsonGravatar Justus Winter2012-04-30
| | | | | | | | | 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>
* python: fix NULL pointer testsGravatar Justus Winter2012-04-30
| | | | | | | Fix the NULL pointer tests in the destructors of all classes and Database.create. Signed-off-by: Justus Winter <4winter@informatik.uni-hamburg.de>
* python: fix Message.get_filenamesGravatar Justus Winter2012-04-30
| | | | | | Do not to use the removed function Filenames.as_iterator. Signed-off-by: Justus Winter <4winter@informatik.uni-hamburg.de>
* python: strip superfluous single quote from copyright noticesGravatar Justus Winter2012-04-29
| | | | Signed-off-by: Justus Winter <4winter@informatik.uni-hamburg.de>
* python: move the exception classes into error.pyGravatar Justus Winter2012-02-23
| | | | Signed-off-by: Justus Winter <4winter@informatik.uni-hamburg.de>
* python: rename filename.py into filenames.pyGravatar Justus Winter2012-02-22
| | | | Signed-off-by: Justus Winter <4winter@informatik.uni-hamburg.de>
* python: move Messages class into its own fileGravatar Justus Winter2012-02-22
| | | | Signed-off-by: Justus Winter <4winter@informatik.uni-hamburg.de>
* python: remove :returns: keywords from functions returning nothingGravatar Justus Winter2012-02-21
| | | | Signed-off-by: Justus Winter <4winter@informatik.uni-hamburg.de>
* python: harmonize the sphinx keyword for exceptionsGravatar Justus Winter2012-02-21
| | | | Signed-off-by: Justus Winter <4winter@informatik.uni-hamburg.de>
* python: refactor the error handling machineryGravatar Justus Winter2012-02-20
| | | | | | | | 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>
* python: more error handling fixesGravatar Justus Winter2012-02-19
| | | | | | | This is a follow up commit to 221c7e0b38177f5f1dbf0561580c15e8aaa49004 fixing more NULL pointer checks. Signed-off-by: Justus Winter <4winter@informatik.uni-hamburg.de>
* python: fix error handlingGravatar Justus Winter2012-01-22
| | | | | | | | | | | 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.
* python: str.decode() doesn't like kwargs in python 2.5Gravatar Sebastian Spaeth2012-01-02
| | | | | | | | | 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>
* python: make the result of Message.get_replies() more pythonicGravatar Justus Winter2012-01-02
| | | | | | | | | | | 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.
* python: refactor print_messages into format_messages and print_messagesGravatar Justus Winter2012-01-02
|
* python: add missing conversions from and to utf-8Gravatar Justus Winter2012-01-02
|
* py3k: Add and use a mixin class that implements __str__Gravatar Justus Winter2012-01-02
| | | | | Amended by Sebastian Spaeth <Sebastian@SSpaeth.de> to include the required sys import in globals.py.
* py3k: Rename .next() to __next__(), add python2.x compatibility aliasGravatar Justus Winter2012-01-02
|
* fix format string in Message.__unicode__Gravatar Patrick Totzke2011-12-06
| | | | | | | Since 2b0116119160f2dc83, 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.
* errors='ignore' when decode to unicodeGravatar Patrick Totzke2011-12-06
|
* use __unicode__ for string representationGravatar Patrick Totzke2011-12-06
|
* python: Return a STATUS value in tags_to_flags and flags_to_tagsGravatar Sebastian Spaeth2011-12-06
| | | | | | | 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>
* remove unused importsGravatar Patrick Totzke2011-12-06
|
* fix sphinx compile-time warningsGravatar Patrick Totzke2011-12-06
| | | | | no changes to the code, only makes compiling the docs smoother as some rsT syntax errors were fixed
* python: annotate all calls into libnotmuch with typesGravatar Justus Winter2011-12-01
| | | | | | | | | | | 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>
* python: fix docstring of Message.get_header()Gravatar Justus Winter2011-09-30
| | | | | | Update the docstring from notmuch.h. Signed-off-by: Justus Winter <4winter@informatik.uni-hamburg.de>
* properly raise exceptions in python bindingsGravatar Justus Winter2011-09-29
| | | | | | | 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>
* python: raise a more specific error in Messages.print_messagesGravatar Justus Winter2011-09-29
| | | | | | | | | | | 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>
* python: Ensure that we pass utf-8 encoded string to libnotmuchGravatar Martin Owens2011-09-16
| | | | | | | | | | | | 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>
* decode headers from utf-8 to unicodeGravatar patrick2011-08-15
| | | | | as mail headers are stored as utf-8 in the index, it is safe to return them as unicode strings directly
* python: pep8 compliance for message.pyGravatar pazz2011-08-09
|
* python: Do not implicitely call maildir_flags_to_tags etcGravatar Sebastian Spaeth2011-06-24
| | | | | | | | | | 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>
* Simplify (& fix) Message().__str__()Gravatar Sebastian Spaeth2011-06-16
| | | | | | | | | | | | 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>
* python: Improve API documentationGravatar Sebastian Spaeth2011-06-16
| | | | | | Various API doc cleanups and improvements. No code change. Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
* Implement Message.tags_to_maildir_flagsGravatar Sebastian Spaeth2011-06-16
| | | | | | | | | 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>
* python: Improve documentationGravatar Sebastian Spaeth2011-06-15
| | | | | | | | 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>
* python: Implement Message.__cmp__ and __hash__Gravatar Sebastian Spaeth2011-06-15
| | | | | | | | | | 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>
* python: Remove Messages().__len__Gravatar Sebastian Spaeth2011-06-15
| | | | | | | | | | | 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>
* bindings/python: Implement Message().get_filenames()Gravatar Sebastian Spaeth2011-06-02
| | | | | | | | | | | | | | | | | | | | 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>
* python: lambda(p) is not P3k-compliantGravatar Sebastian Spaeth2010-10-28
| | | | Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
* Move everything down into a bindings/python directory.Gravatar Carl Worth2010-04-21
In preparation for merging the python bindings into the notmuch repository.