From e910505e4e29ce57fff33be3fa24792bb79d84c9 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 21 Apr 2011 09:31:19 -0600 Subject: [PATCH] Fix search parsing broken on windows, though I have no idea why it broke --- src/calibre/utils/search_query_parser.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/calibre/utils/search_query_parser.py b/src/calibre/utils/search_query_parser.py index a50ca20fc1..3c41498107 100644 --- a/src/calibre/utils/search_query_parser.py +++ b/src/calibre/utils/search_query_parser.py @@ -16,14 +16,14 @@ methods :method:`SearchQueryParser.universal_set` and If this module is run, it will perform a series of unit tests. ''' -import sys, string, operator +import sys, operator from calibre.utils.pyparsing import CaselessKeyword, Group, Forward, \ CharsNotIn, Suppress, OneOrMore, MatchFirst, CaselessLiteral, \ Optional, NoMatch, ParseException, QuotedString from calibre.constants import preferred_encoding from calibre.utils.icu import sort_key - +from calibre import prints ''' @@ -109,7 +109,7 @@ class SearchQueryParser(object): def run_tests(parser, result, tests): failed = [] for test in tests: - print '\tTesting:', test[0], + prints('\tTesting:', test[0], end=' ') res = parser.parseString(test[0]) if list(res.get(result, None)) == test[1]: print 'OK' @@ -134,7 +134,7 @@ class SearchQueryParser(object): for l in standard_locations: location |= l location = Optional(location, default='all') - word_query = CharsNotIn(string.whitespace + '()') + word_query = CharsNotIn(u'\t\r\n\u00a0 ' + u'()') #quoted_query = Suppress('"')+CharsNotIn('"')+Suppress('"') quoted_query = QuotedString('"', escChar='\\') query = quoted_query | word_query @@ -617,7 +617,7 @@ class Tester(SearchQueryParser): def run_tests(self): failed = [] for query in self.tests.keys(): - print 'Testing query:', query, + prints('Testing query:', query, end=' ') res = self.parse(query) if res != self.tests[query]: print 'FAILED', 'Expected:', self.tests[query], 'Got:', res