From cd64abe26c668c6f286384c283b79cc7650cedf1 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 11 Jun 2009 07:56:12 -0700 Subject: [PATCH 1/9] Make formatting of series_index more robust --- src/calibre/ebooks/metadata/__init__.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/calibre/ebooks/metadata/__init__.py b/src/calibre/ebooks/metadata/__init__.py index 4c2c6c744a..81275b4ff6 100644 --- a/src/calibre/ebooks/metadata/__init__.py +++ b/src/calibre/ebooks/metadata/__init__.py @@ -63,14 +63,13 @@ def roman(num): def fmt_sidx(i, fmt='%.2f', use_roman=False): if i is None or i == '': i = 1 - i = float(i) + try: + i = float(i) + except TypeError: + return str(i) if int(i) == float(i): return roman(int(i)) if use_roman else '%d'%int(i) - try: - return fmt%i - except TypeError: - return fmt%float(i) - + return fmt%i class Resource(object): ''' From 2c9a3410ea0ed7b699ecc970490f0341b45f2c64 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 11 Jun 2009 10:26:22 -0700 Subject: [PATCH 2/9] beta 4 --- src/calibre/constants.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/calibre/constants.py b/src/calibre/constants.py index 319b01f887..2a6736d58e 100644 --- a/src/calibre/constants.py +++ b/src/calibre/constants.py @@ -2,7 +2,7 @@ __license__ = 'GPL v3' __copyright__ = '2008, Kovid Goyal kovid@kovidgoyal.net' __docformat__ = 'restructuredtext en' __appname__ = 'calibre' -__version__ = '0.6.0b3' +__version__ = '0.6.0b4' __author__ = "Kovid Goyal " import re From 01a7153972697ed9f1c8385af7fb9a992af5b232 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 11 Jun 2009 11:25:25 -0700 Subject: [PATCH 3/9] Make news download scheduler dialog compatible with PyQt 4.5 --- installer/windows/calibre/calibre.mpi | 2 -- src/calibre/gui2/dialogs/scheduler.py | 6 +++--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/installer/windows/calibre/calibre.mpi b/installer/windows/calibre/calibre.mpi index 6ad18ddaf1..a5fc37d883 100644 --- a/installer/windows/calibre/calibre.mpi +++ b/installer/windows/calibre/calibre.mpi @@ -534,8 +534,6 @@ File ::8B8655B8-3823-AA02-1CDA-02F5AD4677C0 -name fetch-ebook-metadata.exe -pare File ::8FC3D58A-F3FA-A2D1-711F-F4C3128620CE -name podofo.dll -parent 8E5D85A4-7608-47A1-CF7C-309060D5FF40 File ::88034147-A376-B759-D48C-5F17A47E8CC3 -name ebook-meta.exe.local -parent 8E5D85A4-7608-47A1-CF7C-309060D5FF40 File ::6E6F2A97-6614-F2A6-1751-95C099B909FD -name pdfmanipulate.exe.local -parent 8E5D85A4-7608-47A1-CF7C-309060D5FF40 -File ::AC456A9A-6653-5852-D1F7-B04E2C1AA481 -name isbndb.exe -parent 8E5D85A4-7608-47A1-CF7C-309060D5FF40 -File ::94580010-4CE4-8EC0-3834-9A2BCCB28C70 -name isbndb.exe.local -parent 8E5D85A4-7608-47A1-CF7C-309060D5FF40 File ::BA087530-7CF4-5460-C9AA-DE4A796C9AEB -name pdfmanipulate.exe -parent 8E5D85A4-7608-47A1-CF7C-309060D5FF40 File ::6AF80BFC-A813-074D-897A-856744A91949 -name ebook-convert.exe.local -parent 8E5D85A4-7608-47A1-CF7C-309060D5FF40 File ::F8C59A30-9E90-0861-5604-95E7C69C3C80 -name ebook-convert.exe -parent 8E5D85A4-7608-47A1-CF7C-309060D5FF40 diff --git a/src/calibre/gui2/dialogs/scheduler.py b/src/calibre/gui2/dialogs/scheduler.py index 47f5a63db0..3b45e9a759 100644 --- a/src/calibre/gui2/dialogs/scheduler.py +++ b/src/calibre/gui2/dialogs/scheduler.py @@ -182,12 +182,12 @@ class RecipeModel(QAbstractItemModel, SearchQueryParser): self.reset() def index(self, row, column, parent): - return self.createIndex(row, column, parent.row() if parent.isValid() else -1) + return self.createIndex(row, column, parent.row()+1 if parent.isValid() else 0) def parent(self, index): - if index.internalId() == -1: + if index.internalId() == 0: return QModelIndex() - return self.createIndex(index.internalId(), 0, -1) + return self.createIndex(index.internalId()-1, 0, 0) def columnCount(self, parent): if not parent.isValid() or not parent.parent().isValid(): From 0b9f489e256cdf2144b99335392986380ae52fdb Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 11 Jun 2009 11:33:17 -0700 Subject: [PATCH 4/9] ... --- src/calibre/gui2/dialogs/config.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/calibre/gui2/dialogs/config.py b/src/calibre/gui2/dialogs/config.py index 59e148046d..70237548d5 100644 --- a/src/calibre/gui2/dialogs/config.py +++ b/src/calibre/gui2/dialogs/config.py @@ -112,19 +112,19 @@ class PluginModel(QAbstractItemModel): return QModelIndex() if parent.isValid(): - return self.createIndex(row, column, parent.row()) + return self.createIndex(row, column, 1+parent.row()) else: - return self.createIndex(row, column, -1) + return self.createIndex(row, column, 0) def parent(self, index): - if not index.isValid() or index.internalId() == -1: + if not index.isValid() or index.internalId() == 0: return QModelIndex() - return self.createIndex(index.internalId(), 0, -1) + return self.createIndex(index.internalId()-1, 0, 0) def rowCount(self, parent): if not parent.isValid(): return len(self.categories) - if parent.internalId() == -1: + if parent.internalId() == 0: category = self.categories[parent.row()] return len(self._data[category]) return 0 From d596ed03416df89fdfc74b0935917d5a443f9b36 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 11 Jun 2009 11:52:07 -0700 Subject: [PATCH 5/9] Fix #2576 (chm files) and handle empty TOCs in the conversion pipeline --- src/calibre/ebooks/__init__.py | 2 +- src/calibre/ebooks/oeb/base.py | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/calibre/ebooks/__init__.py b/src/calibre/ebooks/__init__.py index d2d6fc94e1..a084cdd0f8 100644 --- a/src/calibre/ebooks/__init__.py +++ b/src/calibre/ebooks/__init__.py @@ -25,7 +25,7 @@ class DRMError(ValueError): BOOK_EXTENSIONS = ['lrf', 'rar', 'zip', 'rtf', 'lit', 'txt', 'htm', 'xhtm', 'html', 'xhtml', 'pdf', 'pdb', 'prc', 'mobi', 'azw', 'doc', 'epub', 'fb2', 'djvu', 'lrx', 'cbr', 'cbz', 'oebzip', - 'rb', 'imp', 'odt'] + 'rb', 'imp', 'odt', 'chm'] class HTMLRenderer(object): diff --git a/src/calibre/ebooks/oeb/base.py b/src/calibre/ebooks/oeb/base.py index e2a4875399..244acf7627 100644 --- a/src/calibre/ebooks/oeb/base.py +++ b/src/calibre/ebooks/oeb/base.py @@ -1327,7 +1327,9 @@ class TOC(object): return len(list(self.iter())) - 1 def next_play_order(self): - return max([x.play_order for x in self.iter()])+1 + entries = [x.play_order for x in self.iter()] + base = max(entries) if entries else 0 + return base+1 def has_href(self, href): for x in self.iter(): From 118d0aa0ce06ca20b3d7384fdd420526155bd384 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 11 Jun 2009 12:16:05 -0700 Subject: [PATCH 6/9] Fix #2578 (ePub output does not seem to work with ADE for Windows) --- src/calibre/ebooks/oeb/base.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/calibre/ebooks/oeb/base.py b/src/calibre/ebooks/oeb/base.py index 244acf7627..3e16e73ab9 100644 --- a/src/calibre/ebooks/oeb/base.py +++ b/src/calibre/ebooks/oeb/base.py @@ -810,6 +810,12 @@ class Manifest(object): r = [x for x in data.iterdescendants(etree.Element) if 'microsoft-com' in x.tag] for x in r: x.tag = XHTML('span') + + # Remove lang redefinition inserted by the amazing Microsoft Word! + body = xpath(data, '/h:html/h:body')[0] + for key in list(body.attrib.keys()): + if key == 'lang' or key.endswith('}lang'): + body.attrib.pop(key) return data def _parse_css(self, data): From 35a121280b9a90b4db319646625993d034b14c84 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 11 Jun 2009 12:20:17 -0700 Subject: [PATCH 7/9] MOBI Output: Change encoding drirection of vwi in indexing trailing bytes --- src/calibre/ebooks/mobi/writer.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/calibre/ebooks/mobi/writer.py b/src/calibre/ebooks/mobi/writer.py index d3b494af1d..8e9fc25ebf 100644 --- a/src/calibre/ebooks/mobi/writer.py +++ b/src/calibre/ebooks/mobi/writer.py @@ -491,12 +491,12 @@ class MobiWriter(object): else : tbsType = 6 - tbSequence = decint(tbsType, DECINT_BACKWARD) - tbSequence += decint(0x00, DECINT_BACKWARD) + tbSequence = decint(tbsType, DECINT_FORWARD) + tbSequence += decint(0x00, DECINT_FORWARD) # Don't write a nodecount for opening type 2 record if tbsType != 2 : tbSequence += chr(self._HTMLRecords[nrecords].currentSectionNodeCount) - tbSequence += decint(len(tbSequence) + 1, DECINT_BACKWARD) + tbSequence += decint(len(tbSequence) + 1, DECINT_FORWARD) else : # Determine tbsType for HTMLRecords > 0 @@ -520,12 +520,12 @@ class MobiWriter(object): shiftedNCXEntry |= tbsType # Assemble the TBS - tbSequence = decint(shiftedNCXEntry, DECINT_BACKWARD) - tbSequence += decint(0x00, DECINT_BACKWARD) + tbSequence = decint(shiftedNCXEntry, DECINT_FORWARD) + tbSequence += decint(0x00, DECINT_FORWARD) # Don't write a nodecount for terminating type 2 record if tbsType != 2 : tbSequence += chr(self._HTMLRecords[nrecords].currentSectionNodeCount) - tbSequence += decint(len(tbSequence) + 1, DECINT_BACKWARD) + tbSequence += decint(len(tbSequence) + 1, DECINT_FORWARD) # print "record %d: tbsType %d" % (nrecords, tbsType) self._tbSequence = tbSequence From b45a202c87c8000ffdfd417a35dd1446a7a22a20 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 11 Jun 2009 12:28:09 -0700 Subject: [PATCH 8/9] Beta 5 --- src/calibre/constants.py | 2 +- src/calibre/devices/prs505/books.py | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/calibre/constants.py b/src/calibre/constants.py index 2a6736d58e..75912b276d 100644 --- a/src/calibre/constants.py +++ b/src/calibre/constants.py @@ -2,7 +2,7 @@ __license__ = 'GPL v3' __copyright__ = '2008, Kovid Goyal kovid@kovidgoyal.net' __docformat__ = 'restructuredtext en' __appname__ = 'calibre' -__version__ = '0.6.0b4' +__version__ = '0.6.0b5' __author__ = "Kovid Goyal " import re diff --git a/src/calibre/devices/prs505/books.py b/src/calibre/devices/prs505/books.py index 6e268e734a..c10263c6e0 100644 --- a/src/calibre/devices/prs505/books.py +++ b/src/calibre/devices/prs505/books.py @@ -403,8 +403,9 @@ def fix_ids(main, carda, cardb): for child in db.root_element.childNodes: if child.nodeType == child.ELEMENT_NODE and child.hasAttribute('id'): id_map[child.getAttribute('id')] = str(cid) - child.setAttribute("sourceid", - '0' if getattr(child, 'tagName', '').endswith('playlist') else '1') + child.setAttribute('sourceid', '1') + #child.setAttribute("sourceid", + # '0' if getattr(child, 'tagName', '').endswith('playlist') else '1') child.setAttribute('id', str(cid)) cid += 1 From 640f059912fdb99d3d03bdb0e750848f0df5ea2d Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 11 Jun 2009 12:42:39 -0700 Subject: [PATCH 9/9] Fix #2579 (Error when importing books by dragging onto the GUI) --- src/calibre/gui2/library.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/calibre/gui2/library.py b/src/calibre/gui2/library.py index 21583e8f98..e27ccba82f 100644 --- a/src/calibre/gui2/library.py +++ b/src/calibre/gui2/library.py @@ -726,7 +726,7 @@ class BooksView(TableView): paths = self.paths_from_event(event) event.setDropAction(Qt.CopyAction) event.accept() - self.emit(SIGNAL('files_dropped(PyQt_PyObject)'), paths, Qt.QueuedConnection) + self.emit(SIGNAL('files_dropped(PyQt_PyObject)'), paths) def set_database(self, db):