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
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):
file_ = Filenames._get(self._files_p)
self._move_to_next(self._files_p)
- return file_.decode('utf-8', errors='ignore')
+ return file_.decode('utf-8', 'ignore')
next = __next__ # python2.x iterator protocol compatibility
def __len__(self):
# 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