From 82e23f1bd72448a1d1bdba953a388ddd1702f7f3 Mon Sep 17 00:00:00 2001 From: Charles Haley <> Date: Tue, 22 Feb 2011 16:55:27 +0000 Subject: [PATCH] Change search to match a tag item X when a user category path @A.X is searched, in addition to the items in category A.X --- src/calibre/library/caches.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/calibre/library/caches.py b/src/calibre/library/caches.py index c25ce1bcce..4f0e3f8d8b 100644 --- a/src/calibre/library/caches.py +++ b/src/calibre/library/caches.py @@ -423,12 +423,22 @@ class ResultCache(SearchQueryParser): # {{{ return res user_cats = self.db_prefs.get('user_categories', []) c = set(candidates) + l = location.rfind('.') + if l > 0: + alt_loc = location[0:l] + alt_item = location[l+1:] for key in user_cats: if key == location or key.startswith(location + '.'): for (item, category, ign) in user_cats[key]: s = self.get_matches(category, '=' + item, candidates=c) c -= s res |= s + elif key == alt_loc: + for (item, category, ign) in user_cats[key]: + if item == alt_item: + s = self.get_matches(category, '=' + item, candidates=c) + c -= s + res |= s if query == 'false': return candidates - res return res