1 from ctypes import CDLL, c_char_p, c_int
2 #package-global instance of the notmuch library
3 #TODO: lazy load this on first access?
4 nmlib = CDLL('/usr/local/lib/libnotmuch.so')
13 DUPLICATE_MESSAGE_ID = 6
16 UNBALANCED_FREEZE_THAW = 9
19 """Get a string representation of a notmuch_status_t value."""
20 status2str = nmlib.notmuch_status_to_string
21 status2str.restype = c_char_p
22 status2str.argtypes = [c_int]
24 def __init__(self, status):
28 """Get a string representation of a notmuch_status_t value."""
29 return str(STATUS.status2str(self._status))
31 class NotmuchError(Exception):
32 def __init__(self, status=None, message=None):
33 """Is initiated with a (notmuch.STATUS[,message=None])"""
34 super(NotmuchError, self).__init__(message, status)
37 if self.args[0] is not None: return self.args[0]
38 else: return str(STATUS(self.args[1]))