X-Git-Url: https://git.notmuchmail.org/git?a=blobdiff_plain;f=bindings%2Fpython%2Fnotmuch%2Fthreads.py;h=d2e0a910e5794d3bf5b183dc436dfcd38a4005b9;hb=e9bcbe7e70d0811f11e58466735b2bf7c8f0a3fc;hp=9d305e23423418fe26a0c2bc9c2beea93692176e;hpb=76a2db3d7b92bc1a8be75f673dc384c46cf02fab;p=notmuch
diff --git a/bindings/python/notmuch/threads.py b/bindings/python/notmuch/threads.py
index 9d305e23..d2e0a910 100644
--- a/bindings/python/notmuch/threads.py
+++ b/bindings/python/notmuch/threads.py
@@ -14,17 +14,19 @@ for more details.
You should have received a copy of the GNU General Public License
along with notmuch. If not, see .
-Copyright 2010 Sebastian Spaeth '
+Copyright 2010 Sebastian Spaeth
"""
from notmuch.globals import (
nmlib,
Python3StringMixIn,
- NullPointerError,
- NotInitializedError,
NotmuchThreadP,
NotmuchThreadsP,
)
+from .errors import (
+ NullPointerError,
+ NotInitializedError,
+)
from .thread import Thread
class Threads(Python3StringMixIn):
@@ -155,24 +157,21 @@ class Threads(Python3StringMixIn):
return i
def __nonzero__(self):
- """Check if :class:`Threads` contains at least one more valid thread
-
- The existence of this function makes 'if Threads: foo' work, as
- that will implicitely call len() exhausting the iterator if
- __nonzero__ does not exist. This function makes `bool(Threads())`
- work repeatedly.
+ '''
+ Implement truth value testing. If __nonzero__ is not
+ implemented, the python runtime would fall back to `len(..) >
+ 0` thus exhausting the iterator.
- :return: True if there is at least one more thread in the
- Iterator, False if not. None on a "Out-of-memory" error.
- """
- return self._threads is not None and \
- self._valid(self._threads) > 0
+ :returns: True if the wrapped iterator has at least one more object
+ left.
+ '''
+ return self._threads and self._valid(self._threads)
_destroy = nmlib.notmuch_threads_destroy
_destroy.argtypes = [NotmuchThreadsP]
- _destroy.argtypes = None
+ _destroy.restype = None
def __del__(self):
"""Close and free the notmuch Threads"""
- if self._threads is not None:
+ if self._threads:
self._destroy(self._threads)