Added doc for unread method in mail/__init__/py + make sure that db is closed before deleting the notmuch db object

This commit is contained in:
Matthieu Coudron 2014-12-19 14:31:10 +01:00
parent cb80f133d7
commit a480701ee6
2 changed files with 7 additions and 1 deletions

View File

@ -43,6 +43,10 @@ class Mail(IntervalModule):
pass pass
def run(self): def run(self):
"""
Returns the sum of unread messages across all registered backends
"""
unread = sum(map(lambda backend: backend.unread, self.backends)) unread = sum(map(lambda backend: backend.unread, self.backends))
if not unread: if not unread:

View File

@ -38,7 +38,9 @@ class Notmuch(Backend):
@property @property
def unread(self): def unread(self):
db = notmuch.Database(self.db_path) db = notmuch.Database(self.db_path)
return notmuch.Query(db, "tag:unread and tag:inbox").count_messages() result = notmuch.Query(db, "tag:unread and tag:inbox").count_messages()
db.close()
return result
Backend = Notmuch Backend = Notmuch