def next(self): if self._files_p is None: raise NotmuchError(STATUS.NOT_INITIALIZED) if not nmlib.notmuch_filenames_valid(self._files_p): self._files_p = None raise StopIteration file = Filenames._get (self._files_p) nmlib.notmuch_filenames_move_to_next(self._files_p) return file
def next(self): if self._files_p is None: raise NotmuchError(STATUS.NOT_INITIALIZED) if not nmlib.notmuch_filenames_valid(self._files_p): self._files_p = None raise StopIteration file = Filenames._get(self._files_p) nmlib.notmuch_filenames_move_to_next(self._files_p) return file
def as_generator(self): """Return generator of Filenames This is the main function that will usually be used by the user.""" if self._files is None: raise NotmuchError(STATUS.NOT_INITIALIZED) while nmlib.notmuch_filenames_valid(self._files): yield Filenames._get(self._files) nmlib.notmuch_filenames_move_to_next(self._files) self._files = None
def __len__(self): """len(:class:`Filenames`) returns the number of contained files .. note:: As this iterates over the files, we will not be able to iterate over them again! So this will fail:: #THIS FAILS files = Database().get_directory('').get_child_files() if len(files) > 0: #this 'exhausts' msgs # next line raises NotmuchError(STATUS.NOT_INITIALIZED)!!! for file in files: print file """ if self._files_p is None: raise NotmuchError(STATUS.NOT_INITIALIZED) i=0 while nmlib.notmuch_filenames_valid(self._files_p): nmlib.notmuch_filenames_move_to_next(self._files_p) i += 1 self._files_p = None return i
def __len__(self): """len(:class:`Filenames`) returns the number of contained files .. note:: As this iterates over the files, we will not be able to iterate over them again! So this will fail:: #THIS FAILS files = Database().get_directory('').get_child_files() if len(files) > 0: #this 'exhausts' msgs # next line raises NotmuchError(:attr:`STATUS`.NOT_INITIALIZED)!!! for file in files: print file """ if self._files_p is None: raise NotmuchError(STATUS.NOT_INITIALIZED) i = 0 while nmlib.notmuch_filenames_valid(self._files_p): nmlib.notmuch_filenames_move_to_next(self._files_p) i += 1 self._files_p = None return i