Store: comments.

This commit is contained in:
John Schember 2011-04-19 07:27:00 -04:00
parent 9c09756b1c
commit 094d09c61a

View File

@ -314,11 +314,14 @@ class SearchThread(Thread):
def _clean_query(self, query):
query = query.lower()
# Remove the prefix.
for loc in ( 'all', 'author', 'authors', 'title'):
query = re.sub(r'%s:"?(?P<a>[^\s"]+)"?' % loc, '\g<a>', query)
# Remove the prefix and search text.
for loc in ('cover', 'drm', 'format', 'formats', 'price', 'store'):
query = re.sub(r'%s:"[^"]"' % loc, '', query)
query = re.sub(r'%s:[^\s]*' % loc, '', query)
# Remove control modifiers.
query = re.sub(r'(^|\s)(and|not|or)(\s|$)', ' ', query)
query = query.replace('\\', '')
query = query.replace('!', '')
@ -326,6 +329,7 @@ class SearchThread(Thread):
query = query.replace('~', '')
query = query.replace('>', '')
query = query.replace('<', '')
# Remove excess whitespace.
query = re.sub(r'\s{2,}', ' ', query)
return query