Resolves bugs #4679 and 4687, improved diagnostics

This commit is contained in:
GRiker 2010-01-26 04:58:55 -07:00
parent d2b6f346ab
commit 76fbc5dc60

View File

@ -3,7 +3,7 @@ import os, re, shutil, htmlentitydefs
from collections import namedtuple from collections import namedtuple
from xml.sax.saxutils import escape from xml.sax.saxutils import escape
from calibre import filesystem_encoding from calibre import filesystem_encoding, prints
from calibre.customize import CatalogPlugin from calibre.customize import CatalogPlugin
from calibre.customize.conversion import OptionRecommendation, DummyReporter from calibre.customize.conversion import OptionRecommendation, DummyReporter
from calibre.ebooks.BeautifulSoup import BeautifulSoup, BeautifulStoneSoup, Tag, NavigableString from calibre.ebooks.BeautifulSoup import BeautifulSoup, BeautifulStoneSoup, Tag, NavigableString
@ -330,6 +330,7 @@ class EPUB_MOBI(CatalogPlugin):
tensComponentString = "%s" % tensPart tensComponentString = "%s" % tensPart
# Concatenate the results # Concatenate the results
result = ''
if hundredsComponent and not tensComponent: if hundredsComponent and not tensComponent:
result = hundredsComponentString result = hundredsComponentString
if not hundredsComponent and tensComponent: if not hundredsComponent and tensComponent:
@ -837,7 +838,8 @@ class EPUB_MOBI(CatalogPlugin):
title = this_title['title'] = self.convertHTMLEntities(record['title']) title = this_title['title'] = self.convertHTMLEntities(record['title'])
this_title['title_sort'] = self.generateSortTitle(title) this_title['title_sort'] = self.generateSortTitle(title)
this_title['author'] = " & ".join(record['authors']) this_title['author'] = " & ".join(record['authors'])
this_title['author_sort'] = record['author_sort'] this_title['author_sort'] = record['author_sort'] if len(record['author_sort']) \
else this_title['author']
this_title['id'] = record['id'] this_title['id'] = record['id']
if record['publisher']: if record['publisher']:
this_title['publisher'] = re.sub('&', '&', record['publisher']) this_title['publisher'] = re.sub('&', '&', record['publisher'])
@ -920,13 +922,13 @@ class EPUB_MOBI(CatalogPlugin):
books_by_current_author)) books_by_current_author))
else: else:
books_by_current_author += 1 books_by_current_author += 1
else:
# Allow for single-author dataset # Add final author to list or single-author dataset
if not multiple_authors: if (current_author == author and len(authors) > 1) or not multiple_authors:
unique_authors.append((current_author[0], current_author[1].title(), unique_authors.append((current_author[0], current_author[1].title(),
books_by_current_author)) books_by_current_author))
if False and self.verbose: if self.verbose:
self.opts.log.info("\nfetchBooksByauthor(): %d unique authors" % len(unique_authors)) self.opts.log.info("\nfetchBooksByauthor(): %d unique authors" % len(unique_authors))
for author in unique_authors: for author in unique_authors:
self.opts.log.info((u" %-50s %-25s %2d" % (author[0][0:45], author[1][0:20], self.opts.log.info((u" %-50s %-25s %2d" % (author[0][0:45], author[1][0:20],
@ -1877,6 +1879,11 @@ class EPUB_MOBI(CatalogPlugin):
self.opts.log.info(self.updateProgressFullStep("generateNCXByTags()")) self.opts.log.info(self.updateProgressFullStep("generateNCXByTags()"))
if not len(self.genres):
self.opts.log.warn(" No genres found in tags.\n"
" No Genre section added to Catalog")
return
ncx_soup = self.ncxSoup ncx_soup = self.ncxSoup
body = ncx_soup.find("navPoint") body = ncx_soup.find("navPoint")
btc = len(body.contents) btc = len(body.contents)
@ -2048,6 +2055,10 @@ class EPUB_MOBI(CatalogPlugin):
filtered_tags.insert(1, (filtered_tags.pop(i))) filtered_tags.insert(1, (filtered_tags.pop(i)))
else: else:
continue continue
if self.verbose:
self.opts.log.info(' %d Genre tags in database (exclude_genre: %s):' % \
(len(filtered_tags), self.opts.exclude_genre))
self.opts.log.info(' %s' % ', '.join(filtered_tags))
return filtered_tags return filtered_tags