mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-06-23 15:30:45 -04:00
Don't search tags when the expression is unprefixed. Some performance improvements and defensive code.
This commit is contained in:
parent
352ee20933
commit
6001342b32
@ -1136,7 +1136,7 @@ class OnDeviceSearch(SearchQueryParser): # {{{
|
|||||||
if location not in self.USABLE_LOCATIONS:
|
if location not in self.USABLE_LOCATIONS:
|
||||||
return set([])
|
return set([])
|
||||||
matches = set([])
|
matches = set([])
|
||||||
all_locs = set(self.USABLE_LOCATIONS) - set(['all'])
|
all_locs = set(self.USABLE_LOCATIONS) - set(['all', 'tags'])
|
||||||
locations = all_locs if location == 'all' else [location]
|
locations = all_locs if location == 'all' else [location]
|
||||||
q = {
|
q = {
|
||||||
'title' : lambda x : getattr(x, 'title').lower(),
|
'title' : lambda x : getattr(x, 'title').lower(),
|
||||||
@ -1144,7 +1144,7 @@ class OnDeviceSearch(SearchQueryParser): # {{{
|
|||||||
'collections':lambda x: ','.join(getattr(x, 'device_collections')).lower(),
|
'collections':lambda x: ','.join(getattr(x, 'device_collections')).lower(),
|
||||||
'format':lambda x: os.path.splitext(x.path)[1].lower(),
|
'format':lambda x: os.path.splitext(x.path)[1].lower(),
|
||||||
'inlibrary':lambda x : getattr(x, 'in_library'),
|
'inlibrary':lambda x : getattr(x, 'in_library'),
|
||||||
'tags':lambda x : getattr(x, 'tags')
|
'tags':lambda x : getattr(x, 'tags', [])
|
||||||
}
|
}
|
||||||
for x in ('author', 'format'):
|
for x in ('author', 'format'):
|
||||||
q[x+'s'] = q[x]
|
q[x+'s'] = q[x]
|
||||||
@ -1172,11 +1172,10 @@ class OnDeviceSearch(SearchQueryParser): # {{{
|
|||||||
m = matchkind
|
m = matchkind
|
||||||
|
|
||||||
vals = accessor(row)
|
vals = accessor(row)
|
||||||
if not isinstance(vals, list):
|
if vals is None:
|
||||||
if locvalue == 'collections':
|
vals = ''
|
||||||
vals = accessor(row).split(',')
|
if isinstance(vals, basestring):
|
||||||
else:
|
vals = vals.split(',') if locvalue == 'collections' else [vals]
|
||||||
vals = [accessor(row)]
|
|
||||||
if _match(query, vals, m, use_primary_find_in_search=upf):
|
if _match(query, vals, m, use_primary_find_in_search=upf):
|
||||||
matches.add(index)
|
matches.add(index)
|
||||||
break
|
break
|
||||||
|
Loading…
x
Reference in New Issue
Block a user