diff options
| author | David Bremner <david@tethera.net> | 2018-06-18 21:18:58 -0300 |
|---|---|---|
| committer | David Bremner <david@tethera.net> | 2018-06-18 21:18:58 -0300 |
| commit | 698415201715497bdf9d5f53aac0d58f65f86dd9 (patch) | |
| tree | af26b4a84fd985832f9aa51008e12fe5fda4689e /bindings/python | |
| parent | c6fba20b96f8c9ebdff0ea43bdc114b64617e4d0 (diff) | |
| parent | 079826f124823f134e5877173e9380edc2eeb3dc (diff) | |
Merge tag 'debian/0.27-1' into debian/stretch-backports
notmuch Debian 0.27-1 upload (same as 0.27)
Diffstat (limited to 'bindings/python')
| -rw-r--r-- | bindings/python/docs/COPYING | 2 | ||||
| -rw-r--r-- | bindings/python/docs/source/conf.py | 2 | ||||
| -rw-r--r-- | bindings/python/docs/source/filesystem.rst | 2 | ||||
| -rw-r--r-- | bindings/python/docs/source/message.rst | 4 | ||||
| -rw-r--r-- | bindings/python/notmuch/database.py | 4 | ||||
| -rw-r--r-- | bindings/python/notmuch/filenames.py | 2 | ||||
| -rw-r--r-- | bindings/python/notmuch/globals.py | 5 | ||||
| -rw-r--r-- | bindings/python/notmuch/message.py | 84 | ||||
| -rw-r--r-- | bindings/python/notmuch/messages.py | 2 | ||||
| -rw-r--r-- | bindings/python/notmuch/tag.py | 2 | ||||
| -rw-r--r-- | bindings/python/notmuch/thread.py | 2 | ||||
| -rw-r--r-- | bindings/python/notmuch/threads.py | 2 | ||||
| -rw-r--r-- | bindings/python/notmuch/version.py | 2 |
13 files changed, 101 insertions, 14 deletions
diff --git a/bindings/python/docs/COPYING b/bindings/python/docs/COPYING index 2a000655..e6000869 100644 --- a/bindings/python/docs/COPYING +++ b/bindings/python/docs/COPYING @@ -1,7 +1,7 @@ GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 - Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/> + Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/> Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. diff --git a/bindings/python/docs/source/conf.py b/bindings/python/docs/source/conf.py index 5107a96e..5b901c4e 100644 --- a/bindings/python/docs/source/conf.py +++ b/bindings/python/docs/source/conf.py @@ -215,4 +215,4 @@ latex_documents = [ # Example configuration for intersphinx: refer to the Python standard library. -intersphinx_mapping = {'http://docs.python.org/': None} +intersphinx_mapping = {'https://docs.python.org/': None} diff --git a/bindings/python/docs/source/filesystem.rst b/bindings/python/docs/source/filesystem.rst index a23ae41a..558c93de 100644 --- a/bindings/python/docs/source/filesystem.rst +++ b/bindings/python/docs/source/filesystem.rst @@ -14,7 +14,7 @@ Files and directories iterator and broke list(Filenames()). Use `len(list(names))` instead. -:class:`Directoy` -- A directory entry in the database +:class:`Directory` -- A directory entry in the database ------------------------------------------------------ .. autoclass:: Directory diff --git a/bindings/python/docs/source/message.rst b/bindings/python/docs/source/message.rst index 1a6cc3d5..b0033924 100644 --- a/bindings/python/docs/source/message.rst +++ b/bindings/python/docs/source/message.rst @@ -33,6 +33,10 @@ .. automethod:: get_tags + .. automethod:: get_property + + .. automethod:: get_properties + .. automethod:: maildir_flags_to_tags .. automethod:: tags_to_maildir_flags diff --git a/bindings/python/notmuch/database.py b/bindings/python/notmuch/database.py index a1ae14fc..342d665a 100644 --- a/bindings/python/notmuch/database.py +++ b/bindings/python/notmuch/database.py @@ -566,7 +566,7 @@ class Database(object): :returns: :class:`Message` or `None` if no message is found. :raises: :exc:`OutOfMemoryError` - If an Out-of-memory occured while constructing the message. + If an Out-of-memory occurred while constructing the message. :exc:`XapianError` In case of a Xapian Exception. These exceptions include "Database modified" situations, e.g. when the @@ -591,7 +591,7 @@ class Database(object): function returns None if no message is found with the given filename. - :raises: :exc:`OutOfMemoryError` if an Out-of-memory occured while + :raises: :exc:`OutOfMemoryError` if an Out-of-memory occurred while constructing the message. :raises: :exc:`XapianError` in case of a Xapian Exception. These exceptions include "Database modified" diff --git a/bindings/python/notmuch/filenames.py b/bindings/python/notmuch/filenames.py index 29f4fdf6..3bbc22b9 100644 --- a/bindings/python/notmuch/filenames.py +++ b/bindings/python/notmuch/filenames.py @@ -67,7 +67,7 @@ class Filenames(Python3StringMixIn): def __init__(self, files_p, parent): """ :param files_p: A pointer to an underlying *notmuch_tags_t* - structure. These are not publically exposed, so a user + structure. These are not publicly exposed, so a user will almost never instantiate a :class:`Tags` object herself. They are usually handed back as a result, e.g. in :meth:`Database.get_all_tags`. *tags_p* must be diff --git a/bindings/python/notmuch/globals.py b/bindings/python/notmuch/globals.py index 97413996..11e328b7 100644 --- a/bindings/python/notmuch/globals.py +++ b/bindings/python/notmuch/globals.py @@ -75,6 +75,11 @@ class NotmuchMessageS(Structure): NotmuchMessageP = POINTER(NotmuchMessageS) +class NotmuchMessagePropertiesS(Structure): + pass +NotmuchMessagePropertiesP = POINTER(NotmuchMessagePropertiesS) + + class NotmuchTagsS(Structure): pass NotmuchTagsP = POINTER(NotmuchTagsS) diff --git a/bindings/python/notmuch/message.py b/bindings/python/notmuch/message.py index d5b98e4f..d242097a 100644 --- a/bindings/python/notmuch/message.py +++ b/bindings/python/notmuch/message.py @@ -19,7 +19,7 @@ Copyright 2010 Sebastian Spaeth <Sebastian@SSpaeth.de> """ -from ctypes import c_char_p, c_long, c_uint, c_int +from ctypes import c_char_p, c_long, c_uint, c_int, POINTER, byref from datetime import date from .globals import ( nmlib, @@ -29,6 +29,7 @@ from .globals import ( NotmuchTagsP, NotmuchMessageP, NotmuchMessagesP, + NotmuchMessagePropertiesP, NotmuchFilenamesP, ) from .errors import ( @@ -113,6 +114,36 @@ class Message(Python3StringMixIn): _maildir_flags_to_tags.argtypes = [NotmuchMessageP] _maildir_flags_to_tags.restype = c_int + """notmuch_message_get_property""" + _get_property = nmlib.notmuch_message_get_property + _get_property.argtypes = [NotmuchMessageP, c_char_p, POINTER(c_char_p)] + _get_property.restype = c_int + + """notmuch_message_get_properties""" + _get_properties = nmlib.notmuch_message_get_properties + _get_properties.argtypes = [NotmuchMessageP, c_char_p, c_int] + _get_properties.restype = NotmuchMessagePropertiesP + + """notmuch_message_properties_valid""" + _properties_valid = nmlib.notmuch_message_properties_valid + _properties_valid.argtypes = [NotmuchMessagePropertiesP] + _properties_valid.restype = bool + + """notmuch_message_properties_value""" + _properties_value = nmlib.notmuch_message_properties_value + _properties_value.argtypes = [NotmuchMessagePropertiesP] + _properties_value.restype = c_char_p + + """notmuch_message_properties_key""" + _properties_key = nmlib.notmuch_message_properties_key + _properties_key.argtypes = [NotmuchMessagePropertiesP] + _properties_key.restype = c_char_p + + """notmuch_message_properties_move_to_next""" + _properties_move_to_next = nmlib.notmuch_message_properties_move_to_next + _properties_move_to_next.argtypes = [NotmuchMessagePropertiesP] + _properties_move_to_next.restype = None + #Constants: Flags that can be set/get with set_flag FLAG = Enum(['MATCH']) @@ -223,7 +254,7 @@ class Message(Python3StringMixIn): :returns: The header value as string :raises: :exc:`NotInitializedError` if the message is not initialized - :raises: :exc:`NullPointerError` if any error occured + :raises: :exc:`NullPointerError` if any error occurred """ if not self._msg: raise NotInitializedError() @@ -295,7 +326,7 @@ class Message(Python3StringMixIn): :returns: A :class:`Tags` iterator. :raises: :exc:`NotInitializedError` if the message is not initialized - :raises: :exc:`NullPointerError` if any error occured + :raises: :exc:`NullPointerError` if any error occurred """ if not self._msg: raise NotInitializedError() @@ -433,6 +464,53 @@ class Message(Python3StringMixIn): _freeze.argtypes = [NotmuchMessageP] _freeze.restype = c_uint + def get_property(self, prop): + """ Retrieve the value for a single property key + + :param prop: The name of the property to get. + :returns: String with the property value or None if there is no such + key. In the case of multiple values for the given key, the + first one is retrieved. + :raises: :exc:`NotInitializedError` if message has not been + initialized + """ + if not self._msg: + raise NotInitializedError() + + value = c_char_p() + status = Message._get_property(self._msg, _str(prop), byref(value)) + if status != 0: + raise NotmuchError(status) + + return value.value.decode('utf-8') + + def get_properties(self, prop="", exact=False): + """ Get the properties of the message, returning a generator of + name, value pairs. + + The generator will yield once per value. There might be more than one + value on each name, so the generator might yield the same name several + times. + + :param prop: The name of the property to get. Otherwise it will return + the full list of properties of the message. + :param exact: if True, require exact match with key. Otherwise + treat as prefix. + :yields: Each property values as a pair of `name, value` + :ytype: pairs of str + :raises: :exc:`NotInitializedError` if message has not been + initialized + """ + if not self._msg: + raise NotInitializedError() + + properties = Message._get_properties(self._msg, _str(prop), exact) + while Message._properties_valid(properties): + key = Message._properties_key(properties) + value = Message._properties_value(properties) + yield key.decode("utf-8"), value.decode("utf-8") + Message._properties_move_to_next(properties) + def freeze(self): """Freezes the current state of 'message' within the database diff --git a/bindings/python/notmuch/messages.py b/bindings/python/notmuch/messages.py index e17f1507..cae5da50 100644 --- a/bindings/python/notmuch/messages.py +++ b/bindings/python/notmuch/messages.py @@ -100,7 +100,7 @@ class Messages(object): def __init__(self, msgs_p, parent=None): """ :param msgs_p: A pointer to an underlying *notmuch_messages_t* - structure. These are not publically exposed, so a user + structure. These are not publicly exposed, so a user will almost never instantiate a :class:`Messages` object herself. They are usually handed back as a result, e.g. in :meth:`Query.search_messages`. *msgs_p* must be diff --git a/bindings/python/notmuch/tag.py b/bindings/python/notmuch/tag.py index 3b4a56ac..fbb18ce4 100644 --- a/bindings/python/notmuch/tag.py +++ b/bindings/python/notmuch/tag.py @@ -64,7 +64,7 @@ class Tags(Python3StringMixIn): def __init__(self, tags_p, parent=None): """ :param tags_p: A pointer to an underlying *notmuch_tags_t* - structure. These are not publically exposed, so a user + structure. These are not publicly exposed, so a user will almost never instantiate a :class:`Tags` object herself. They are usually handed back as a result, e.g. in :meth:`Database.get_all_tags`. *tags_p* must be diff --git a/bindings/python/notmuch/thread.py b/bindings/python/notmuch/thread.py index ed961885..9aa0e08c 100644 --- a/bindings/python/notmuch/thread.py +++ b/bindings/python/notmuch/thread.py @@ -71,7 +71,7 @@ class Thread(object): def __init__(self, thread_p, parent=None): """ :param thread_p: A pointer to an internal notmuch_thread_t - Structure. These are not publically exposed, so a user + Structure. These are not publicly exposed, so a user will almost never instantiate a :class:`Thread` object herself. They are usually handed back as a result, e.g. when iterating through :class:`Threads`. *thread_p* diff --git a/bindings/python/notmuch/threads.py b/bindings/python/notmuch/threads.py index 86f1f2cc..0c382d5b 100644 --- a/bindings/python/notmuch/threads.py +++ b/bindings/python/notmuch/threads.py @@ -85,7 +85,7 @@ class Threads(Python3StringMixIn): def __init__(self, threads_p, parent=None): """ :param threads_p: A pointer to an underlying *notmuch_threads_t* - structure. These are not publically exposed, so a user + structure. These are not publicly exposed, so a user will almost never instantiate a :class:`Threads` object herself. They are usually handed back as a result, e.g. in :meth:`Query.search_threads`. *threads_p* must be diff --git a/bindings/python/notmuch/version.py b/bindings/python/notmuch/version.py index bc246330..fbb282e3 100644 --- a/bindings/python/notmuch/version.py +++ b/bindings/python/notmuch/version.py @@ -1,3 +1,3 @@ # this file should be kept in sync with ../../../version -__VERSION__ = '0.26' +__VERSION__ = '0.27' SOVERSION = '5' |
