From 52e9ee0ce318223e18d9f90590120b0959822f80 Mon Sep 17 00:00:00 2001 From: John Schember Date: Fri, 12 Jun 2009 18:43:42 -0400 Subject: [PATCH 01/18] Ensure ascii with pdb header title. --- src/calibre/ebooks/pdb/header.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/calibre/ebooks/pdb/header.py b/src/calibre/ebooks/pdb/header.py index 0d626b98f6..10e80c4ee0 100644 --- a/src/calibre/ebooks/pdb/header.py +++ b/src/calibre/ebooks/pdb/header.py @@ -66,7 +66,7 @@ class PdbHeaderBuilder(object): def __init__(self, identity, title): self.identity = identity.ljust(3, '\x00')[:8] - self.title = re.sub('[^-A-Za-z0-9]+', '_', title).ljust(32, '\x00')[:32] + self.title = re.sub('[^-A-Za-z0-9]+', '_', title).ljust(32, '\x00')[:32].encode('utf-8') def build_header(self, section_lengths, out_stream): ''' From f8dacaa28d24445eafeb348195a38ad997c65604 Mon Sep 17 00:00:00 2001 From: John Schember Date: Fri, 12 Jun 2009 20:18:51 -0400 Subject: [PATCH 02/18] Ensure pdb header title is encoded correctly. --- src/calibre/ebooks/pdb/header.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/calibre/ebooks/pdb/header.py b/src/calibre/ebooks/pdb/header.py index 10e80c4ee0..5785500c59 100644 --- a/src/calibre/ebooks/pdb/header.py +++ b/src/calibre/ebooks/pdb/header.py @@ -66,7 +66,7 @@ class PdbHeaderBuilder(object): def __init__(self, identity, title): self.identity = identity.ljust(3, '\x00')[:8] - self.title = re.sub('[^-A-Za-z0-9]+', '_', title).ljust(32, '\x00')[:32].encode('utf-8') + self.title = re.sub('[^-A-Za-z0-9]+', '_', title).ljust(32, '\x00')[:32].encode('ascii', 'replace') def build_header(self, section_lengths, out_stream): ''' From 8810cdeeba04b5a71b1e8d4dc614ccc12bdcb54d Mon Sep 17 00:00:00 2001 From: John Schember Date: Sat, 13 Jun 2009 10:19:29 -0400 Subject: [PATCH 03/18] Kindle DX screen sizes (width and height) were opposite. --- src/calibre/customize/profiles.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/calibre/customize/profiles.py b/src/calibre/customize/profiles.py index 3844ab43a5..cc45855c9a 100644 --- a/src/calibre/customize/profiles.py +++ b/src/calibre/customize/profiles.py @@ -242,9 +242,9 @@ class KindleDXOutput(OutputProfile): description = _('This profile is intended for the Amazon Kindle DX.') # Screen size is a best guess - screen_size = (1200, 824) + screen_size = (824, 1200) dpi = 150.0 - comic_screen_size = (1180, 800) + comic_screen_size = (800, 1180) @classmethod def tags_to_string(cls, tags): From 58c49359265282f595fc213fdaf60f12630831a8 Mon Sep 17 00:00:00 2001 From: John Schember Date: Sat, 13 Jun 2009 13:37:05 -0400 Subject: [PATCH 04/18] Fix import of input plugin widget. --- src/calibre/gui2/convert/single.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/calibre/gui2/convert/single.py b/src/calibre/gui2/convert/single.py index 8aaa9de7cd..4f91d848d8 100644 --- a/src/calibre/gui2/convert/single.py +++ b/src/calibre/gui2/convert/single.py @@ -153,7 +153,7 @@ class Config(ResizableDialog, Ui_Dialog): except ImportError: pass input_widget = None - name = 'calibre.gui2.convert.%s' % self.plumber.input_plugin.name.lower().replace(' ', '_') + name = self.plumber.input_plugin.name.lower().replace(' ', '_') try: input_widget = __import__('calibre.gui2.convert.'+name, fromlist=[1]) From 85d4ff84fbf4894517629f69851ce353bbc3784f Mon Sep 17 00:00:00 2001 From: John Schember Date: Sat, 13 Jun 2009 14:05:00 -0400 Subject: [PATCH 05/18] Kindle DX produce correct(?) comic size. --- src/calibre/customize/profiles.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/calibre/customize/profiles.py b/src/calibre/customize/profiles.py index cc45855c9a..8434773515 100644 --- a/src/calibre/customize/profiles.py +++ b/src/calibre/customize/profiles.py @@ -244,7 +244,7 @@ class KindleDXOutput(OutputProfile): # Screen size is a best guess screen_size = (824, 1200) dpi = 150.0 - comic_screen_size = (800, 1180) + comic_screen_size = (775, 1128) @classmethod def tags_to_string(cls, tags): From 2ed396d2c14c39c744734d7f926b0e566eb25c2e Mon Sep 17 00:00:00 2001 From: John Schember Date: Sun, 14 Jun 2009 07:44:40 -0400 Subject: [PATCH 06/18] Add missing command line mobi options to gui. --- src/calibre/gui2/convert/mobi_output.py | 3 ++- src/calibre/gui2/convert/mobi_output.ui | 23 ++++++++++++++++++++++- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/src/calibre/gui2/convert/mobi_output.py b/src/calibre/gui2/convert/mobi_output.py index 797ab31493..3cd2361b94 100644 --- a/src/calibre/gui2/convert/mobi_output.py +++ b/src/calibre/gui2/convert/mobi_output.py @@ -18,7 +18,8 @@ class PluginWidget(Widget, Ui_Form): def __init__(self, parent, get_option, get_help, db=None, book_id=None): Widget.__init__(self, parent, 'mobi_output', - ['prefer_author_sort', 'rescale_images', 'toc_title'] + ['prefer_author_sort', 'rescale_images', 'toc_title', + 'no_mobi_index', 'dont_compress', 'mobi_periodical'] ) self.db, self.book_id = db, book_id self.initialize_options(get_option, get_help, db, book_id) diff --git a/src/calibre/gui2/convert/mobi_output.ui b/src/calibre/gui2/convert/mobi_output.ui index a91f48d592..63fdba6d34 100644 --- a/src/calibre/gui2/convert/mobi_output.ui +++ b/src/calibre/gui2/convert/mobi_output.ui @@ -41,7 +41,7 @@ - + Qt::Vertical @@ -54,6 +54,27 @@ + + + + Disable generation of MOBI index + + + + + + + Disable compression of the file contents + + + + + + + Generate a periodical rather than a book + + + From e12f0a39c3c87599f9c096bab7f116f7ab2560de Mon Sep 17 00:00:00 2001 From: John Schember Date: Sun, 14 Jun 2009 08:13:44 -0400 Subject: [PATCH 07/18] Stop auto-scroll in detail view. It is unnecessary because appeneding will scroll the view. Also, it prevents the user from looking at earlier messages because it scrolls to the bottom every second. --- src/calibre/gui2/widgets.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/calibre/gui2/widgets.py b/src/calibre/gui2/widgets.py index 9c62f53d3f..ff21a8f67e 100644 --- a/src/calibre/gui2/widgets.py +++ b/src/calibre/gui2/widgets.py @@ -344,8 +344,6 @@ class DetailView(QDialog, Ui_Dialog): self.next_pos = f.tell() if more: self.log.appendPlainText(more.decode('utf-8', 'replace')) - vbar = self.log.verticalScrollBar() - vbar.setValue(vbar.maximum()) class JobsView(TableView): From c47396b0726cc22cbecf51a2b9eed3aadabf7b36 Mon Sep 17 00:00:00 2001 From: John Schember Date: Sun, 14 Jun 2009 12:01:35 -0400 Subject: [PATCH 08/18] Fix bug 2603: Default to preferred output format in bulk convert. --- src/calibre/gui2/convert/bulk.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/calibre/gui2/convert/bulk.py b/src/calibre/gui2/convert/bulk.py index 23336037a1..0b48f2521b 100644 --- a/src/calibre/gui2/convert/bulk.py +++ b/src/calibre/gui2/convert/bulk.py @@ -95,14 +95,13 @@ class BulkConfig(Config): self.stack.setCurrentIndex(idx) def setup_output_formats(self, db, preferred_output_format): - available_formats = '' - available_formats = set([x.lower() for x in - available_formats.split(',')]) + if preferred_output_format: + preferred_output_format = preferred_output_format.lower() output_formats = sorted(available_output_formats()) output_formats.remove('oeb') preferred_output_format = preferred_output_format if \ - preferred_output_format in output_formats else \ - sort_formats_by_preference(output_formats, + preferred_output_format and preferred_output_format \ + in output_formats else sort_formats_by_preference(output_formats, OUTPUT_FORMAT_PREFERENCES)[0] self.output_formats.addItems(list(map(QString, [x.upper() for x in output_formats]))) From 940734ab36a93ba7a4647b25273a009fecd1b820 Mon Sep 17 00:00:00 2001 From: John Schember Date: Sun, 14 Jun 2009 12:08:38 -0400 Subject: [PATCH 09/18] Fix bug 2607: Remove non-numerical characters from ISBN when fetching metadata. --- src/calibre/gui2/dialogs/metadata_single.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/calibre/gui2/dialogs/metadata_single.py b/src/calibre/gui2/dialogs/metadata_single.py index 17c166099d..c6a9400f2c 100644 --- a/src/calibre/gui2/dialogs/metadata_single.py +++ b/src/calibre/gui2/dialogs/metadata_single.py @@ -1,16 +1,19 @@ -from __future__ import with_statement __license__ = 'GPL v3' __copyright__ = '2008, Kovid Goyal ' + ''' The dialog used to edit meta information for a book as well as add/remove formats ''' -import os, time, traceback + +import os +import re +import time +import traceback from PyQt4.QtCore import SIGNAL, QObject, QCoreApplication, Qt, QTimer, QThread from PyQt4.QtGui import QPixmap, QListWidgetItem, QErrorMessage, QDialog, QCompleter - from calibre.gui2 import qstring_to_unicode, error_dialog, file_icon_provider, \ choose_files, pixmap_to_data, choose_images, ResizableDialog from calibre.gui2.dialogs.metadata_single_ui import Ui_MetadataSingleDialog @@ -422,7 +425,7 @@ class MetadataSingleDialog(ResizableDialog, Ui_MetadataSingleDialog): def fetch_metadata(self): - isbn = qstring_to_unicode(self.isbn.text()) + isbn = re.sub('[^\d]', '', qstring_to_unicode(self.isbn.text())) title = qstring_to_unicode(self.title.text()) author = string_to_authors(unicode(self.authors.text()))[0] publisher = qstring_to_unicode(self.publisher.currentText()) From 0c3e217e411974abce13bff7fa1c6ff9c2e52932 Mon Sep 17 00:00:00 2001 From: John Schember Date: Sun, 14 Jun 2009 15:08:38 -0400 Subject: [PATCH 10/18] Fix BeBook device detection. --- src/calibre/devices/bebook/driver.py | 24 ++++++++++++++++++++++-- src/calibre/devices/usbms/device.py | 4 +++- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/src/calibre/devices/bebook/driver.py b/src/calibre/devices/bebook/driver.py index a3e8db917a..324de00823 100644 --- a/src/calibre/devices/bebook/driver.py +++ b/src/calibre/devices/bebook/driver.py @@ -1,9 +1,12 @@ __license__ = 'GPL v3' __copyright__ = '2009, Tijmen Ruizendaal ' + ''' Device driver for BeBook ''' +import re + from calibre.devices.usbms.driver import USBMS class BEBOOK(USBMS): @@ -24,8 +27,8 @@ class BEBOOK(USBMS): WINDOWS_MAIN_MEM = 'FILE-STOR_GADGET' WINDOWS_CARD_A_MEM = 'FILE-STOR_GADGET' - OSX_MAIN_MEM = 'BeBook Internal Memory' - OSX_CARD_A_MEM = 'BeBook Storage Card' + OSX_MAIN_MEM = 'Linux File-Stor Gadget Media' + OSX_CARD_A_MEM = 'Linux File-Stor Gadget Media' MAIN_MEMORY_VOLUME_LABEL = 'BeBook Internal Memory' STORAGE_CARD_VOLUME_LABEL = 'BeBook Storage Card' @@ -43,6 +46,23 @@ class BEBOOK(USBMS): return drives + def osx_sort_names(self, names): + main = names.get('main', None) + card = names.get('carda', None) + + main_num = int(re.findall('\d+', main)[0]) if main else None + card_num = int(re.findall('\d+', card)[0]) if card else None + + if card_num is not None and main_num is not None and card_num < main_num: + names['main'] = card + names['carda'] = main + + if card and not main: + names['main'] = card + names['carda'] = None + + return names + def linux_swap_drives(self, drives): if len(drives) < 2: return drives drives = list(drives) diff --git a/src/calibre/devices/usbms/device.py b/src/calibre/devices/usbms/device.py index 98ba781b0b..8d2c6631a0 100644 --- a/src/calibre/devices/usbms/device.py +++ b/src/calibre/devices/usbms/device.py @@ -265,6 +265,8 @@ class Device(DeviceConfig, DevicePlugin): return subprocess.Popen((ioreg+' -w 0 -S -c IOMedia').split(), stdout=subprocess.PIPE).communicate()[0] + def osx_sort_names(self, names): + return names def get_osx_mountpoints(self, raw=None): raw = self.run_ioreg(raw) @@ -290,7 +292,7 @@ class Device(DeviceConfig, DevicePlugin): get_dev_node(lines[i+1:], 'cardb') if len(names.keys()) == 3: break - return names + return self.osx_sort_names(names) def open_osx(self): mount = subprocess.Popen('mount', shell=True, stdout=subprocess.PIPE).stdout.read() From ab9c4b39f0d1aa9dc041c9ceefbba3412bcd56b7 Mon Sep 17 00:00:00 2001 From: John Schember Date: Sun, 14 Jun 2009 20:33:55 -0400 Subject: [PATCH 11/18] PDF preprocessing rule additions. --- src/calibre/ebooks/conversion/preprocess.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/calibre/ebooks/conversion/preprocess.py b/src/calibre/ebooks/conversion/preprocess.py index 2dc404e586..1cbec251e3 100644 --- a/src/calibre/ebooks/conversion/preprocess.py +++ b/src/calibre/ebooks/conversion/preprocess.py @@ -130,7 +130,11 @@ class HTMLPreProcessor(object): # Have paragraphs show better (re.compile(r''), lambda match : '

'), # Clean up spaces - (re.compile(u'(?<=[\.,:;\?!”"\'])[\s^ ]*(?=<)'), lambda match: ' '), + (re.compile(u'(?<=[\.,;\?!”"\'])[\s^ ]*(?=<)'), lambda match: ' '), + # Connect paragraphs split by - + (re.compile(u'(?<=[^\s][-–])[\s]*(

)*[\s]*(

)*\s*(?=[^\s])'), lambda match: ''), + # Remove - that splits words + (re.compile(u'(?<=[^\s])[-–]+(?=[^\s])'), lambda match: ''), # Add space before and after italics (re.compile(u'(?'), lambda match: ' '), (re.compile(r'(?=\w)'), lambda match: ' '), From 8ff44715fb68c7045bbf655ae1e71e441e996500 Mon Sep 17 00:00:00 2001 From: John Schember Date: Mon, 15 Jun 2009 17:00:59 -0400 Subject: [PATCH 12/18] Enchance error detection for BeBook swap names on OS X. --- src/calibre/devices/bebook/driver.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/calibre/devices/bebook/driver.py b/src/calibre/devices/bebook/driver.py index 324de00823..c732fb0d58 100644 --- a/src/calibre/devices/bebook/driver.py +++ b/src/calibre/devices/bebook/driver.py @@ -50,8 +50,14 @@ class BEBOOK(USBMS): main = names.get('main', None) card = names.get('carda', None) - main_num = int(re.findall('\d+', main)[0]) if main else None - card_num = int(re.findall('\d+', card)[0]) if card else None + try: + main_num = int(re.findall('\d+', main)[0]) if main else None + except: + main_num = None + try: + card_num = int(re.findall('\d+', card)[0]) if card else None + except: + card_num = None if card_num is not None and main_num is not None and card_num < main_num: names['main'] = card From 7999b3c188185e862a7ad08185eabb754550b06c Mon Sep 17 00:00:00 2001 From: John Schember Date: Mon, 15 Jun 2009 19:22:49 -0400 Subject: [PATCH 13/18] Possible fix for only detecting BeBook main memory and not card. --- src/calibre/devices/bebook/driver.py | 4 ++++ src/calibre/devices/usbms/device.py | 10 +++++----- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/calibre/devices/bebook/driver.py b/src/calibre/devices/bebook/driver.py index c732fb0d58..2fb756b532 100644 --- a/src/calibre/devices/bebook/driver.py +++ b/src/calibre/devices/bebook/driver.py @@ -44,6 +44,10 @@ class BEBOOK(USBMS): drives['main'] = card drives['carda'] = main + if card and not main: + drives['main'] = card + drives['carda'] = None + return drives def osx_sort_names(self, names): diff --git a/src/calibre/devices/usbms/device.py b/src/calibre/devices/usbms/device.py index 8d2c6631a0..6450b5e33c 100644 --- a/src/calibre/devices/usbms/device.py +++ b/src/calibre/devices/usbms/device.py @@ -235,12 +235,12 @@ class Device(DeviceConfig, DevicePlugin): wmi = __import__('wmi', globals(), locals(), [], -1) c = wmi.WMI(find_classes=False) for drive in c.Win32_DiskDrive(): - if self.windows_match_device(drive, 'WINDOWS_CARD_A_MEM'): - drives['carda'] = self.windows_get_drive_prefix(drive) - elif self.windows_match_device(drive, 'WINDOWS_CARD_B_MEM'): - drives['cardb'] = self.windows_get_drive_prefix(drive) - elif self.windows_match_device(drive, 'WINDOWS_MAIN_MEM'): + if self.windows_match_device(drive, 'WINDOWS_MAIN_MEM') and not drives.get('main', None): drives['main'] = self.windows_get_drive_prefix(drive) + elif self.windows_match_device(drive, 'WINDOWS_CARD_A_MEM') and not drives.get('carda', None): + drives['carda'] = self.windows_get_drive_prefix(drive) + elif self.windows_match_device(drive, 'WINDOWS_CARD_B_MEM') and not drives.get('cardb', None): + drives['cardb'] = self.windows_get_drive_prefix(drive) if 'main' in drives.keys() and 'carda' in drives.keys() and \ 'cardb' in drives.keys(): break From fb92bbbf507e1be54838c638902c4e5d6c20bbcd Mon Sep 17 00:00:00 2001 From: John Schember Date: Mon, 15 Jun 2009 20:25:19 -0400 Subject: [PATCH 14/18] Fix bug 2587: Only add \n's to head if they are not alreay present. --- src/calibre/ebooks/conversion/preprocess.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/calibre/ebooks/conversion/preprocess.py b/src/calibre/ebooks/conversion/preprocess.py index 1cbec251e3..8081dce325 100644 --- a/src/calibre/ebooks/conversion/preprocess.py +++ b/src/calibre/ebooks/conversion/preprocess.py @@ -21,7 +21,9 @@ _span_pat = re.compile('', re.DOTALL|re.IGNORECASE) def sanitize_head(match): x = match.group(1) x = _span_pat.sub('', x) - return '\n'+x+'\n' + x = ('\n%s' % x) if not x.startswith('\n') else x + x += '\n' if not x.endswith('\n') else '' + return '%s' % x def chap_head(match): chap = match.group('chap') From d5bf14f1d88b1e3f7cb57bc0a84f1c146636a09d Mon Sep 17 00:00:00 2001 From: John Schember Date: Mon, 15 Jun 2009 20:27:17 -0400 Subject: [PATCH 15/18] Fix bug 2587: Use WayneD solution because it's cleaner. --- src/calibre/ebooks/conversion/preprocess.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/calibre/ebooks/conversion/preprocess.py b/src/calibre/ebooks/conversion/preprocess.py index 8081dce325..816dd54ade 100644 --- a/src/calibre/ebooks/conversion/preprocess.py +++ b/src/calibre/ebooks/conversion/preprocess.py @@ -21,9 +21,7 @@ _span_pat = re.compile('', re.DOTALL|re.IGNORECASE) def sanitize_head(match): x = match.group(1) x = _span_pat.sub('', x) - x = ('\n%s' % x) if not x.startswith('\n') else x - x += '\n' if not x.endswith('\n') else '' - return '%s' % x + return '\n%s\n' % x def chap_head(match): chap = match.group('chap') @@ -86,7 +84,7 @@ class HTMLPreProcessor(object): PREPROCESS = [ # Some idiotic HTML generators (Frontpage I'm looking at you) # Put all sorts of crap into . This messes up lxml - (re.compile(r']*>(.*?)', re.IGNORECASE|re.DOTALL), + (re.compile(r']*>\n*(.*?)\n*', re.IGNORECASE|re.DOTALL), sanitize_head), # Convert all entities, since lxml doesn't handle them well (re.compile(r'&(\S+?);'), convert_entities), From 6a23f90a11b8e0b34cb62568655fb9e8234fad79 Mon Sep 17 00:00:00 2001 From: John Schember Date: Mon, 15 Jun 2009 20:54:54 -0400 Subject: [PATCH 16/18] =?UTF-8?q?partial=20fix=20for=20bug=202623,=20write?= =?UTF-8?q?s=20characters=20such=20as=20=C3=A6=20to=20file=20but=20ebook-v?= =?UTF-8?q?iewr/firefox=20cannot=20load=20the=20image=20with=20the=20chara?= =?UTF-8?q?cter=20in=20the=20file=20name.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/calibre/ebooks/oeb/iterator.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/calibre/ebooks/oeb/iterator.py b/src/calibre/ebooks/oeb/iterator.py index f4eb2c5a29..4fc7b7ea1b 100644 --- a/src/calibre/ebooks/oeb/iterator.py +++ b/src/calibre/ebooks/oeb/iterator.py @@ -149,7 +149,7 @@ class EbookIterator(object): if self.ebook_ext in ('lit', 'mobi', 'prc', 'opf') and cover: cfile = os.path.join(os.path.dirname(self.spine[0]), 'calibre_iterator_cover.html') - open(cfile, 'wb').write(TITLEPAGE%cover) + open(cfile, 'wb').write(TITLEPAGE%cover.encode('utf-8')) self.spine[0:0] = [SpineItem(cfile)] self.delete_on_exit.append(cfile) From 4598b0238c4f9fd1d2b6ceebb92d4b5b1562b54c Mon Sep 17 00:00:00 2001 From: John Schember Date: Tue, 16 Jun 2009 07:07:45 -0400 Subject: [PATCH 17/18] Revert last change because it might not always work. --- src/calibre/ebooks/oeb/iterator.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/calibre/ebooks/oeb/iterator.py b/src/calibre/ebooks/oeb/iterator.py index 4fc7b7ea1b..f4eb2c5a29 100644 --- a/src/calibre/ebooks/oeb/iterator.py +++ b/src/calibre/ebooks/oeb/iterator.py @@ -149,7 +149,7 @@ class EbookIterator(object): if self.ebook_ext in ('lit', 'mobi', 'prc', 'opf') and cover: cfile = os.path.join(os.path.dirname(self.spine[0]), 'calibre_iterator_cover.html') - open(cfile, 'wb').write(TITLEPAGE%cover.encode('utf-8')) + open(cfile, 'wb').write(TITLEPAGE%cover) self.spine[0:0] = [SpineItem(cfile)] self.delete_on_exit.append(cfile) From ea87d99899b9e77ab44954841b6560663ac3980e Mon Sep 17 00:00:00 2001 From: John Schember Date: Wed, 17 Jun 2009 19:11:07 -0400 Subject: [PATCH 18/18] fix bug 2648: Ignore garbage characters in pdb title. --- src/calibre/ebooks/pdb/header.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/calibre/ebooks/pdb/header.py b/src/calibre/ebooks/pdb/header.py index 5785500c59..c012110a62 100644 --- a/src/calibre/ebooks/pdb/header.py +++ b/src/calibre/ebooks/pdb/header.py @@ -30,7 +30,7 @@ class PdbHeaderReader(object): def name(self): self.stream.seek(0) - return self.stream.read(32).replace('\x00', '') + return re.sub('[^-A-Za-z0-9]+', '', self.stream.read(32).replace('\x00', '')) def full_section_info(self, number): if number not in range(0, self.num_sections):