diff --git a/src/calibre/library/caches.py b/src/calibre/library/caches.py index a31a8a846c..ee19f07644 100644 --- a/src/calibre/library/caches.py +++ b/src/calibre/library/caches.py @@ -155,7 +155,9 @@ class ResultCache(SearchQueryParser): self._map = self._map_filtered = self._data = [] self.first_sort = True self.search_restriction = '' - SearchQueryParser.__init__(self, [c for c in cc_label_map]) + SearchQueryParser.__init__(self, + locations=SearchQueryParser.DEFAULT_LOCATIONS + + [c for c in cc_label_map]) self.build_relop_dict() def build_relop_dict(self): diff --git a/src/calibre/utils/search_query_parser.py b/src/calibre/utils/search_query_parser.py index 6768b66063..79324e6b8b 100644 --- a/src/calibre/utils/search_query_parser.py +++ b/src/calibre/utils/search_query_parser.py @@ -73,7 +73,7 @@ class SearchQueryParser(object): When no operator is specified between two tokens, `and` is assumed. Each token is a string of the form `location:query`. `location` is a string - from :member:`LOCATIONS`. It is optional. If it is omitted, it is assumed to + from :member:`DEFAULT_LOCATIONS`. It is optional. If it is omitted, it is assumed to be `all`. `query` is an arbitrary string that must not contain parentheses. If it contains whitespace, it should be quoted by enclosing it in `"` marks. @@ -86,7 +86,7 @@ class SearchQueryParser(object): * `(author:Asimov or author:Hardy) and not tag:read` [search for unread books by Asimov or Hardy] ''' - LOCATIONS = [ + DEFAULT_LOCATIONS = [ 'tag', 'title', 'author', @@ -116,10 +116,13 @@ class SearchQueryParser(object): failed.append(test[0]) return failed - def __init__(self, custcols=[], test=False): + def __init__(self, locations=None, test=False): + if locations is None: + locations = self.DEFAULT_LOCATIONS self._tests_failed = False # Define a token - standard_locations = map(lambda x : CaselessLiteral(x)+Suppress(':'), self.LOCATIONS+custcols) + standard_locations = map(lambda x : CaselessLiteral(x)+Suppress(':'), + locations) location = NoMatch() for l in standard_locations: location |= l @@ -228,7 +231,7 @@ class SearchQueryParser(object): ''' Should return the set of matches for :param:'location` and :param:`query`. - :param:`location` is one of the items in :member:`SearchQueryParser.LOCATIONS`. + :param:`location` is one of the items in :member:`SearchQueryParser.DEFAULT_LOCATIONS`. :param:`query` is a string literal. ''' return set([]) diff --git a/src/calibre/web/feeds/recipes/model.py b/src/calibre/web/feeds/recipes/model.py index 55ff51d1e9..4eea0ce80c 100644 --- a/src/calibre/web/feeds/recipes/model.py +++ b/src/calibre/web/feeds/recipes/model.py @@ -121,7 +121,7 @@ class RecipeModel(QAbstractItemModel, SearchQueryParser): def __init__(self, db, *args): QAbstractItemModel.__init__(self, *args) - SearchQueryParser.__init__(self) + SearchQueryParser.__init__(self, locations=['all']) self.db = db self.default_icon = QVariant(QIcon(I('news.svg'))) self.custom_icon = QVariant(QIcon(I('user_profile.svg')))