From 312754acb6bace5807cd271de6028c4a743dede7 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 10 Jan 2021 07:39:50 +0530 Subject: [PATCH 1/3] String changes --- manual/faq.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manual/faq.rst b/manual/faq.rst index daddcf1051..7e7df71c7f 100644 --- a/manual/faq.rst +++ b/manual/faq.rst @@ -61,7 +61,7 @@ In the MOBI format, the situation is a little confused. This is because the MOBI Now it might well seem to you that the MOBI book has two identical ToCs. Remember that one is semantically a content ToC and the other is a metadata ToC, even though both might have exactly the same entries and look the same. One can be accessed directly from the Kindle's menus, the other cannot. -When converting to MOBI, calibre detects the *metadata ToC* in the input document and generates an end-of-file ToC in the output MOBI file. You can turn this off by an option in the MOBI Output settings. You can also tell calibre whether to put it and the start or the end of the book via an option in the MOBI Output settings. Remember this ToC is semantically a *metadata ToC*, in any format other than MOBI it *cannot not be part of the text*. The fact that it is part of the text in MOBI is an accident caused by the limitations of MOBI. If you want a ToC at a particular location in your document text, create one by hand. So we strongly recommend that you leave the default as it is, i.e. with the metadata ToC at the end of the book. Also note that if you disable the generation of the end-of-file ToC the resulting MOBI file may not function correctly on a Kindle, since the Kindle's use the metadata ToC for many things, including the Page Flip feature. +When converting to MOBI, calibre detects the *metadata ToC* in the input document and generates an end-of-file ToC in the output MOBI file. You can turn this off by an option in the MOBI Output settings. You can also tell calibre whether to put it at the start or the end of the book via an option in the MOBI Output settings. Remember this ToC is semantically a *metadata ToC*, in any format other than MOBI it *cannot not be part of the text*. The fact that it is part of the text in MOBI is an accident caused by the limitations of MOBI. If you want a ToC at a particular location in your document text, create one by hand. So we strongly recommend that you leave the default as it is, i.e. with the metadata ToC at the end of the book. Also note that if you disable the generation of the end-of-file ToC the resulting MOBI file may not function correctly on a Kindle, since the Kindle's use the metadata ToC for many things, including the Page Flip feature. If you have a hand edited ToC in the input document, you can use the ToC detection options in calibre to automatically generate the metadata ToC from it. See the conversion section of the User Manual for more details on how to use these options. From 31a1ce8d4ad61d223f135046de03b1b1ab5ca7a4 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 10 Jan 2021 16:42:34 +0530 Subject: [PATCH 2/3] Fix #1910904 [[Enhancement] Use a Cancel button instead of a Discard button](https://bugs.launchpad.net/calibre/+bug/1910904) --- src/calibre/gui2/preferences/main.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/calibre/gui2/preferences/main.py b/src/calibre/gui2/preferences/main.py index 943b4f158a..a62b774732 100644 --- a/src/calibre/gui2/preferences/main.py +++ b/src/calibre/gui2/preferences/main.py @@ -238,10 +238,10 @@ class Preferences(QDialog): self.stack = QStackedWidget(self) self.bb = QDialogButtonBox( QDialogButtonBox.StandardButton.Close | QDialogButtonBox.StandardButton.Apply | - QDialogButtonBox.StandardButton.Discard | QDialogButtonBox.StandardButton.RestoreDefaults + QDialogButtonBox.StandardButton.Cancel | QDialogButtonBox.StandardButton.RestoreDefaults ) self.bb.button(QDialogButtonBox.StandardButton.Apply).clicked.connect(self.accept) - self.bb.button(QDialogButtonBox.StandardButton.Discard).clicked.connect(self.reject) + self.bb.button(QDialogButtonBox.StandardButton.Cancel).clicked.connect(self.reject) self.bb.button(QDialogButtonBox.StandardButton.RestoreDefaults).setIcon(QIcon(I('clear_left.png'))) self.bb.button(QDialogButtonBox.StandardButton.RestoreDefaults).clicked.connect(self.restore_defaults) self.wizard_button = self.bb.addButton(_('Run Welcome &wizard'), QDialogButtonBox.ButtonRole.ActionRole) @@ -259,7 +259,7 @@ class Preferences(QDialog): self.setContextMenuPolicy(Qt.ContextMenuPolicy.NoContextMenu) self.title_bar = TitleBar(self) for ac, tt in [(QDialogButtonBox.StandardButton.Apply, _('Save changes')), - (QDialogButtonBox.StandardButton.Discard, _('Cancel and return to overview'))]: + (QDialogButtonBox.StandardButton.Cancel, _('Cancel and return to overview'))]: self.bb.button(ac).setToolTip(tt) l.addWidget(self.title_bar), l.addWidget(self.stack), l.addWidget(self.bb) @@ -323,7 +323,7 @@ class Preferences(QDialog): self.bb.button(QDialogButtonBox.StandardButton.Close).setVisible(False) self.wizard_button.setVisible(False) - for button in (QDialogButtonBox.StandardButton.Apply, QDialogButtonBox.StandardButton.RestoreDefaults, QDialogButtonBox.StandardButton.Discard): + for button in (QDialogButtonBox.StandardButton.Apply, QDialogButtonBox.StandardButton.RestoreDefaults, QDialogButtonBox.StandardButton.Cancel): button = self.bb.button(button) button.setVisible(True) @@ -353,7 +353,7 @@ class Preferences(QDialog): self.title_bar.show_plugin() self.setWindowIcon(QIcon(I('config.png'))) - for button in (QDialogButtonBox.StandardButton.Apply, QDialogButtonBox.StandardButton.RestoreDefaults, QDialogButtonBox.StandardButton.Discard): + for button in (QDialogButtonBox.StandardButton.Apply, QDialogButtonBox.StandardButton.RestoreDefaults, QDialogButtonBox.StandardButton.Cancel): button = self.bb.button(button) button.setVisible(False) From e91ebda5e862ea7e6ae60dfda5fbf74d6e8b5b7a Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Mon, 11 Jan 2021 07:19:25 +0530 Subject: [PATCH 3/3] When detecting plugin zip safety dont use a hardcoded list of native code extensions --- src/calibre/customize/__init__.py | 38 ++++++++++++++++--------------- 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/src/calibre/customize/__init__.py b/src/calibre/customize/__init__.py index 2437ad542e..2625c569d9 100644 --- a/src/calibre/customize/__init__.py +++ b/src/calibre/customize/__init__.py @@ -278,24 +278,26 @@ class Plugin(object): # {{{ ''' if self.plugin_path is not None: from calibre.utils.zipfile import ZipFile - zf = ZipFile(self.plugin_path) - extensions = {x.rpartition('.')[-1].lower() for x in - zf.namelist()} - zip_safe = True - for ext in ('pyd', 'so', 'dll', 'dylib'): - if ext in extensions: - zip_safe = False - break - if zip_safe: - sys.path.insert(0, self.plugin_path) - self.sys_insertion_path = self.plugin_path - else: - from calibre.ptempfile import TemporaryDirectory - self._sys_insertion_tdir = TemporaryDirectory('plugin_unzip') - self.sys_insertion_path = self._sys_insertion_tdir.__enter__(*args) - zf.extractall(self.sys_insertion_path) - sys.path.insert(0, self.sys_insertion_path) - zf.close() + from importlib.machinery import EXTENSION_SUFFIXES + with ZipFile(self.plugin_path) as zf: + extensions = {x.lower() for x in EXTENSION_SUFFIXES} + zip_safe = True + for name in zf.namelist(): + for q in extensions: + if name.endswith(q): + zip_safe = False + break + if not zip_safe: + break + if zip_safe: + sys.path.insert(0, self.plugin_path) + self.sys_insertion_path = self.plugin_path + else: + from calibre.ptempfile import TemporaryDirectory + self._sys_insertion_tdir = TemporaryDirectory('plugin_unzip') + self.sys_insertion_path = self._sys_insertion_tdir.__enter__(*args) + zf.extractall(self.sys_insertion_path) + sys.path.insert(0, self.sys_insertion_path) def __exit__(self, *args): ip, it = getattr(self, 'sys_insertion_path', None), getattr(self,