From 62d5c99297b518dec3b65ba680db655ea7ed528f Mon Sep 17 00:00:00 2001 From: Charles Haley <> Date: Wed, 4 Jul 2012 20:10:53 +0200 Subject: [PATCH] Make contains searches be more forgiving about accents. --- src/calibre/library/caches.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/calibre/library/caches.py b/src/calibre/library/caches.py index 191ac53f94..998c21c50c 100644 --- a/src/calibre/library/caches.py +++ b/src/calibre/library/caches.py @@ -20,6 +20,7 @@ from calibre.utils.localization import (canonicalize_lang, lang_map, get_udc, from calibre.ebooks.metadata import title_sort, author_to_author_sort from calibre.ebooks.metadata.opf2 import metadata_to_opf from calibre import prints +from calibre.utils.icu import primary_find class MetadataBackup(Thread): # {{{ ''' @@ -147,9 +148,10 @@ def _match(query, value, matchkind): return True elif query == t: return True - elif ((matchkind == REGEXP_MATCH and re.search(query, t, re.I|re.UNICODE)) or ### search unanchored - (matchkind == CONTAINS_MATCH and query in t)): - return True + elif matchkind == REGEXP_MATCH: + return re.search(query, t, re.I|re.UNICODE) + elif matchkind == CONTAINS_MATCH: + return primary_find(query, t)[0] != -1 except re.error: pass return False