From 163f90f08385bf1ed4157bd833587483088cdcb3 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sat, 19 Dec 2020 09:01:13 +0530 Subject: [PATCH] Fix errors reported by pyflakes --- src/calibre/gui2/store/stores/nexto_plugin.py | 5 +++-- src/calibre/gui2/tweak_book/preview.py | 9 +++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/calibre/gui2/store/stores/nexto_plugin.py b/src/calibre/gui2/store/stores/nexto_plugin.py index 55c0a988a3..3e25dad8f6 100644 --- a/src/calibre/gui2/store/stores/nexto_plugin.py +++ b/src/calibre/gui2/store/stores/nexto_plugin.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- from __future__ import absolute_import, division, print_function, unicode_literals -store_version = 5 # Needed for dynamic plugin loading +store_version = 6 # Needed for dynamic plugin loading __license__ = 'GPL 3' __copyright__ = '2011-2020, Tomasz Długosz ' @@ -9,6 +9,7 @@ __docformat__ = 'restructuredtext en' import re from contextlib import closing +from base64 import standard_b64encode try: from urllib.parse import quote_plus except ImportError: @@ -29,7 +30,7 @@ from calibre.gui2.store.web_store_dialog import WebStoreDialog def as_base64(data): if not isinstance(data, bytes): data = data.encode('utf-8') - ans = b64encode(data) + ans = standard_b64encode(data) if isinstance(ans, bytes): ans = ans.decode('ascii') return ans diff --git a/src/calibre/gui2/tweak_book/preview.py b/src/calibre/gui2/tweak_book/preview.py index 9fb7c502a4..7c0685540b 100644 --- a/src/calibre/gui2/tweak_book/preview.py +++ b/src/calibre/gui2/tweak_book/preview.py @@ -8,8 +8,6 @@ import textwrap import time from collections import defaultdict from functools import partial -from threading import Thread - from PyQt5.Qt import ( QApplication, QByteArray, QHBoxLayout, QIcon, QLabel, QMenu, QSize, QSizePolicy, QStackedLayout, Qt, QTimer, QToolBar, QUrl, QVBoxLayout, QWidget, pyqtSignal @@ -18,6 +16,7 @@ from PyQt5.QtWebEngineCore import QWebEngineUrlSchemeHandler from PyQt5.QtWebEngineWidgets import ( QWebEnginePage, QWebEngineProfile, QWebEngineScript, QWebEngineView ) +from threading import Thread from calibre import prints from calibre.constants import ( @@ -25,7 +24,9 @@ from calibre.constants import ( ) from calibre.ebooks.oeb.base import OEB_DOCS, XHTML_MIME, serialize from calibre.ebooks.oeb.polish.parsing import parse -from calibre.gui2 import NO_URL_FORMATTING, error_dialog, is_dark_theme, safe_open_url +from calibre.gui2 import ( + NO_URL_FORMATTING, error_dialog, is_dark_theme, safe_open_url +) from calibre.gui2.palette import dark_color, dark_link_color, dark_text_color from calibre.gui2.tweak_book import TOP, actions, current_container, editors, tprefs from calibre.gui2.tweak_book.file_list import OpenWithHandler @@ -459,7 +460,7 @@ class WebView(RestartingWebEngineView, OpenWithHandler): menu.addAction(actions['reload-preview']) menu.addAction(QIcon(I('debug.png')), _('Inspect element'), self.inspect) if url.partition(':')[0].lower() in {'http', 'https'}: - menu.addAction(_('Open link'), partial(open_url, data.linkUrl())) + menu.addAction(_('Open link'), partial(safe_open_url, data.linkUrl())) if data.MediaTypeImage <= data.mediaType() <= data.MediaTypeFile: url = data.mediaUrl() if url.scheme() == FAKE_PROTOCOL: