diff options
Diffstat (limited to 'alot/db/manager.py')
-rw-r--r-- | alot/db/manager.py | 19 |
1 files changed, 5 insertions, 14 deletions
diff --git a/alot/db/manager.py b/alot/db/manager.py index c4ec02d1..e57af181 100644 --- a/alot/db/manager.py +++ b/alot/db/manager.py @@ -14,6 +14,7 @@ from notmuch2 import Database, NotmuchError from .errors import DatabaseError from .errors import DatabaseROError from .errors import NonexistantObjectError +from .sort import ORDER from .thread import Thread from ..settings.const import settings @@ -116,12 +117,6 @@ class DBManager: lets you look up threads and messages directly to the persistent wrapper classes. """ - _sort_orders = { - 'oldest_first': Database.SORT.OLDEST_FIRST, - 'newest_first': Database.SORT.NEWEST_FIRST, - 'unsorted': Database.SORT.UNSORTED, - 'message_id': Database.SORT.MESSAGE_ID, - } """constants representing sort orders""" _loop = None @@ -202,25 +197,21 @@ class DBManager: queries = filter(lambda k: k.startswith(q_prefix), db.config) return { q[len(q_prefix):] : db.config[q] for q in queries } - def get_threads(self, querystring, sort='newest_first', exclude_tags = frozenset()): + def get_threads(self, querystring, sort = ORDER.NEWEST_FIRST, + exclude_tags = frozenset()): """ asynchronously look up thread ids matching `querystring`. :param querystring: The query string to use for the lookup :type querystring: str. - :param sort: Sort order. one of ['oldest_first', 'newest_first', - 'message_id', 'unsorted'] - :type query: str + :param sort: Sort order. + :type query: alot.db.sort.ORDER :param exclude_tags: Tags to exclude by default unless included in the search :type exclude_tags: set of str :returns: iterator over thread ids """ - # TODO: use a symbolic constant for this - assert sort in self._sort_orders - with self._db_ro() as db: - sort = self._sort_orders[sort] exclude_tags = self._exclude_tags | exclude_tags for t in db.threads(querystring, sort = sort, exclude_tags = exclude_tags): |