This commit is contained in:
Kovid Goyal 2010-02-12 12:27:09 -07:00
commit d5b4f4c36f

View File

@ -832,9 +832,8 @@ class EPUB_MOBI(CatalogPlugin):
# Methods # Methods
def buildSources(self): def buildSources(self):
if self.booksByTitle is None: if self.booksByTitle is None:
self.fetchBooksByTitle() if not self.fetchBooksByTitle():
if not len(self.booksByTitle): return False
return False
self.fetchBooksByAuthor() self.fetchBooksByAuthor()
self.generateHTMLDescriptions() self.generateHTMLDescriptions()
self.generateHTMLByAuthor() self.generateHTMLByAuthor()
@ -901,16 +900,15 @@ class EPUB_MOBI(CatalogPlugin):
self.opts.sort_by = 'title' self.opts.sort_by = 'title'
# Merge opts.exclude_tag with opts.search_text # Merge opts.exclude_tags with opts.search_text
# Updated to use exact match syntax
# What if no exclude tags?
empty_exclude_tags = False if len(self.opts.exclude_tags) else True empty_exclude_tags = False if len(self.opts.exclude_tags) else True
search_phrase = '' search_phrase = ''
if not empty_exclude_tags: if not empty_exclude_tags:
exclude_tags = self.opts.exclude_tags.split(',') exclude_tags = self.opts.exclude_tags.split(',')
search_terms = [] search_terms = []
for tag in exclude_tags: 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) search_phrase = "not (%s)" % " or ".join(search_terms)
# If a list of ids are provided, don't use search_text # If a list of ids are provided, don't use search_text
@ -996,14 +994,18 @@ class EPUB_MOBI(CatalogPlugin):
titles.append(this_title) titles.append(this_title)
# Re-sort based on title_sort # Re-sort based on title_sort
self.booksByTitle = sorted(titles, if len(titles):
key=lambda x:(x['title_sort'].upper(), x['title_sort'].upper())) self.booksByTitle = sorted(titles,
if False and self.verbose: key=lambda x:(x['title_sort'].upper(), x['title_sort'].upper()))
self.opts.log.info("fetchBooksByTitle(): %d books" % len(self.booksByTitle)) if False and self.verbose:
self.opts.log.info(" %-40s %-40s" % ('title', 'title_sort')) self.opts.log.info("fetchBooksByTitle(): %d books" % len(self.booksByTitle))
for title in self.booksByTitle: self.opts.log.info(" %-40s %-40s" % ('title', 'title_sort'))
self.opts.log.info((u" %-40s %-40s" % (title['title'][0:40], for title in self.booksByTitle:
title['title_sort'][0:40])).encode('utf-8')) 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): def fetchBooksByAuthor(self):
# Generate a list of titles sorted by author from the database # Generate a list of titles sorted by author from the database