X-Git-Url: https://git.notmuchmail.org/git?p=notmuch;a=blobdiff_plain;f=bindings%2Fpython%2Fnotmuch%2Fdatabase.py;h=6238b2891e066cf76a9361fc573509a287851124;hp=93183687a4259c8aebe391ccb342c4b577493366;hb=8015cbff263606f009b5750d23b28ee332c25db8;hpb=4ed0362d41e62d5254be6cfb46e0c0c9fd9de0a0 diff --git a/bindings/python/notmuch/database.py b/bindings/python/notmuch/database.py index 93183687..6238b289 100644 --- a/bindings/python/notmuch/database.py +++ b/bindings/python/notmuch/database.py @@ -168,7 +168,7 @@ class Database(object): 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 @@ -188,7 +188,7 @@ class Database(object): """ 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 @@ -430,7 +430,7 @@ class Database(object): removed. """ self._assert_db_is_initialized() - return self._remove_message(self._db, filename) + return self._remove_message(self._db, _str(filename)) def find_message(self, msgid): """Returns a :class:`Message` as identified by its message ID @@ -651,7 +651,7 @@ class Query(object): 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 @@ -685,7 +685,7 @@ class Query(object): 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) @@ -699,7 +699,7 @@ class Query(object): 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) @@ -765,7 +765,7 @@ class Directory(object): 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): @@ -925,17 +925,18 @@ class Filenames(object): _move_to_next.argtypes = [NotmuchFilenamesP] _move_to_next.restype = None - def next(self): - if self._files_p is None: + def __next__(self): + if not self._files_p: raise NotmuchError(STATUS.NOT_INITIALIZED) if not self._valid(self._files_p): self._files_p = None raise StopIteration - file = Filenames._get(self._files_p) + file_ = Filenames._get(self._files_p) self._move_to_next(self._files_p) - return file + return file_.decode('utf-8', 'ignore') + next = __next__ # python2.x iterator protocol compatibility def __len__(self): """len(:class:`Filenames`) returns the number of contained files @@ -952,7 +953,7 @@ class Filenames(object): # 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