"""
import os
-from ctypes import c_int, c_char_p, c_void_p, c_uint, c_long, byref, POINTER
+from ctypes import c_char_p, c_void_p, c_uint, c_long, byref, POINTER
from notmuch.globals import (nmlib, STATUS, NotmuchError, NotInitializedError,
- NullPointerError, OutOfMemoryError, XapianError, Enum, _str,
+ NullPointerError, Enum, _str,
NotmuchDatabaseP, NotmuchDirectoryP, NotmuchMessageP, NotmuchTagsP,
NotmuchQueryP, NotmuchMessagesP, NotmuchThreadsP, NotmuchFilenamesP)
from notmuch.thread import Threads
res = Database._create(_str(path), Database.MODE.READ_WRITE)
- if res is None:
+ if not res:
raise NotmuchError(
message="Could not create the specified database")
self._db = res
"""
res = Database._open(_str(path), mode)
- if res is None:
+ if not res:
raise NotmuchError(message="Could not open the specified database")
self._db = res
be added.
"""
self._assert_db_is_initialized()
- msg_p = c_void_p()
+ msg_p = NotmuchMessageP()
status = self._add_message(self._db, _str(filename), byref(msg_p))
if not status in [STATUS.SUCCESS, STATUS.DUPLICATE_MESSAGE_ID]:
the database was not intitialized.
"""
self._assert_db_is_initialized()
- msg_p = c_void_p()
+ msg_p = NotmuchMessageP()
status = Database._find_message(self._db, _str(msgid), byref(msg_p))
if status != STATUS.SUCCESS:
raise NotmuchError(status)
*Added in notmuch 0.9*"""
self._assert_db_is_initialized()
- msg_p = c_void_p()
+ msg_p = NotmuchMessageP()
status = Database._find_message_by_filename(self._db, _str(filename),
byref(msg_p))
if status != STATUS.SUCCESS:
self._db = db
# create query, return None if too little mem available
query_p = Query._create(db.db_p, _str(querystr))
- if query_p is None:
+ if not query_p:
raise NullPointerError
self._query = query_p
self._assert_query_is_initialized()
threads_p = Query._search_threads(self._query)
- if threads_p is None:
+ if not threads_p:
raise NullPointerError
return Threads(threads_p, self)
self._assert_query_is_initialized()
msgs_p = Query._search_messages(self._query)
- if msgs_p is None:
+ if not msgs_p:
raise NullPointerError
return Messages(msgs_p, self)
def _assert_dir_is_initialized(self):
"""Raises a NotmuchError(:attr:`STATUS`.NOT_INITIALIZED)
if dir_p is None"""
- if self._dir_p is None:
+ if not self._dir_p:
raise NotmuchError(STATUS.NOT_INITIALIZED)
def __init__(self, path, dir_p, parent):
_move_to_next.restype = None
def next(self):
- if self._files_p is None:
+ if not self._files_p:
raise NotmuchError(STATUS.NOT_INITIALIZED)
if not self._valid(self._files_p):
# NotmuchError(:attr:`STATUS`.NOT_INITIALIZED)
for file in files: print file
"""
- if self._files_p is None:
+ if not self._files_p:
raise NotmuchError(STATUS.NOT_INITIALIZED)
i = 0