From 57ab9f1ba027eceec12a60bfe7632eb0cd710fe9 Mon Sep 17 00:00:00 2001 From: Charles Haley <> Date: Fri, 21 May 2010 11:30:05 +0100 Subject: [PATCH 1/4] sony driver: fix missing mime attribute when adding a new book --- src/calibre/devices/prs505/sony_cache.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/calibre/devices/prs505/sony_cache.py b/src/calibre/devices/prs505/sony_cache.py index 64f82e2b76..f87bcf89d3 100644 --- a/src/calibre/devices/prs505/sony_cache.py +++ b/src/calibre/devices/prs505/sony_cache.py @@ -428,8 +428,8 @@ class XMLCache(object): mime = MIME_MAP.get(ext, None) if mime is None: mime = guess_type('a.'+ext)[0] - if mime is not None: - record.set('mime', mime) + if mime is not None: + record.set('mime', mime) if 'sourceid' not in record.attrib: record.set('sourceid', '1') if 'id' not in record.attrib: From 330de1cc7be73f0ba69eba3362a36395b80249d0 Mon Sep 17 00:00:00 2001 From: Charles Haley <> Date: Fri, 21 May 2010 12:02:18 +0100 Subject: [PATCH 2/4] Fix searching on devices to not fail when using non-located searches (bare words). --- src/calibre/gui2/library/models.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/calibre/gui2/library/models.py b/src/calibre/gui2/library/models.py index e3dc5eed48..e234002a9c 100644 --- a/src/calibre/gui2/library/models.py +++ b/src/calibre/gui2/library/models.py @@ -734,8 +734,6 @@ class OnDeviceSearch(SearchQueryParser): # {{{ 'title', 'author', 'format', - 'search', - 'date', 'all', ] @@ -867,6 +865,7 @@ class DeviceBooksModel(BooksModel): # {{{ def search(self, text, refinement, reset=True): + traceback.print_stack() if not text or not text.strip(): self.map = list(range(len(self.db))) else: From 76ceb08b58d8603707e2ee0aefea827b60497ef0 Mon Sep 17 00:00:00 2001 From: Charles Haley <> Date: Fri, 21 May 2010 13:17:58 +0100 Subject: [PATCH 3/4] Get rid of traceback accidentally left in. --- src/calibre/gui2/library/models.py | 1 - 1 file changed, 1 deletion(-) diff --git a/src/calibre/gui2/library/models.py b/src/calibre/gui2/library/models.py index e234002a9c..7bf679fa0c 100644 --- a/src/calibre/gui2/library/models.py +++ b/src/calibre/gui2/library/models.py @@ -865,7 +865,6 @@ class DeviceBooksModel(BooksModel): # {{{ def search(self, text, refinement, reset=True): - traceback.print_stack() if not text or not text.strip(): self.map = list(range(len(self.db))) else: From 0b3bc6d5d5b4d119b228522704af116bdd3f905b Mon Sep 17 00:00:00 2001 From: Charles Haley <> Date: Fri, 21 May 2010 13:32:25 +0100 Subject: [PATCH 4/4] OndeviceSearch must permit all the locations that the library permits or exceptions get raised. Changed to do that, but also limit the locations that the search will actually use. --- src/calibre/gui2/library/models.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/calibre/gui2/library/models.py b/src/calibre/gui2/library/models.py index 7bf679fa0c..6fbc0660f7 100644 --- a/src/calibre/gui2/library/models.py +++ b/src/calibre/gui2/library/models.py @@ -729,18 +729,19 @@ class BooksModel(QAbstractTableModel): # {{{ class OnDeviceSearch(SearchQueryParser): # {{{ - DEFAULT_LOCATIONS = [ + USABLE_LOCATIONS = set([ 'collections', 'title', 'author', 'format', 'all', - ] + ]) def __init__(self, model): SearchQueryParser.__init__(self) self.model = model + self.DEFAULT_LOCATIONS = set(self.DEFAULT_LOCATIONS) | self.USABLE_LOCATIONS def universal_set(self): return set(range(0, len(self.model.db))) @@ -763,10 +764,10 @@ class OnDeviceSearch(SearchQueryParser): # {{{ if matchkind != REGEXP_MATCH: ### leave case in regexps because it can be significant e.g. \S \W \D query = query.lower() - if location not in self.DEFAULT_LOCATIONS: + if location not in self.USABLE_LOCATIONS: return set([]) matches = set([]) - all_locs = set(self.DEFAULT_LOCATIONS) - set(['all']) + all_locs = set(self.USABLE_LOCATIONS) - set(['all']) locations = all_locs if location == 'all' else [location] q = { 'title' : lambda x : getattr(x, 'title').lower(),