From 4b7575252eb184dff028866ad7d7191df324cdfc Mon Sep 17 00:00:00 2001 From: Charles Haley <> Date: Mon, 14 Mar 2011 10:41:52 +0000 Subject: [PATCH 1/3] #9397: Search Replace error on custom series_index field --- src/calibre/gui2/dialogs/metadata_bulk.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/calibre/gui2/dialogs/metadata_bulk.py b/src/calibre/gui2/dialogs/metadata_bulk.py index d918991aad..9b25545252 100644 --- a/src/calibre/gui2/dialogs/metadata_bulk.py +++ b/src/calibre/gui2/dialogs/metadata_bulk.py @@ -783,6 +783,12 @@ class MetadataBulkDialog(ResizableDialog, Ui_MetadataBulkDialog): books_to_refresh = self.db.set_custom(id, val, label=dfm['label'], extra=extra, commit=False, allow_case_change=True) + elif dest.startswith('#') and dest.endswith('_index'): + label = self.db.field_metadata[dest[:-6]]['label'] + series = self.db.get_custom(id, label=label, index_is_id=True) + books_to_refresh = self.db.set_custom(id, series, label=label, + extra=val, commit=False, + allow_case_change=True) else: if dest == 'comments': setter = self.db.set_comment From 028d2fc04b261db1da9f292c3e6606109f202714 Mon Sep 17 00:00:00 2001 From: Charles Haley <> Date: Mon, 14 Mar 2011 12:19:57 +0000 Subject: [PATCH 2/3] Currently searches for '..X' match only items exactly equal to '.X'. Change to make such a search match that and also any exactly-matching embedded hierarchical components, such as 'A.X' and 'A.X.Z'. This means that one cannot search for *only* '.X' if there is a hierarchical subitem with the name X, but I think this case will be exceedingly rare. --- src/calibre/library/caches.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/calibre/library/caches.py b/src/calibre/library/caches.py index 97ddaeb51a..119a5492e0 100644 --- a/src/calibre/library/caches.py +++ b/src/calibre/library/caches.py @@ -123,14 +123,23 @@ REGEXP_MATCH = 2 def _match(query, value, matchkind): if query.startswith('..'): query = query[1:] - prefix_match_ok = False + sq = query[1:] + internal_match_ok = True else: - prefix_match_ok = True + internal_match_ok = False for t in value: t = icu_lower(t) try: ### ignore regexp exceptions, required because search-ahead tries before typing is finished if (matchkind == EQUALS_MATCH): - if prefix_match_ok and query[0] == '.': + if internal_match_ok: + print query, t + if query == t: + return True + comps = [c.strip() for c in t.split('.') if c.strip()] + for comp in comps: + if sq == comp: + return True + elif query[0] == '.': if t.startswith(query[1:]): ql = len(query) - 1 if (len(t) == ql) or (t[ql:ql+1] == '.'): From 43fe7d047f4eddf457dff1f03b5e3ab2a5b65424 Mon Sep 17 00:00:00 2001 From: Charles Haley <> Date: Mon, 14 Mar 2011 13:02:05 +0000 Subject: [PATCH 3/3] ... --- src/calibre/library/caches.py | 1 - 1 file changed, 1 deletion(-) diff --git a/src/calibre/library/caches.py b/src/calibre/library/caches.py index 119a5492e0..be996063d5 100644 --- a/src/calibre/library/caches.py +++ b/src/calibre/library/caches.py @@ -132,7 +132,6 @@ def _match(query, value, matchkind): try: ### ignore regexp exceptions, required because search-ahead tries before typing is finished if (matchkind == EQUALS_MATCH): if internal_match_ok: - print query, t if query == t: return True comps = [c.strip() for c in t.split('.') if c.strip()]