def next(self): if self._threads is None: raise NotmuchError(STATUS.NOT_INITIALIZED) if not nmlib.notmuch_threads_valid(self._threads): self._threads = None raise StopIteration thread = Thread(Threads._get(self._threads), self) nmlib.notmuch_threads_move_to_next(self._threads) return thread
def next(self): if self._threads is None: raise NotmuchError(STATUS.NOT_INITIALIZED) if not nmlib.notmuch_threads_valid(self._threads): self._threads = None raise StopIteration thread = Thread(Threads._get(self._threads), self) nmlib.notmuch_threads_move_to_next(self._threads) return thread
def __len__(self): """len(:class:`Threads`) returns the number of contained Threads .. note:: As this iterates over the threads, we will not be able to iterate over them again! So this will fail:: #THIS FAILS threads = Database().create_query('').search_threads() if len(threads) > 0: #this 'exhausts' threads # next line raises NotmuchError(STATUS.NOT_INITIALIZED)!!! for thread in threads: print thread """ if self._threads is None: raise NotmuchError(STATUS.NOT_INITIALIZED) i = 0 # returns 'bool'. On out-of-memory it returns None while nmlib.notmuch_threads_valid(self._threads): nmlib.notmuch_threads_move_to_next(self._threads) i += 1 # reset self._threads to mark as "exhausted" self._threads = None return i
def __len__(self): """len(:class:`Threads`) returns the number of contained Threads .. note:: As this iterates over the threads, we will not be able to iterate over them again! So this will fail:: #THIS FAILS threads = Database().create_query('').search_threads() if len(threads) > 0: #this 'exhausts' threads # next line raises NotmuchError(STATUS.NOT_INITIALIZED)!!! for thread in threads: print thread """ if self._threads is None: raise NotmuchError(STATUS.NOT_INITIALIZED) i = 0 # returns 'bool'. On out-of-memory it returns None while nmlib.notmuch_threads_valid(self._threads): nmlib.notmuch_threads_move_to_next(self._threads) i += 1 # reset self._threads to mark as "exhausted" self._threads = None return i