From b1357eae0c1aa445913aed4c346b5c2ee75489b2 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sat, 28 Mar 2009 18:08:30 -0700 Subject: [PATCH] IGN:Fix minor bug in advanced search dialog if only a none term is specified --- src/calibre/gui2/dialogs/search.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/calibre/gui2/dialogs/search.py b/src/calibre/gui2/dialogs/search.py index 403bb7f287..caf5fc6997 100644 --- a/src/calibre/gui2/dialogs/search.py +++ b/src/calibre/gui2/dialogs/search.py @@ -6,13 +6,13 @@ from PyQt4.QtGui import QDialog from calibre.gui2.dialogs.search_ui import Ui_Dialog from calibre.gui2 import qstring_to_unicode - + class SearchDialog(QDialog, Ui_Dialog): - + def __init__(self, *args): QDialog.__init__(self, *args) self.setupUi(self) - + def tokens(self, raw): phrases = re.findall(r'\s+".*?"\s+', raw) for f in phrases: @@ -20,7 +20,8 @@ class SearchDialog(QDialog, Ui_Dialog): return [t.strip() for t in phrases + raw.split()] def search_string(self): - all, any, phrase, none = map(lambda x: unicode(x.text()), (self.all, self.any, self.phrase, self.none)) + all, any, phrase, none = map(lambda x: unicode(x.text()), + (self.all, self.any, self.phrase, self.none)) all, any, none = map(self.tokens, (all, any, none)) phrase = phrase.strip() all = ' and '.join(all) @@ -32,11 +33,11 @@ class SearchDialog(QDialog, Ui_Dialog): if all: ans += (' and ' if ans else '') + all if none: - ans += (' and not ' if ans else '') + none + ans += (' and not ' if ans else 'not') + none if any: ans += (' or ' if ans else '') + any return ans - + def token(self): txt = qstring_to_unicode(self.text.text()).strip() if txt: @@ -46,4 +47,4 @@ class SearchDialog(QDialog, Ui_Dialog): if re.search(r'\s', tok): tok = '"%s"'%tok return tok - +