diff --git a/src/calibre/library/catalog.py b/src/calibre/library/catalog.py
index 3c280b89da..2ced3499b0 100644
--- a/src/calibre/library/catalog.py
+++ b/src/calibre/library/catalog.py
@@ -244,12 +244,12 @@ class EPUB_MOBI(CatalogPlugin):
Option('--debug-pipeline',
default=None,
dest='debug_pipeline',
- help=_('Save the output from different stages of the conversion '
- 'pipeline to the specified '
- 'directory. Useful if you are unsure at which stage '
- 'of the conversion process a bug is occurring.\n'
- 'Default: None\n'
- 'Applies to: ePub, MOBI output formats')),
+ help=_("Save the output from different stages of the conversion "
+ "pipeline to the specified "
+ "directory. Useful if you are unsure at which stage "
+ "of the conversion process a bug is occurring.\n"
+ "Default: '%default'None\n"
+ "Applies to: ePub, MOBI output formats")),
Option('--exclude-genre',
default='\[[\w ]*\]',
dest='exclude_genre',
@@ -466,7 +466,7 @@ class EPUB_MOBI(CatalogPlugin):
'July','August','September','October','November','December']
# Tags starting with these characters will not be included in the genre list
- REMOVE_TAGS = ['~','+','*','[']
+# REMOVE_TAGS = ['~','+','*','[']
# Symbols used to show a book's read/unread status
NOT_READ_SYMBOL = '✓'
@@ -476,7 +476,6 @@ class EPUB_MOBI(CatalogPlugin):
# creator dc:creator in OPF metadata
# dbs_fname stored catalog snapshot
# descriptionClip limits size of NCX descriptions (Kindle only)
- # generateForMobigen Modifies OPF/NCX for Mobigen compilation
# includeSources Used in processSpecialTags to skip tags like '[SPL]'
# notification Used to check for cancel, report progress
# plugin_path Plugin zip file (resources)
@@ -484,11 +483,10 @@ class EPUB_MOBI(CatalogPlugin):
# title dc:title in OPF metadata, NCX periodical
# verbosity level of diagnostic printout
-
def __init__(self, db, opts, plugin,
- generateForMobigen=False,
notification=DummyReporter(),
stylesheet="content/stylesheet.css"):
+ self.__opts = opts
self.__authors = None
self.__basename = opts.basename
self.__booksByAuthor = None
@@ -501,12 +499,11 @@ class EPUB_MOBI(CatalogPlugin):
self.__databaseSnapshot = self.fetchDatabaseSnapshot(self.__dbs_fname)
self.__descriptionClip = opts.descriptionClip
self.__error = None
- self.__generateForMobigen = generateForMobigen
self.__genres = None
self.__htmlFileList = []
self.__libraryPath = self.fetchLibraryPath()
+ self.__markerTags = self.getMarkerTags()
self.__ncxSoup = None
- self.__opts = opts
self.__playOrder = 1
self.__plugin = plugin
self.__plugin_path = opts.plugin_path
@@ -536,7 +533,6 @@ class EPUB_MOBI(CatalogPlugin):
def fset(self, val):
self.__authors = val
return property(fget=fget, fset=fset)
-
@dynamic_property
def basename(self):
def fget(self):
@@ -544,7 +540,6 @@ class EPUB_MOBI(CatalogPlugin):
def fset(self, val):
self.__basename = val
return property(fget=fget, fset=fset)
-
@dynamic_property
def booksByAuthor(self):
def fget(self):
@@ -552,7 +547,6 @@ class EPUB_MOBI(CatalogPlugin):
def fset(self, val):
self.__booksByAuthor = val
return property(fget=fget, fset=fset)
-
@dynamic_property
def booksByTitle(self):
def fget(self):
@@ -560,7 +554,6 @@ class EPUB_MOBI(CatalogPlugin):
def fset(self, val):
self.__booksByTitle = val
return property(fget=fget, fset=fset)
-
@dynamic_property
def catalogPath(self):
def fget(self):
@@ -568,7 +561,6 @@ class EPUB_MOBI(CatalogPlugin):
def fset(self, val):
self.__catalogPath = val
return property(fget=fget, fset=fset)
-
@dynamic_property
def contentDir(self):
def fget(self):
@@ -576,7 +568,6 @@ class EPUB_MOBI(CatalogPlugin):
def fset(self, val):
self.__contentDir = val
return property(fget=fget, fset=fset)
-
@dynamic_property
def creator(self):
def fget(self):
@@ -584,7 +575,6 @@ class EPUB_MOBI(CatalogPlugin):
def fset(self, val):
self.__creator = val
return property(fget=fget, fset=fset)
-
@dynamic_property
def databaseSnapshot(self):
def fget(self):
@@ -592,13 +582,11 @@ class EPUB_MOBI(CatalogPlugin):
def fset(self, val):
self.__databaseSnapshot = val
return property(fget=fget, fset=fset)
-
@dynamic_property
def db(self):
def fget(self):
return self.__db
return property(fget=fget)
-
@dynamic_property
def descriptionClip(self):
def fget(self):
@@ -606,13 +594,11 @@ class EPUB_MOBI(CatalogPlugin):
def fset(self, val):
self.__descriptionClip = val
return property(fget=fget, fset=fset)
-
@dynamic_property
def error(self):
def fget(self):
return self.__error
return property(fget=fget)
-
@dynamic_property
def generateForMobigen(self):
def fget(self):
@@ -620,7 +606,6 @@ class EPUB_MOBI(CatalogPlugin):
def fset(self, val):
self.__generateForMobigen = val
return property(fget=fget, fset=fset)
-
@dynamic_property
def genres(self):
def fget(self):
@@ -628,7 +613,6 @@ class EPUB_MOBI(CatalogPlugin):
def fset(self, val):
self.__genres = val
return property(fget=fget, fset=fset)
-
@dynamic_property
def htmlFileList(self):
def fget(self):
@@ -636,7 +620,6 @@ class EPUB_MOBI(CatalogPlugin):
def fset(self, val):
self.__htmlFileList = val
return property(fget=fget, fset=fset)
-
@dynamic_property
def libraryPath(self):
def fget(self):
@@ -644,7 +627,13 @@ class EPUB_MOBI(CatalogPlugin):
def fset(self, val):
self.__libraryPath = val
return property(fget=fget, fset=fset)
-
+ @dynamic_property
+ def markerTags(self):
+ def fget(self):
+ return self.__markerTags
+ def fset(self, val):
+ self.__markerTags = val
+ return property(fget=fget, fset=fset)
@dynamic_property
def ncxSoup(self):
def fget(self):
@@ -652,13 +641,11 @@ class EPUB_MOBI(CatalogPlugin):
def fset(self, val):
self.__ncxSoup = val
return property(fget=fget, fset=fset)
-
@dynamic_property
def opts(self):
def fget(self):
return self.__opts
return property(fget=fget)
-
@dynamic_property
def playOrder(self):
def fget(self):
@@ -666,13 +653,11 @@ class EPUB_MOBI(CatalogPlugin):
def fset(self,val):
self.__playOrder = val
return property(fget=fget, fset=fset)
-
@dynamic_property
def plugin(self):
def fget(self):
return self.__plugin
return property(fget=fget)
-
@dynamic_property
def pluginPath(self):
def fget(self):
@@ -680,7 +665,6 @@ class EPUB_MOBI(CatalogPlugin):
def fset(self, val):
self.__pluginPath = val
return property(fget=fget, fset=fset)
-
@dynamic_property
def progressInt(self):
def fget(self):
@@ -688,7 +672,6 @@ class EPUB_MOBI(CatalogPlugin):
def fset(self, val):
self.__progressInt = val
return property(fget=fget, fset=fset)
-
@dynamic_property
def progressString(self):
def fget(self):
@@ -696,7 +679,6 @@ class EPUB_MOBI(CatalogPlugin):
def fset(self, val):
self.__progressString = val
return property(fget=fget, fset=fset)
-
@dynamic_property
def reporter(self):
def fget(self):
@@ -704,7 +686,6 @@ class EPUB_MOBI(CatalogPlugin):
def fset(self, val):
self.__reporter = val
return property(fget=fget, fset=fset)
-
@dynamic_property
def stylesheet(self):
def fget(self):
@@ -712,7 +693,6 @@ class EPUB_MOBI(CatalogPlugin):
def fset(self, val):
self.__stylesheet = val
return property(fget=fget, fset=fset)
-
@dynamic_property
def thumbs(self):
def fget(self):
@@ -720,7 +700,6 @@ class EPUB_MOBI(CatalogPlugin):
def fset(self, val):
self.__thumbs = val
return property(fget=fget, fset=fset)
-
@dynamic_property
def title(self):
def fget(self):
@@ -728,7 +707,6 @@ class EPUB_MOBI(CatalogPlugin):
def fset(self, val):
self.__title = val
return property(fget=fget, fset=fset)
-
@dynamic_property
def verbose(self):
def fget(self):
@@ -890,7 +868,7 @@ class EPUB_MOBI(CatalogPlugin):
if self.verbose:
print self.updateProgressFullStep("fetchBooksByAuthor()")
- # Sort titles based on upper case authors
+ # Sort titles case-insensitive
self.booksByAuthor = sorted(self.booksByTitle,
key=lambda x:(x['author_sort'].upper(), x['author_sort'].upper()))
@@ -923,7 +901,8 @@ class EPUB_MOBI(CatalogPlugin):
# authors[] contains a list of all book authors, with multiple entries for multiple books by author
- # unique_authors : (([0]:friendly [1]:sort [2]:book_count))
+ # authors[]: (([0]:friendly [1]:sort))
+ # create unique_authors[] : (([0]:friendly [1]:sort [2]:book_count))
books_by_current_author = 0
current_author = authors[0]
multiple_authors = False
@@ -949,14 +928,20 @@ class EPUB_MOBI(CatalogPlugin):
unique_authors.append((current_author[0], current_author[1],
books_by_current_author))
- if False and self.verbose:
- print "\nget_books_by_author(): %d unique authors" % len(unique_authors)
- for author in unique_authors[0:3]:
- print "%s" % author[0]
- print " ... "
- for author in unique_authors[-3:]:
- print "%s" % author[0]
-
+ if self.verbose:
+ if False:
+ print "\nget_books_by_author(): %d unique authors" % len(unique_authors)
+ for author in unique_authors[0:3]:
+ print "%s" % author[0]
+ print " ... "
+ for author in unique_authors[-3:]:
+ print "%s" % author[0]
+ else:
+ print "\nget_books_by_author(): %d unique authors" % len(unique_authors)
+ for author in unique_authors:
+ print "%-50s %-25s %2d" % (author[0], author[1], author[2])
+ print
+
self.authors = unique_authors
def generateHTMLDescriptions(self):
@@ -977,24 +962,12 @@ class EPUB_MOBI(CatalogPlugin):
btc = 0
- # Insert section tag if this is the section start - first article only
- if not title_num and self.generateForMobigen:
- aTag = Tag(soup,'a')
- aTag['name'] = 'section_start'
- body.insert(btc, aTag)
- btc += 1
-
# Insert the anchor
aTag = Tag(soup, "a")
aTag['name'] = "book%d" % int(title['id'])
body.insert(btc, aTag)
btc += 1
- # Insert section marker if this is the section head - first article only
- if not title_num and self.generateForMobigen:
- body.insert(btc, '')
- btc += 1
-
# Insert the book title
#
Book Title
emTag = Tag(soup, "em")
@@ -1123,23 +1096,6 @@ class EPUB_MOBI(CatalogPlugin):
body.insert(btc, aTag)
btc += 1
- # Insert section marker if this is the section head - first article only
- if self.generateForMobigen:
- body.insert(btc, '')
- btc += 1
-
- '''
- # We don't need this because the Kindle shows section titles
- #
divTag = Tag(soup, "div")
@@ -1234,24 +1190,6 @@ class EPUB_MOBI(CatalogPlugin):
body.insert(btc, aTag)
btc += 1
- # Insert section marker if this is the section head - first article only
- if self.generateForMobigen:
- body.insert(btc, '')
- btc += 1
-
- '''
- # We don't need this because the kindle inserts section titles
- #