From 2091ca2ca498a54e98fc291beb48df01bc3fe6e8 Mon Sep 17 00:00:00 2001 From: GRiker Date: Fri, 12 Feb 2010 10:51:41 -0700 Subject: [PATCH 1/3] Changed booksByTitle when empty list --- src/calibre/library/catalog.py | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/src/calibre/library/catalog.py b/src/calibre/library/catalog.py index 96310d2111..7d7421c601 100644 --- a/src/calibre/library/catalog.py +++ b/src/calibre/library/catalog.py @@ -832,9 +832,8 @@ class EPUB_MOBI(CatalogPlugin): # Methods def buildSources(self): if self.booksByTitle is None: - self.fetchBooksByTitle() - if not len(self.booksByTitle): - return False + if not self.fetchBooksByTitle(): + return False self.fetchBooksByAuthor() self.generateHTMLDescriptions() self.generateHTMLByAuthor() @@ -996,14 +995,18 @@ class EPUB_MOBI(CatalogPlugin): titles.append(this_title) # Re-sort based on title_sort - self.booksByTitle = sorted(titles, - key=lambda x:(x['title_sort'].upper(), x['title_sort'].upper())) - if False and self.verbose: - self.opts.log.info("fetchBooksByTitle(): %d books" % len(self.booksByTitle)) - self.opts.log.info(" %-40s %-40s" % ('title', 'title_sort')) - for title in self.booksByTitle: - self.opts.log.info((u" %-40s %-40s" % (title['title'][0:40], - title['title_sort'][0:40])).encode('utf-8')) + if len(titles): + self.booksByTitle = sorted(titles, + key=lambda x:(x['title_sort'].upper(), x['title_sort'].upper())) + if False and self.verbose: + self.opts.log.info("fetchBooksByTitle(): %d books" % len(self.booksByTitle)) + self.opts.log.info(" %-40s %-40s" % ('title', 'title_sort')) + for title in self.booksByTitle: + self.opts.log.info((u" %-40s %-40s" % (title['title'][0:40], + title['title_sort'][0:40])).encode('utf-8')) + return True + else: + return False def fetchBooksByAuthor(self): # Generate a list of titles sorted by author from the database From d9e5ac9a05d52fbe174bdfb0cc8102600369ace8 Mon Sep 17 00:00:00 2001 From: GRiker Date: Fri, 12 Feb 2010 11:11:23 -0700 Subject: [PATCH 2/3] GR tweaks anticipating exact search --- src/calibre/library/catalog.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/calibre/library/catalog.py b/src/calibre/library/catalog.py index 7d7421c601..91e10b757e 100644 --- a/src/calibre/library/catalog.py +++ b/src/calibre/library/catalog.py @@ -900,9 +900,7 @@ class EPUB_MOBI(CatalogPlugin): self.opts.sort_by = 'title' - # Merge opts.exclude_tag with opts.search_text - - # What if no exclude tags? + # Merge opts.exclude_tags with opts.search_text empty_exclude_tags = False if len(self.opts.exclude_tags) else True search_phrase = '' if not empty_exclude_tags: @@ -910,6 +908,7 @@ class EPUB_MOBI(CatalogPlugin): search_terms = [] for tag in exclude_tags: search_terms.append("tag:%s" % tag) + #search_terms.append("tag:=%s" % tag) search_phrase = "not (%s)" % " or ".join(search_terms) # If a list of ids are provided, don't use search_text From fd82ec60023d00f86c505c485076dcf5470abe8e Mon Sep 17 00:00:00 2001 From: GRiker Date: Fri, 12 Feb 2010 11:26:38 -0700 Subject: [PATCH 3/3] Update to exact match search for exclude_tags --- src/calibre/library/catalog.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/calibre/library/catalog.py b/src/calibre/library/catalog.py index 91e10b757e..540ba65cc5 100644 --- a/src/calibre/library/catalog.py +++ b/src/calibre/library/catalog.py @@ -901,14 +901,14 @@ class EPUB_MOBI(CatalogPlugin): self.opts.sort_by = 'title' # Merge opts.exclude_tags with opts.search_text + # Updated to use exact match syntax empty_exclude_tags = False if len(self.opts.exclude_tags) else True search_phrase = '' if not empty_exclude_tags: exclude_tags = self.opts.exclude_tags.split(',') search_terms = [] for tag in exclude_tags: - search_terms.append("tag:%s" % tag) - #search_terms.append("tag:=%s" % tag) + search_terms.append("tag:=%s" % tag) search_phrase = "not (%s)" % " or ".join(search_terms) # If a list of ids are provided, don't use search_text