]> git.notmuchmail.org Git - notmuch/blobdiff - bindings/python/notmuch/globals.py
python: add classes to wrap all notmuch_*_t types
[notmuch] / bindings / python / notmuch / globals.py
index 51d2b654e736aa07860776d7fed17b9d9d113cee..36354fcec5ec1cf83ddffca17c4aeeccc898decc 100644 (file)
@@ -17,7 +17,7 @@ along with notmuch.  If not, see <http://www.gnu.org/licenses/>.
 Copyright 2010 Sebastian Spaeth <Sebastian@SSpaeth.de>'
 """
 
-from ctypes import CDLL, c_char_p, c_int
+from ctypes import CDLL, c_char_p, c_int, Structure, POINTER
 from ctypes.util import find_library
 
 #-----------------------------------------------------------------------------
@@ -143,27 +143,32 @@ class NotmuchError(Exception):
 # List of Subclassed exceptions that correspond to STATUS values and are
 # subclasses of NotmuchError.
 class OutOfMemoryError(NotmuchError):
-    pass
+    status = STATUS.OUT_OF_MEMORY
 class ReadOnlyDatabaseError(NotmuchError):
-    pass
+    status = STATUS.READ_ONLY_DATABASE
 class XapianError(NotmuchError):
-    pass
+    status = STATUS.XAPIAN_EXCEPTION
 class FileError(NotmuchError):
-    pass
+    status = STATUS.FILE_ERROR
 class FileNotEmailError(NotmuchError):
-    pass
+    status = STATUS.FILE_NOT_EMAIL
 class DuplicateMessageIdError(NotmuchError):
-    pass
+    status = STATUS.DUPLICATE_MESSAGE_ID
 class NullPointerError(NotmuchError):
-    pass
+    status = STATUS.NULL_POINTER
 class TagTooLongError(NotmuchError):
-    pass
+    status = STATUS.TAG_TOO_LONG
 class UnbalancedFreezeThawError(NotmuchError):
-    pass
+    status = STATUS.UNBALANCED_FREEZE_THAW
 class UnbalancedAtomicError(NotmuchError):
-    pass
+    status = STATUS.UNBALANCED_ATOMIC
 class NotInitializedError(NotmuchError):
-    pass
+    """Derived from NotmuchError, this occurs if the underlying data
+    structure (e.g. database is not initialized (yet) or an iterator has
+    been exhausted. You can test for NotmuchError with .status =
+    STATUS.NOT_INITIALIZED"""
+    status = STATUS.NOT_INITIALIZED
+
 
 
 def _str(value):
@@ -177,3 +182,39 @@ def _str(value):
         return value.encode('UTF-8')
     return value
 
+
+class NotmuchDatabaseS(Structure):
+    pass
+NotmuchDatabaseP = POINTER(NotmuchDatabaseS)
+
+class NotmuchQueryS(Structure):
+    pass
+NotmuchQueryP = POINTER(NotmuchQueryS)
+
+class NotmuchThreadsS(Structure):
+    pass
+NotmuchThreadsP = POINTER(NotmuchThreadsS)
+
+class NotmuchThreadS(Structure):
+    pass
+NotmuchThreadP = POINTER(NotmuchThreadS)
+
+class NotmuchMessagesS(Structure):
+    pass
+NotmuchMessagesP = POINTER(NotmuchMessagesS)
+
+class NotmuchMessageS(Structure):
+    pass
+NotmuchMessageP = POINTER(NotmuchMessageS)
+
+class NotmuchTagsS(Structure):
+    pass
+NotmuchTagsP = POINTER(NotmuchTagsS)
+
+class NotmuchDirectoryS(Structure):
+    pass
+NotmuchDirectoryP = POINTER(NotmuchDirectoryS)
+
+class NotmuchFilenamesS(Structure):
+    pass
+NotmuchFilenamesP = POINTER(NotmuchFilenamesS)