From df5766f02aae244028590b8274737992932d49e5 Mon Sep 17 00:00:00 2001 From: Charles Haley <> Date: Tue, 25 Jan 2011 23:29:00 +0000 Subject: [PATCH] Another 'right' fix for the multiple user category problem --- src/calibre/library/caches.py | 7 ++++++- src/calibre/library/field_metadata.py | 3 --- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/calibre/library/caches.py b/src/calibre/library/caches.py index af47a79e49..7c935a4320 100644 --- a/src/calibre/library/caches.py +++ b/src/calibre/library/caches.py @@ -424,6 +424,11 @@ class ResultCache(SearchQueryParser): # {{{ if self.db_prefs is None: return res user_cats = self.db_prefs.get('user_categories', []) + # translate the case of the location + for loc in user_cats: + if location == icu_lower(loc): + location = loc + break if location not in user_cats: return res c = set(candidates) @@ -445,7 +450,7 @@ class ResultCache(SearchQueryParser): # {{{ if query and query.strip(): # get metadata key associated with the search term. Eliminates # dealing with plurals and other aliases - location = self.field_metadata.search_term_to_field_key(location.lower().strip()) + location = self.field_metadata.search_term_to_field_key(icu_lower(location.strip())) if isinstance(location, list): if allow_recursion: for loc in location: diff --git a/src/calibre/library/field_metadata.py b/src/calibre/library/field_metadata.py index c8706f2137..224b6aa79f 100644 --- a/src/calibre/library/field_metadata.py +++ b/src/calibre/library/field_metadata.py @@ -7,7 +7,6 @@ import copy from calibre.utils.ordered_dict import OrderedDict from calibre.utils.config import tweaks -from calibre.utils.icu import lower class TagsIcons(dict): ''' @@ -485,7 +484,6 @@ class FieldMetadata(dict): return self._tb_cats[key]['rec_index'] + 1 def add_user_category(self, label, name): - label = lower(label) if label in self._tb_cats: raise ValueError('Duplicate user field [%s]'%(label)) self._tb_cats[label] = {'table':None, 'column':None, @@ -525,7 +523,6 @@ class FieldMetadata(dict): def _add_search_terms_to_map(self, key, terms): if terms is not None: for t in terms: - t = t.lower() if t in self._search_term_map: raise ValueError('Attempt to add duplicate search term "%s"'%t) self._search_term_map[t] = key