GwR revisions to catalog generator

This commit is contained in:
GRiker 2011-01-18 06:21:17 -07:00
parent 0c20dd246d
commit fc2ae0d4b5
2 changed files with 20 additions and 23 deletions

View File

@ -6,6 +6,8 @@ __copyright__ = '2010, Kovid Goyal <kovid@kovidgoyal.net>'
__docformat__ = 'restructuredtext en' __docformat__ = 'restructuredtext en'
''' '''
These templates control the content of titles displayed in the various sections
Available fields: Available fields:
{title} Title of the book {title} Title of the book
{series} Series name {series} Series name
@ -14,6 +16,7 @@ __docformat__ = 'restructuredtext en'
{rating_parens} Rating, in parentheses {rating_parens} Rating, in parentheses
{pubyear} Year the book was published {pubyear} Year the book was published
{pubyear_parens} Year the book was published, in parentheses {pubyear_parens} Year the book was published, in parentheses
''' '''
# Books by Author # Books by Author
by_authors_normal_title_template = '{title} {pubyear_parens}' by_authors_normal_title_template = '{title} {pubyear_parens}'

View File

@ -1027,17 +1027,12 @@ class EPUB_MOBI(CatalogPlugin):
self.__totalSteps += 3 self.__totalSteps += 3
# Load section list templates # Load section list templates
templates = ['by_authors_normal_title_template', templates = []
'by_authors_series_title_template', with open(P('catalog/section_list_templates.py'), 'r') as f:
'by_titles_normal_title_template', for line in f:
'by_titles_series_title_template', t = re.match("(by_.+_template)",line)
'by_series_title_template', if t:
'by_genres_normal_title_template', templates.append(t.group(1))
'by_genres_series_title_template',
'by_recently_added_normal_title_template',
'by_recently_added_series_title_template',
'by_month_added_normal_title_template',
'by_month_added_series_title_template']
execfile(P('catalog/section_list_templates.py'), locals()) execfile(P('catalog/section_list_templates.py'), locals())
for t in templates: for t in templates:
setattr(self,t,eval(t)) setattr(self,t,eval(t))
@ -1441,7 +1436,9 @@ class EPUB_MOBI(CatalogPlugin):
# Exit if author matches previous, but author_sort doesn't match # Exit if author matches previous, but author_sort doesn't match
if author[0] == current_author[0]: if author[0] == current_author[0]:
error_msg = _(''' error_msg = _('''
Inconsistent Author Sort values for Author '{0}' ('{1}' <> '{2}'), unable to build catalog.\n Inconsistent Author Sort values for Author '{0}':
'{1}' <> '{2}',
unable to build catalog.\n
Select all books by '{0}', apply correct Author Sort value in Edit Metadata dialog, Select all books by '{0}', apply correct Author Sort value in Edit Metadata dialog,
then rebuild the catalog.\n''').format(author[0],author[1],current_author[1]) then rebuild the catalog.\n''').format(author[0],author[1],current_author[1])
self.opts.log.warn('\n*** Metadata error ***') self.opts.log.warn('\n*** Metadata error ***')
@ -1450,15 +1447,11 @@ then rebuild the catalog.\n''').format(author[0],author[1],current_author[1])
self.error.append('Metadata error') self.error.append('Metadata error')
self.error.append(error_msg) self.error.append(error_msg)
return False return False
current_author = author
self.booksByAuthor = sorted(self.booksByAuthor, key=self.booksByAuthorSorter_author_sort) self.booksByAuthor = sorted(self.booksByAuthor, key=self.booksByAuthorSorter_author_sort)
# for book in self.booksByAuthor:
# print '{0:<10} {1:<5} {2:<20} {3:<20} {4:<20} {5:<20}'.format(book['series'], book['series_index'], book['title'],
# book['author'], book['authors'],book['author_sort'])
# print
# Build the unique_authors set from existing data # Build the unique_authors set from existing data
authors = [(record['author'], capitalize(record['author_sort'])) for record in self.booksByAuthor] authors = [(record['author'], capitalize(record['author_sort'])) for record in self.booksByAuthor]
@ -1566,7 +1559,7 @@ then rebuild the catalog.\n''').format(author[0],author[1],current_author[1])
this_title['rating'] = record['rating'] if record['rating'] else 0 this_title['rating'] = record['rating'] if record['rating'] else 0
if re.match('0100-01-01',str(record['pubdate'].date())): if re.match('0101-01-01',str(record['pubdate'].date())):
this_title['date'] = None this_title['date'] = None
else: else:
this_title['date'] = strftime(u'%B %Y', record['pubdate'].timetuple()) this_title['date'] = strftime(u'%B %Y', record['pubdate'].timetuple())
@ -2683,7 +2676,7 @@ then rebuild the catalog.\n''').format(author[0],author[1],current_author[1])
#aTag.insert(0,'%d. %s &middot; %s' % (book['series_index'],escape(book['title']), ' & '.join(book['authors']))) #aTag.insert(0,'%d. %s &middot; %s' % (book['series_index'],escape(book['title']), ' & '.join(book['authors'])))
# Reassert 'date' since this is the result of a new search # Reassert 'date' since this is the result of a new search
if re.match('0100-01-01',str(book['pubdate'].date())): if re.match('0101-01-01',str(book['pubdate'].date())):
book['date'] = None book['date'] = None
else: else:
book['date'] = strftime(u'%B %Y', book['pubdate'].timetuple()) book['date'] = strftime(u'%B %Y', book['pubdate'].timetuple())
@ -4314,10 +4307,11 @@ then rebuild the catalog.\n''').format(author[0],author[1],current_author[1])
formats = ' &middot; '.join(formats) formats = ' &middot; '.join(formats)
# Date of publication # Date of publication
pubdate = book['date'] if book['date']:
pubmonth, pubyear = pubdate.split() pubdate = book['date']
if pubyear == '101': pubmonth, pubyear = pubdate.split()
pubdate = pubmonth = pubyear = '' else:
pubdate = pubyear = pubmonth = ''
# Thumb # Thumb
_soup = BeautifulSoup('<html>',selfClosingTags=['img']) _soup = BeautifulSoup('<html>',selfClosingTags=['img'])