From f38000ac9df536dcaa9d9b35d0c347c72b5a6d93 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 8 Mar 2011 11:54:44 -0700 Subject: [PATCH 1/7] ... --- src/calibre/library/caches.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/calibre/library/caches.py b/src/calibre/library/caches.py index 943e414c1a..d9ff43a67c 100644 --- a/src/calibre/library/caches.py +++ b/src/calibre/library/caches.py @@ -6,7 +6,7 @@ __license__ = 'GPL v3' __copyright__ = '2010, Kovid Goyal ' __docformat__ = 'restructuredtext en' -import re, itertools, time, traceback, copy +import re, itertools, time, traceback from itertools import repeat, izip from datetime import timedelta from threading import Thread @@ -790,7 +790,7 @@ class ResultCache(SearchQueryParser): # {{{ # Simple list. Make it a dict of string 'true' self.marked_ids_dict = dict(izip(id_dict, repeat(u'true'))) else: - self.marked_ids_dict = copy.copy(id_dict) + self.marked_ids_dict = id_dict.copy() # Ensure that all the items in the dict are text for id_,val in self.marked_ids_dict.iteritems(): self.marked_ids_dict[id_] = unicode(val) From 1b5a67bd49bef0b14a50c867ffeea29fc2adf96a Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 8 Mar 2011 11:55:46 -0700 Subject: [PATCH 2/7] ... --- src/calibre/library/caches.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/calibre/library/caches.py b/src/calibre/library/caches.py index d9ff43a67c..acd3b78d68 100644 --- a/src/calibre/library/caches.py +++ b/src/calibre/library/caches.py @@ -7,7 +7,7 @@ __copyright__ = '2010, Kovid Goyal ' __docformat__ = 'restructuredtext en' import re, itertools, time, traceback -from itertools import repeat, izip +from itertools import repeat from datetime import timedelta from threading import Thread @@ -788,7 +788,7 @@ class ResultCache(SearchQueryParser): # {{{ ''' if not hasattr(id_dict, 'items'): # Simple list. Make it a dict of string 'true' - self.marked_ids_dict = dict(izip(id_dict, repeat(u'true'))) + self.marked_ids_dict = dict.fromkeys(id_dict, u'true') else: self.marked_ids_dict = id_dict.copy() # Ensure that all the items in the dict are text From ca177e071bdba628c2a834178b7bf5f5a995e2e4 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 8 Mar 2011 11:58:44 -0700 Subject: [PATCH 3/7] ... --- src/calibre/library/caches.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/calibre/library/caches.py b/src/calibre/library/caches.py index acd3b78d68..76f5200f21 100644 --- a/src/calibre/library/caches.py +++ b/src/calibre/library/caches.py @@ -790,9 +790,9 @@ class ResultCache(SearchQueryParser): # {{{ # Simple list. Make it a dict of string 'true' self.marked_ids_dict = dict.fromkeys(id_dict, u'true') else: - self.marked_ids_dict = id_dict.copy() # Ensure that all the items in the dict are text - for id_,val in self.marked_ids_dict.iteritems(): + self.marked_ids_dict = {} + for id_, val in id_dict.iteritems(): self.marked_ids_dict[id_] = unicode(val) # Set the values in the cache From 9f138f31fc005d293c6ab1873e0d115c54e15d64 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 8 Mar 2011 12:02:52 -0700 Subject: [PATCH 4/7] ... --- src/calibre/library/caches.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/calibre/library/caches.py b/src/calibre/library/caches.py index 76f5200f21..397f9bb403 100644 --- a/src/calibre/library/caches.py +++ b/src/calibre/library/caches.py @@ -779,9 +779,10 @@ class ResultCache(SearchQueryParser): # {{{ def set_marked_ids(self, id_dict): ''' ids in id_dict are "marked". They can be searched for by - using the search term ``marked:true`` + using the search term ``marked:true``. Pass in an empty dictionary or + set to clear marked ids. - :param id_dict: Either a dictionary mapping ids to values or a sequence + :param id_dict: Either a dictionary mapping ids to values or a set of ids. In the latter case, the value is set to 'true' for all ids. If a mapping is provided, then the search can be used to search for particular values: ``marked:value`` From 2c20826122a8692fd80f1eb3bc9d5ff09bec2d5a Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 8 Mar 2011 12:11:33 -0700 Subject: [PATCH 5/7] Fix set_marked not clearing previously marked ids --- src/calibre/library/caches.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/calibre/library/caches.py b/src/calibre/library/caches.py index 397f9bb403..63920c5dc9 100644 --- a/src/calibre/library/caches.py +++ b/src/calibre/library/caches.py @@ -798,7 +798,10 @@ class ResultCache(SearchQueryParser): # {{{ # Set the values in the cache marked_col = self.FIELD_MAP['marked'] - for id_,val in self.marked_ids_dict.iteritems(): + for id_ in self.iterallids(): + self._data[id_][marked_col] = None + + for id_, val in self.marked_ids_dict.iteritems(): try: self._data[id_][marked_col] = val except: From 25b9d4c118531df0bf49d376a5a00260d3f9a056 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 8 Mar 2011 12:15:34 -0700 Subject: [PATCH 6/7] ... --- src/calibre/library/caches.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/calibre/library/caches.py b/src/calibre/library/caches.py index 63920c5dc9..f27e15a74b 100644 --- a/src/calibre/library/caches.py +++ b/src/calibre/library/caches.py @@ -798,8 +798,8 @@ class ResultCache(SearchQueryParser): # {{{ # Set the values in the cache marked_col = self.FIELD_MAP['marked'] - for id_ in self.iterallids(): - self._data[id_][marked_col] = None + for r in self.iterall(): + r[marked_col] = None for id_, val in self.marked_ids_dict.iteritems(): try: From 8580338d8c99f0167a30cdc81cf26df506bb9ba6 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 8 Mar 2011 12:25:02 -0700 Subject: [PATCH 7/7] ... --- src/calibre/library/caches.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/calibre/library/caches.py b/src/calibre/library/caches.py index f27e15a74b..21a2622f33 100644 --- a/src/calibre/library/caches.py +++ b/src/calibre/library/caches.py @@ -7,7 +7,7 @@ __copyright__ = '2010, Kovid Goyal ' __docformat__ = 'restructuredtext en' import re, itertools, time, traceback -from itertools import repeat +from itertools import repeat, izip, imap from datetime import timedelta from threading import Thread @@ -792,9 +792,8 @@ class ResultCache(SearchQueryParser): # {{{ self.marked_ids_dict = dict.fromkeys(id_dict, u'true') else: # Ensure that all the items in the dict are text - self.marked_ids_dict = {} - for id_, val in id_dict.iteritems(): - self.marked_ids_dict[id_] = unicode(val) + self.marked_ids_dict = dict(izip(id_dict.iterkeys(), imap(unicode, + id_dict.itervalues()))) # Set the values in the cache marked_col = self.FIELD_MAP['marked']