diff --git a/src/calibre/devices/apple/driver.py b/src/calibre/devices/apple/driver.py index ed26ae86e1..7a9562f136 100644 --- a/src/calibre/devices/apple/driver.py +++ b/src/calibre/devices/apple/driver.py @@ -17,9 +17,9 @@ from calibre.ebooks.metadata import authors_to_string, MetaInformation, \ title_sort from calibre.ebooks.metadata.book.base import Metadata from calibre.ebooks.metadata.epub import set_metadata -from calibre.gui2.dialogs.confirm_delete import _config_name +from calibre.gui2.dialogs.confirm_delete import config_name from calibre.library.server.utils import strftime -from calibre.utils.config import config_dir, dynamic, DynamicConfig, prefs +from calibre.utils.config import config_dir, dynamic, prefs from calibre.utils.date import now, parse_date from calibre.utils.logging import Log from calibre.utils.zipfile import ZipFile @@ -33,8 +33,8 @@ class AppleOpenFeedback(OpenFeedback): self.plugin = plugin def custom_dialog(self, parent): - from PyQt4.Qt import (QCheckBox, QDialog, QDialogButtonBox, QIcon, - QLabel, QPixmap, QPushButton, QSize, QVBoxLayout) + from PyQt4.Qt import (QDialog, QDialogButtonBox, QIcon, + QLabel, QPushButton, QVBoxLayout) class Dialog(QDialog): @@ -45,19 +45,20 @@ class AppleOpenFeedback(OpenFeedback): self.l = l = QVBoxLayout() self.setLayout(l) msg = QLabel() - msg.setText( + msg.setText(_( '
If you do not want calibre to recognize your Apple iDevice ' 'when it is connected to your computer, ' 'click Disable Apple Driver.
' 'To transfer books to your iDevice, ' 'click Disable Apple Driver, ' "then use the 'Connect to iTunes' method recommended in the " - 'Calibre + iDevices FAQ, ' + 'Calibre + iDevices FAQ, ' 'using the Connect/Share|Connect to iTunes menu item.
' 'Enabling the Apple driver for direct connection to iDevices ' 'is an unsupported advanced user mode.
' '' - ) + )) + msg.setOpenExternalLinks(True) msg.setWordWrap(True) l.addWidget(msg) @@ -75,16 +76,18 @@ class AppleOpenFeedback(OpenFeedback): self.setWindowIcon(QIcon(I(pixmap))) self.resize(self.sizeHint()) - if Dialog(parent).exec_(): - # Enable Apple driver, inhibit future display of dialog - # Reset dialog with Preferences|Behavior|Reset all disabled confirmation dialogs - self.log.info(" Apple driver ENABLED") - dynamic[_config_name(self.plugin.DISPLAY_DISABLE_DIALOG)] = False - else: - # Disable Apple driver - from calibre.customize.ui import disable_plugin - self.log.info(" Apple driver DISABLED") - disable_plugin(self.plugin) + self.finished.connect(self.do_it) + + def do_it(self, return_code): + if return_code == self.Accepted: + self.log.info(" Apple driver ENABLED") + dynamic[config_name(self.plugin.DISPLAY_DISABLE_DIALOG)] = False + else: + from calibre.customize.ui import disable_plugin + self.log.info(" Apple driver DISABLED") + disable_plugin(self.plugin) + + return Dialog(parent) from PIL import Image as PILImage @@ -179,7 +182,7 @@ class ITUNES(DriverBase): #: The version of this plugin as a 3-tuple (major, minor, revision) version = (1,0,0) - DISPLAY_DISABLE_DIALOG = "display_disable_dialog" + DISPLAY_DISABLE_DIALOG = "display_disable_apple_driver_dialog" # EXTRA_CUSTOMIZATION_MESSAGE indexes USE_SERIES_AS_CATEGORY = 0 @@ -805,7 +808,7 @@ class ITUNES(DriverBase): # Display a dialog recommending using 'Connect to iTunes' if user hasn't # previously disabled the dialog - if dynamic.get(_config_name(self.DISPLAY_DISABLE_DIALOG),True): + if dynamic.get(config_name(self.DISPLAY_DISABLE_DIALOG),True): raise AppleOpenFeedback(self) else: if DEBUG: diff --git a/src/calibre/devices/errors.py b/src/calibre/devices/errors.py index 05c30c2f72..7b11b6933f 100644 --- a/src/calibre/devices/errors.py +++ b/src/calibre/devices/errors.py @@ -43,8 +43,8 @@ class OpenFeedback(DeviceError): def custom_dialog(self, parent): ''' - If you need to show the user a custom dialog, create and - run it from a custom_dialog() method in your subclass. + If you need to show the user a custom dialog, instead if just + displaying the feedback_msg, create and return it here. ''' raise NotImplementedError diff --git a/src/calibre/ebooks/conversion/plumber.py b/src/calibre/ebooks/conversion/plumber.py index 6272e7b10b..b26befe075 100644 --- a/src/calibre/ebooks/conversion/plumber.py +++ b/src/calibre/ebooks/conversion/plumber.py @@ -1003,8 +1003,10 @@ OptionRecommendation(name='sr3_replace', self.opts.insert_blank_line = oibl self.opts.remove_paragraph_spacing = orps - from calibre.ebooks.oeb.transforms.page_margin import RemoveFakeMargins + from calibre.ebooks.oeb.transforms.page_margin import \ + RemoveFakeMargins, RemoveAdobeMargins RemoveFakeMargins()(self.oeb, self.log, self.opts) + RemoveAdobeMargins()(self.oeb, self.log, self.opts) pr(0.9) self.flush() diff --git a/src/calibre/ebooks/metadata/meta.py b/src/calibre/ebooks/metadata/meta.py index cbd9db3f04..b0c43a8182 100644 --- a/src/calibre/ebooks/metadata/meta.py +++ b/src/calibre/ebooks/metadata/meta.py @@ -182,6 +182,19 @@ def metadata_from_filename(name, pat=None): mi.isbn = si except (IndexError, ValueError): pass + try: + publisher = match.group('publisher') + mi.publisher = publisher + except (IndexError, ValueError): + pass + try: + pubdate = match.group('published') + if pubdate: + from calibre.utils.date import parse_date + mi.pubdate = parse_date(pubdate) + except: + pass + if mi.is_null('title'): mi.title = name return mi diff --git a/src/calibre/ebooks/metadata/sources/identify.py b/src/calibre/ebooks/metadata/sources/identify.py index 53fb3a9ea4..5bc0c5b256 100644 --- a/src/calibre/ebooks/metadata/sources/identify.py +++ b/src/calibre/ebooks/metadata/sources/identify.py @@ -79,7 +79,7 @@ def identify(log, abort, title=None, authors=None, identifiers=[], timeout=30): time.sleep(0.2) if get_results() and first_result_at is None: - first_result_at = time.time() + first_result_at = time.time() if not is_worker_alive(workers): break diff --git a/src/calibre/ebooks/mobi/mobiml.py b/src/calibre/ebooks/mobi/mobiml.py index 189739986d..40ad5e9e78 100644 --- a/src/calibre/ebooks/mobi/mobiml.py +++ b/src/calibre/ebooks/mobi/mobiml.py @@ -102,6 +102,7 @@ class MobiMLizer(object): def __call__(self, oeb, context): oeb.logger.info('Converting XHTML to Mobipocket markup...') self.oeb = oeb + self.log = self.oeb.logger self.opts = context self.profile = profile = context.dest self.fnums = fnums = dict((v, k) for k, v in profile.fnums.items()) @@ -118,6 +119,10 @@ class MobiMLizer(object): del oeb.guide['cover'] item = oeb.manifest.hrefs[href] if item.spine_position is not None: + self.log.warn('Found an HTML cover,', item.href, 'removing it.', + 'If you find some content missing from the output MOBI, it ' + 'is because you misidentified the HTML cover in the input ' + 'document') oeb.spine.remove(item) if item.media_type in OEB_DOCS: self.oeb.manifest.remove(item) @@ -206,7 +211,11 @@ class MobiMLizer(object): vspace = bstate.vpadding + bstate.vmargin bstate.vpadding = bstate.vmargin = 0 if tag not in TABLE_TAGS: - wrapper.attrib['height'] = self.mobimlize_measure(vspace) + if tag in ('ul', 'ol') and vspace > 0: + wrapper.addprevious(etree.Element(XHTML('div'), + height=self.mobimlize_measure(vspace))) + else: + wrapper.attrib['height'] = self.mobimlize_measure(vspace) para.attrib['width'] = self.mobimlize_measure(indent) elif tag == 'table' and vspace > 0: vspace = int(round(vspace / self.profile.fbase)) diff --git a/src/calibre/ebooks/oeb/transforms/margins.py b/src/calibre/ebooks/oeb/transforms/margins.py deleted file mode 100644 index fbdf2e63fd..0000000000 --- a/src/calibre/ebooks/oeb/transforms/margins.py +++ /dev/null @@ -1,56 +0,0 @@ -#!/usr/bin/env python -# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai - -__license__ = 'GPL v3' -__copyright__ = '2010, Kovid Goyal