Wed, 25 Sep 2019 19:11:13 +0200
Continued to resolve code style issue M841.
--- a/eric6/WebBrowser/ClosedTabsManager.py Wed Sep 25 19:00:09 2019 +0200 +++ b/eric6/WebBrowser/ClosedTabsManager.py Wed Sep 25 19:11:13 2019 +0200 @@ -34,9 +34,11 @@ @param other reference to the object to compare against (ClosedTab) @return flag indicating equality of the tabs (boolean) """ - return self.url == other.url and \ - self.title == other.title and \ + return ( + self.url == other.url and + self.title == other.title and self.position == other.position + ) class ClosedTabsManager(QObject):
--- a/eric6/WebBrowser/History/HistoryCompleter.py Wed Sep 25 19:00:09 2019 +0200 +++ b/eric6/WebBrowser/History/HistoryCompleter.py Wed Sep 25 19:11:13 2019 +0200 @@ -197,8 +197,10 @@ url_L = self.sourceModel().data(left, HistoryModel.UrlRole).host() title_L = self.sourceModel().data(left, HistoryModel.TitleRole) - if self.__wordMatcher.indexIn(url_L) != -1 or \ - self.__wordMatcher.indexIn(title_L) != -1: + if ( + self.__wordMatcher.indexIn(url_L) != -1 or + self.__wordMatcher.indexIn(title_L) != -1 + ): frequency_L *= 2 frequency_R = self.sourceModel().data(
--- a/eric6/WebBrowser/Passwords/PasswordManager.py Wed Sep 25 19:00:09 2019 +0200 +++ b/eric6/WebBrowser/Passwords/PasswordManager.py Wed Sep 25 19:11:13 2019 +0200 @@ -314,9 +314,10 @@ elif mb.clickedButton() == noButton: return - self.__logins[key] = \ - (userName, - Utilities.crypto.pwConvert(password, encode=True)) + self.__logins[key] = ( + userName, + Utilities.crypto.pwConvert(password, encode=True) + ) from .LoginForm import LoginForm form = LoginForm() form.url = url
--- a/eric6/WebBrowser/SearchWidget.py Wed Sep 25 19:00:09 2019 +0200 +++ b/eric6/WebBrowser/SearchWidget.py Wed Sep 25 19:11:13 2019 +0200 @@ -37,10 +37,12 @@ self.findPrevButton.setIcon(UI.PixmapCache.getIcon("1leftarrow.png")) self.findNextButton.setIcon(UI.PixmapCache.getIcon("1rightarrow.png")) - self.__defaultBaseColor = \ + self.__defaultBaseColor = ( self.findtextCombo.lineEdit().palette().color(QPalette.Base) - self.__defaultTextColor = \ + ) + self.__defaultTextColor = ( self.findtextCombo.lineEdit().palette().color(QPalette.Text) + ) self.__findHistory = [] self.__havefound = False
--- a/eric6/WebBrowser/WebBrowserClearPrivateDataDialog.py Wed Sep 25 19:00:09 2019 +0200 +++ b/eric6/WebBrowser/WebBrowserClearPrivateDataDialog.py Wed Sep 25 19:11:13 2019 +0200 @@ -10,8 +10,9 @@ from PyQt5.QtWidgets import QDialog -from .Ui_WebBrowserClearPrivateDataDialog import \ +from .Ui_WebBrowserClearPrivateDataDialog import ( Ui_WebBrowserClearPrivateDataDialog +) class WebBrowserClearPrivateDataDialog(QDialog,
--- a/eric6/WebBrowser/WebBrowserLanguagesDialog.py Wed Sep 25 19:00:09 2019 +0200 +++ b/eric6/WebBrowser/WebBrowserLanguagesDialog.py Wed Sep 25 19:11:13 2019 +0200 @@ -170,16 +170,21 @@ allLanguages = [] countries = [l.country() for l in QLocale.matchingLocales( language, QLocale.AnyScript, QLocale.AnyCountry)] - languageString = "{0} [{1}]"\ - .format(QLocale.languageToString(language), - QLocale(language).name().split('_')[0]) + languageString = ( + "{0} [{1}]" + ).format( + QLocale.languageToString(language), + QLocale(language).name().split('_')[0] + ) allLanguages.append(languageString) for country in countries: - languageString = "{0}/{1} [{2}]"\ - .format(QLocale.languageToString(language), - QLocale.countryToString(country), - '-'.join(QLocale(language, country).name() - .split('_')).lower()) + languageString = ( + "{0}/{1} [{2}]" + ).format( + QLocale.languageToString(language), + QLocale.countryToString(country), + '-'.join(QLocale(language, country).name().split('_')).lower() + ) if languageString not in allLanguages: allLanguages.append(languageString)
--- a/eric6/WebBrowser/WebBrowserPage.py Wed Sep 25 19:00:09 2019 +0200 +++ b/eric6/WebBrowser/WebBrowserPage.py Wed Sep 25 19:11:13 2019 +0200 @@ -8,11 +8,13 @@ Module implementing the helpbrowser using QWebView. """ -from PyQt5.QtCore import pyqtSlot, pyqtSignal, QUrl, QUrlQuery, QTimer, \ - QEventLoop, QPoint, QPointF +from PyQt5.QtCore import ( + pyqtSlot, pyqtSignal, QUrl, QUrlQuery, QTimer, QEventLoop, QPoint, QPointF +) from PyQt5.QtGui import QDesktopServices -from PyQt5.QtWebEngineWidgets import QWebEnginePage, QWebEngineSettings, \ - QWebEngineScript +from PyQt5.QtWebEngineWidgets import ( + QWebEnginePage, QWebEngineSettings, QWebEngineScript +) from PyQt5.QtWebChannel import QWebChannel from E5Gui import E5MessageBox @@ -122,8 +124,10 @@ return False # GreaseMonkey - if type_ == QWebEnginePage.NavigationTypeLinkClicked and \ - url.toString().endswith(".user.js"): + if ( + type_ == QWebEnginePage.NavigationTypeLinkClicked and + url.toString().endswith(".user.js") + ): WebBrowserWindow.greaseMonkeyManager().downloadScript(url) return False @@ -139,16 +143,21 @@ # Safe Browsing self.__badSite = False - from WebBrowser.SafeBrowsing.SafeBrowsingManager import \ + from WebBrowser.SafeBrowsing.SafeBrowsingManager import ( SafeBrowsingManager - if SafeBrowsingManager.isEnabled() and \ - url.scheme() not in \ - SafeBrowsingManager.getIgnoreSchemes(): - threatLists = \ + ) + if ( + SafeBrowsingManager.isEnabled() and + url.scheme() not in SafeBrowsingManager.getIgnoreSchemes() + ): + threatLists = ( WebBrowserWindow.safeBrowsingManager().lookupUrl(url)[0] + ) if threatLists: - threatMessages = WebBrowserWindow.safeBrowsingManager()\ + threatMessages = ( + WebBrowserWindow.safeBrowsingManager() .getThreatMessages(threatLists) + ) res = E5MessageBox.warning( WebBrowserWindow.getWindow(), self.tr("Suspicuous URL detected"), @@ -164,8 +173,10 @@ return False self.__badSite = True - threatType = WebBrowserWindow.safeBrowsingManager()\ + threatType = ( + WebBrowserWindow.safeBrowsingManager() .getThreatType(threatLists[0]) + ) self.safeBrowsingBad.emit(threatType, "".join(threatMessages)) result = QWebEnginePage.acceptNavigationRequest(self, url, type_, @@ -198,8 +209,11 @@ @param url new URL @type QUrl """ - if not url.isEmpty() and url.scheme() == "eric" and \ - not self.isJavaScriptEnabled(): + if ( + not url.isEmpty() and + url.scheme() == "eric" and + not self.isJavaScriptEnabled() + ): self.settings().setAttribute(QWebEngineSettings.JavascriptEnabled, True) self.triggerAction(QWebEnginePage.Reload) @@ -544,14 +558,16 @@ @param request reference to the registration request @type QWebEngineRegisterProtocolHandlerRequest """ - from PyQt5.QtWebEngineCore import \ + from PyQt5.QtWebEngineCore import ( QWebEngineRegisterProtocolHandlerRequest + ) if self.__registerProtocolHandlerRequest: del self.__registerProtocolHandlerRequest self.__registerProtocolHandlerRequest = None - self.__registerProtocolHandlerRequest = \ + self.__registerProtocolHandlerRequest = ( QWebEngineRegisterProtocolHandlerRequest(request) + ) except TypeError: # this is supported with Qt 5.12 and later pass @@ -563,9 +579,11 @@ @return registered protocol handler request URL @rtype QUrl """ - if self.__registerProtocolHandlerRequest and \ + if ( + self.__registerProtocolHandlerRequest and (self.url().host() == - self.__registerProtocolHandlerRequest.origin().host()): + self.__registerProtocolHandlerRequest.origin().host()) + ): return self.__registerProtocolHandlerRequest.origin() else: return QUrl() @@ -577,9 +595,11 @@ @return registered protocol handler request scheme @rtype str """ - if self.__registerProtocolHandlerRequest and \ + if ( + self.__registerProtocolHandlerRequest and (self.url().host() == - self.__registerProtocolHandlerRequest.origin().host()): + self.__registerProtocolHandlerRequest.origin().host()) + ): return self.__registerProtocolHandlerRequest.scheme() else: return ""
--- a/eric6/WebBrowser/WebBrowserSingleApplication.py Wed Sep 25 19:00:09 2019 +0200 +++ b/eric6/WebBrowser/WebBrowserSingleApplication.py Wed Sep 25 19:11:13 2019 +0200 @@ -12,8 +12,9 @@ from PyQt5.QtCore import pyqtSignal -from Toolbox.SingleApplication import SingleApplicationClient, \ - SingleApplicationServer +from Toolbox.SingleApplication import ( + SingleApplicationClient, SingleApplicationServer +) import Globals
--- a/eric6/WebBrowser/WebBrowserTabBar.py Wed Sep 25 19:00:09 2019 +0200 +++ b/eric6/WebBrowser/WebBrowserTabBar.py Wed Sep 25 19:11:13 2019 +0200 @@ -104,18 +104,24 @@ i += 1 # If found and not the current tab then show tab preview - if tabIndex != -1 and \ - tabIndex != self.currentIndex() and \ - evt.buttons() == Qt.NoButton: - if self.__previewPopup is None or \ + if ( + tabIndex != -1 and + tabIndex != self.currentIndex() and + evt.buttons() == Qt.NoButton + ): + if ( + self.__previewPopup is None or (self.__previewPopup is not None and - self.__previewPopup.getCustomData("index") != tabIndex): + self.__previewPopup.getCustomData("index") != tabIndex) + ): QTimer.singleShot( 0, lambda: self.__showTabPreview(tabIndex)) # If current tab or not found then hide previous tab preview - if tabIndex == self.currentIndex() or \ - tabIndex == -1: + if ( + tabIndex == self.currentIndex() or + tabIndex == -1 + ): self.__hidePreview() def leaveEvent(self, evt): @@ -151,8 +157,10 @@ @param evt reference to the event to be handled (QEvent) @return flag indicating, if the event was handled (boolean) """ - if evt.type() == QEvent.ToolTip and \ - Preferences.getWebBrowser("ShowPreview"): + if ( + evt.type() == QEvent.ToolTip and + Preferences.getWebBrowser("ShowPreview") + ): # suppress tool tips if we are showing previews evt.setAccepted(True) return True
--- a/eric6/WebBrowser/WebBrowserTabWidget.py Wed Sep 25 19:00:09 2019 +0200 +++ b/eric6/WebBrowser/WebBrowserTabWidget.py Wed Sep 25 19:11:13 2019 +0200 @@ -12,8 +12,9 @@ from PyQt5.QtCore import pyqtSignal, pyqtSlot, Qt, QUrl, QFile, QFileDevice from PyQt5.QtGui import QIcon, QPixmap, QPainter -from PyQt5.QtWidgets import QWidget, QHBoxLayout, QMenu, QToolButton, \ - QDialog, QApplication +from PyQt5.QtWidgets import ( + QWidget, QHBoxLayout, QMenu, QToolButton, QDialog, QApplication +) from PyQt5.QtPrintSupport import QPrinter, QPrintDialog, QAbstractPrintDialog from E5Gui.E5TabWidget import E5TabWidget @@ -244,8 +245,10 @@ self.tabContextCloseOthersAct.setEnabled(self.count() > 1) if self.__audioAct is not None: - if self.widget(self.__tabContextMenuIndex).page()\ - .isAudioMuted(): + if ( + self.widget(self.__tabContextMenuIndex).page() + .isAudioMuted() + ): self.__audioAct.setText(self.tr("Unmute Tab")) self.__audioAct.setIcon( UI.PixmapCache.getIcon("audioVolumeHigh.png")) @@ -294,8 +297,10 @@ Private slot to close all other tabs. """ index = self.__tabContextMenuIndex - for i in list(range(self.count() - 1, index, -1)) + \ - list(range(index - 1, -1, -1)): + for i in ( + list(range(self.count() - 1, index, -1)) + + list(range(index - 1, -1, -1)) + ): self.closeBrowserAt(i) def __tabContextMenuPrint(self): @@ -396,8 +401,9 @@ urlbar = UrlBar(self.__mainWindow, self) if self.__historyCompleter is None: import WebBrowser.WebBrowserWindow - from .History.HistoryCompleter import HistoryCompletionModel, \ - HistoryCompleter + from .History.HistoryCompleter import ( + HistoryCompletionModel, HistoryCompleter + ) self.__historyCompletionModel = HistoryCompletionModel(self) self.__historyCompletionModel.setSourceModel( WebBrowser.WebBrowserWindow.WebBrowserWindow.historyManager() @@ -935,8 +941,10 @@ sourceList = {} for i in range(self.count()): browser = self.widget(i) - if browser is not None and \ - browser.source().isValid(): + if ( + browser is not None and + browser.source().isValid() + ): sourceList[i] = browser.source().host() return sourceList @@ -1046,15 +1054,19 @@ except AttributeError: url = QUrl(path) - if url.scheme() == "about" and \ - url.path() == "home": + if ( + url.scheme() == "about" and + url.path() == "home" + ): url = QUrl("eric:home") if url.scheme() in ["s", "search"]: url = manager.currentEngine().searchUrl(url.path().strip()) - if url.scheme() != "" and \ - (url.host() != "" or url.path() != ""): + if ( + url.scheme() != "" and + (url.host() != "" or url.path() != "") + ): return url urlString = Preferences.getWebBrowser("DefaultScheme") + path.strip() @@ -1192,8 +1204,8 @@ # 1. load tab data if "Tabs" in sessionData: - loadTabOnActivate = \ - Preferences.getWebBrowser("LoadTabOnActivation") + loadTabOnActivate = Preferences.getWebBrowser( + "LoadTabOnActivation") for data in sessionData["Tabs"]: browser = self.newBrowser(restoreSession=True) if loadTabOnActivate: @@ -1206,8 +1218,10 @@ browser.loadFromSessionData(data) # 2. set tab index - if "CurrentTabIndex" in sessionData and \ - sessionData["CurrentTabIndex"] >= 0: + if ( + "CurrentTabIndex" in sessionData and + sessionData["CurrentTabIndex"] >= 0 + ): index = tabCount + sessionData["CurrentTabIndex"] self.setCurrentIndex(index) self.browserAt(index).activateSession()
--- a/eric6/WebBrowser/WebBrowserView.py Wed Sep 25 19:00:09 2019 +0200 +++ b/eric6/WebBrowser/WebBrowserView.py Wed Sep 25 19:11:13 2019 +0200 @@ -11,14 +11,17 @@ import os -from PyQt5.QtCore import pyqtSignal, pyqtSlot, Qt, QUrl, QFileInfo, QTimer, \ - QEvent, QPoint, QPointF, QDateTime, QStandardPaths, QByteArray, \ - QIODevice, QDataStream -from PyQt5.QtGui import QDesktopServices, QClipboard, QIcon, \ - QContextMenuEvent, QPixmap, QCursor +from PyQt5.QtCore import ( + pyqtSignal, pyqtSlot, Qt, QUrl, QFileInfo, QTimer, QEvent, QPoint, + QPointF, QDateTime, QStandardPaths, QByteArray, QIODevice, QDataStream +) +from PyQt5.QtGui import ( + QDesktopServices, QClipboard, QIcon, QContextMenuEvent, QPixmap, QCursor +) from PyQt5.QtWidgets import qApp, QStyle, QMenu, QApplication, QDialog -from PyQt5.QtWebEngineWidgets import QWebEngineView, QWebEnginePage, \ - QWebEngineDownloadItem +from PyQt5.QtWebEngineWidgets import ( + QWebEngineView, QWebEnginePage, QWebEngineDownloadItem +) from E5Gui import E5MessageBox, E5FileDialog @@ -208,9 +211,11 @@ @param url URL to be loaded @type QUrl """ - if self.__page is not None and \ + if ( + self.__page is not None and not self.__page.acceptNavigationRequest( - url, QWebEnginePage.NavigationTypeTyped, True): + url, QWebEnginePage.NavigationTypeTyped, True) + ): return super(WebBrowserView, self).load(url) @@ -244,8 +249,10 @@ else: name.setUrl("file://" + name.toString()) - if len(name.scheme()) == 1 or \ - name.scheme() == "file": + if ( + len(name.scheme()) == 1 or + name.scheme() == "file" + ): # name is a local file if name.scheme() and len(name.scheme()) == 1: # it is a local path on win os @@ -551,8 +558,10 @@ self.__menu.addSeparator() self.__menu.addAction(self.__mw.adBlockIcon().menuAction()) - if qVersionTuple() >= (5, 11, 0) or \ - Preferences.getWebBrowser("WebInspectorEnabled"): + if ( + qVersionTuple() >= (5, 11, 0) or + Preferences.getWebBrowser("WebInspectorEnabled") + ): self.__menu.addSeparator() self.__menu.addAction( UI.PixmapCache.getIcon("webInspector.png"), @@ -591,8 +600,10 @@ menu.addSeparator() spellCheckActionCount = len(menu.actions()) - if not hitTest.linkUrl().isEmpty() and \ - hitTest.linkUrl().scheme() != "javascript": + if ( + not hitTest.linkUrl().isEmpty() and + hitTest.linkUrl().scheme() != "javascript" + ): self.__createLinkContextMenu(menu, hitTest) if not hitTest.imageUrl().isEmpty(): @@ -679,8 +690,10 @@ act.setData(hitTest.linkUrl()) act.triggered.connect( lambda: self.__sendLink(act)) - if Preferences.getWebBrowser("VirusTotalEnabled") and \ - Preferences.getWebBrowser("VirusTotalServiceKey") != "": + if ( + Preferences.getWebBrowser("VirusTotalEnabled") and + Preferences.getWebBrowser("VirusTotalServiceKey") != "" + ): act = menu.addAction( UI.PixmapCache.getIcon("virustotal.png"), self.tr("Scan Link with VirusTotal")) @@ -755,8 +768,10 @@ act.setData(hitTest.imageUrl().toString()) act.triggered.connect( lambda: self.__blockImage(act)) - if Preferences.getWebBrowser("VirusTotalEnabled") and \ - Preferences.getWebBrowser("VirusTotalServiceKey") != "": + if ( + Preferences.getWebBrowser("VirusTotalEnabled") and + Preferences.getWebBrowser("VirusTotalServiceKey") != "" + ): act = menu.addAction( UI.PixmapCache.getIcon("virustotal.png"), self.tr("Scan Image with VirusTotal")) @@ -835,8 +850,9 @@ menu.addAction(self.tr("Search with '{0}'").format(engineName), self.__searchDefaultRequested) - from .OpenSearch.OpenSearchEngineAction import \ + from .OpenSearch.OpenSearchEngineAction import ( OpenSearchEngineAction + ) self.__searchMenu = menu.addMenu(self.tr("Search with...")) engineNames = self.__mw.openSearchManager().allEnginesNames() @@ -1037,10 +1053,12 @@ @param url URL to be checked (QUrl) @return flag indicating a valid URL (boolean) """ - return url.isValid() and \ - bool(url.host()) and \ - bool(url.scheme()) and \ + return ( + url.isValid() and + bool(url.host()) and + bool(url.scheme()) and "." in url.host() + ) def __replaceMisspelledWord(self, act): """ @@ -1339,9 +1357,11 @@ @param evt reference to the drop event (QDropEvent) """ super(WebBrowserView, self).dropEvent(evt) - if not evt.isAccepted() and \ - evt.source() != self and \ - evt.possibleActions() & Qt.CopyAction: + if ( + not evt.isAccepted() and + evt.source() != self and + evt.possibleActions() & Qt.CopyAction + ): url = QUrl() if len(evt.mimeData().urls()) > 0: url = evt.mimeData().urls()[0] @@ -1383,12 +1403,16 @@ accepted = evt.isAccepted() self.__page.event(evt) - if not evt.isAccepted() and \ - self.__mw.eventMouseButtons() & Qt.MidButton: + if ( + not evt.isAccepted() and + self.__mw.eventMouseButtons() & Qt.MidButton + ): url = QUrl(QApplication.clipboard().text(QClipboard.Selection)) - if not url.isEmpty() and \ - url.isValid() and \ - url.scheme() != "": + if ( + not url.isEmpty() and + url.isValid() and + url.scheme() != "" + ): self.__mw.setEventMouseButtons(Qt.NoButton) self.__mw.setEventKeyboardModifiers(Qt.NoModifier) self.setSource(url) @@ -1513,8 +1537,11 @@ @return flag indicating that the event should be filtered out @rtype bool """ - if obj is self and evt.type() == QEvent.ParentChange and \ - self.parentWidget() is not None: + if ( + obj is self and + evt.type() == QEvent.ParentChange and + self.parentWidget() is not None + ): self.parentWidget().installEventFilter(self) # find the render widget receiving events for the web page @@ -1523,10 +1550,12 @@ QTimer.singleShot(0, self.__setRwhvqt) # forward events to WebBrowserView - if obj is self.__rwhvqt and \ - evt.type() in [QEvent.KeyPress, QEvent.KeyRelease, - QEvent.MouseButtonPress, QEvent.MouseButtonRelease, - QEvent.MouseMove, QEvent.Wheel, QEvent.Gesture]: + if ( + obj is self.__rwhvqt and + evt.type() in [QEvent.KeyPress, QEvent.KeyRelease, + QEvent.MouseButtonPress, QEvent.MouseButtonRelease, + QEvent.MouseMove, QEvent.Wheel, QEvent.Gesture] + ): wasAccepted = evt.isAccepted() evt.setAccepted(False) if evt.type() == QEvent.KeyPress: @@ -1547,8 +1576,10 @@ evt.setAccepted(wasAccepted) return ret - if obj is self.parentWidget() and \ - evt.type() in [QEvent.KeyPress, QEvent.KeyRelease]: + if ( + obj is self.parentWidget() and + evt.type() in [QEvent.KeyPress, QEvent.KeyRelease] + ): wasAccepted = evt.isAccepted() evt.setAccepted(False) if evt.type() == QEvent.KeyPress: @@ -2269,8 +2300,9 @@ clientCertificateSelection.select(certificates[0]) else: certificate = None - from E5Network.E5SslCertificateSelectionDialog import \ + from E5Network.E5SslCertificateSelectionDialog import ( E5SslCertificateSelectionDialog + ) dlg = E5SslCertificateSelectionDialog(certificates, self) if dlg.exec_() == QDialog.Accepted: certificate = dlg.getSelectedCertificate()
--- a/eric6/WebBrowser/WebBrowserWebSearchWidget.py Wed Sep 25 19:00:09 2019 +0200 +++ b/eric6/WebBrowser/WebBrowserWebSearchWidget.py Wed Sep 25 19:11:13 2019 +0200 @@ -9,8 +9,9 @@ from PyQt5.QtCore import pyqtSignal, QUrl, QModelIndex, QTimer, Qt -from PyQt5.QtGui import QStandardItem, QStandardItemModel, QFont, QIcon, \ - QPixmap +from PyQt5.QtGui import ( + QStandardItem, QStandardItemModel, QFont, QIcon, QPixmap +) from PyQt5.QtWidgets import QMenu, QCompleter from PyQt5.QtWebEngineWidgets import QWebEnginePage @@ -112,8 +113,8 @@ self.__recentSearches.remove(searchText) self.__recentSearches.insert(0, searchText) if len(self.__recentSearches) > self.__maxSavedSearches: - self.__recentSearches = \ - self.__recentSearches[:self.__maxSavedSearches] + self.__recentSearches = self.__recentSearches[ + :self.__maxSavedSearches] self.__setupCompleterMenu() self.__mw.currentBrowser().setFocus() @@ -124,9 +125,11 @@ """ Private method to create the completer menu. """ - if not self.__suggestions or \ - (self.__model.rowCount() > 0 and - self.__model.item(0) != self.__suggestionsItem): + if ( + not self.__suggestions or + (self.__model.rowCount() > 0 and + self.__model.item(0) != self.__suggestionsItem) + ): self.__model.clear() self.__suggestionsItem = None else: @@ -172,12 +175,16 @@ @param index index of the item (QModelIndex) """ - if self.__suggestionsItem and \ - self.__suggestionsItem.index().row() == index.row(): + if ( + self.__suggestionsItem and + self.__suggestionsItem.index().row() == index.row() + ): return - if self.__recentSearchesItem and \ - self.__recentSearchesItem.index().row() == index.row(): + if ( + self.__recentSearchesItem and + self.__recentSearchesItem.index().row() == index.row() + ): return self.__searchNow() @@ -189,12 +196,16 @@ @param index index of the item (QModelIndex) @return flah indicating a successful highlighting (boolean) """ - if self.__suggestionsItem and \ - self.__suggestionsItem.index().row() == index.row(): + if ( + self.__suggestionsItem and + self.__suggestionsItem.index().row() == index.row() + ): return False - if self.__recentSearchesItem and \ - self.__recentSearchesItem.index().row() == index.row(): + if ( + self.__recentSearchesItem and + self.__recentSearchesItem.index().row() == index.row() + ): return False self.setText(index.data()) @@ -224,8 +235,8 @@ """ searchText = self.text() if searchText: - self.__openSearchManager.currentEngine()\ - .requestSuggestions(searchText) + self.__openSearchManager.currentEngine().requestSuggestions( + searchText) def __newSuggestions(self, suggestions): """
--- a/eric6/WebBrowser/WebBrowserWindow.py Wed Sep 25 19:00:09 2019 +0200 +++ b/eric6/WebBrowser/WebBrowserWindow.py Wed Sep 25 19:11:13 2019 +0200 @@ -12,14 +12,19 @@ import shutil import sys -from PyQt5.QtCore import pyqtSlot, pyqtSignal, Qt, QByteArray, QSize, QTimer, \ - QUrl, QTextCodec, QProcess, QEvent, QFileInfo +from PyQt5.QtCore import ( + pyqtSlot, pyqtSignal, Qt, QByteArray, QSize, QTimer, QUrl, QTextCodec, + QProcess, QEvent, QFileInfo +) from PyQt5.QtGui import QDesktopServices, QKeySequence, QFont, QFontMetrics -from PyQt5.QtWidgets import QWidget, QVBoxLayout, QSizePolicy, QDockWidget, \ - QComboBox, QLabel, QMenu, QLineEdit, QApplication, \ - QWhatsThis, QDialog, QHBoxLayout, QProgressBar, QInputDialog, QAction -from PyQt5.QtWebEngineWidgets import QWebEngineSettings, QWebEnginePage, \ - QWebEngineProfile, QWebEngineScript +from PyQt5.QtWidgets import ( + QWidget, QVBoxLayout, QSizePolicy, QDockWidget, QComboBox, QLabel, QMenu, + QLineEdit, QApplication, QWhatsThis, QDialog, QHBoxLayout, QProgressBar, + QInputDialog, QAction +) +from PyQt5.QtWebEngineWidgets import ( + QWebEngineSettings, QWebEnginePage, QWebEngineProfile, QWebEngineScript +) try: from PyQt5.QtHelp import QHelpEngine, QHelpEngineCore, QHelpSearchQuery QTHELP_AVAILABLE = True @@ -162,10 +167,12 @@ self.__eventMouseButtons = Qt.NoButton self.__eventKeyboardModifiers = Qt.NoModifier - if qVersionTuple() < (5, 11, 0) and \ - Preferences.getWebBrowser("WebInspectorEnabled"): - os.environ["QTWEBENGINE_REMOTE_DEBUGGING"] = \ - str(Preferences.getWebBrowser("WebInspectorPort")) + if ( + qVersionTuple() < (5, 11, 0) and + Preferences.getWebBrowser("WebInspectorEnabled") + ): + os.environ["QTWEBENGINE_REMOTE_DEBUGGING"] = str( + Preferences.getWebBrowser("WebInspectorPort")) WebBrowserWindow.setUseQtHelp(qthelp or bool(searchWord)) @@ -287,8 +294,7 @@ self.addDockWidget(Qt.LeftDockWidgetArea, self.__searchDock) # JavaScript Console window - from .WebBrowserJavaScriptConsole import \ - WebBrowserJavaScriptConsole + from .WebBrowserJavaScriptConsole import WebBrowserJavaScriptConsole self.__javascriptConsole = WebBrowserJavaScriptConsole(self) self.__javascriptConsoleDock = QDockWidget( self.tr("JavaScript Console")) @@ -344,21 +350,23 @@ syncMgr.syncError.connect(self.statusBar().showMessage) restoreSessionData = {} - if WebBrowserWindow._performingStartup and not home and \ - not WebBrowserWindow.isPrivate(): + if ( + WebBrowserWindow._performingStartup and + not home and + not WebBrowserWindow.isPrivate() + ): startupBehavior = Preferences.getWebBrowser("StartupBehavior") if not private and startupBehavior in [3, 4]: if startupBehavior == 3: # restore last session - restoreSessionFile = \ + restoreSessionFile = ( self.sessionManager().lastActiveSessionFile() + ) elif startupBehavior == 4: # select session - restoreSessionFile = \ - self.sessionManager().selectSession() - sessionData = \ - self.sessionManager().readSessionFromFile( - restoreSessionFile) + restoreSessionFile = self.sessionManager().selectSession() + sessionData = self.sessionManager().readSessionFromFile( + restoreSessionFile) if self.sessionManager().isValidSession(sessionData): restoreSessionData = sessionData restoreSession = True @@ -1859,8 +1867,10 @@ self.__virusTotalDomainReport) self.__actions.append(self.virustotalDomainReportAct) - if not Preferences.getWebBrowser("VirusTotalEnabled") or \ - Preferences.getWebBrowser("VirusTotalServiceKey") == "": + if ( + not Preferences.getWebBrowser("VirusTotalEnabled") or + Preferences.getWebBrowser("VirusTotalServiceKey") == "" + ): self.virustotalScanCurrentAct.setEnabled(False) self.virustotalIpReportAct.setEnabled(False) self.virustotalDomainReportAct.setEnabled(False) @@ -2506,8 +2516,10 @@ if linkName: args.append(linkName) - if not os.path.isfile(applPath) or \ - not QProcess.startDetached(sys.executable, args): + if ( + not os.path.isfile(applPath) or + not QProcess.startDetached(sys.executable, args) + ): E5MessageBox.critical( self, self.tr('New Private Window'), @@ -2579,8 +2591,9 @@ """ Private slot to show the about information. """ - chromeVersion, webengineVersion = \ + chromeVersion, webengineVersion = ( WebBrowserTools.getWebEngineVersions() + ) E5MessageBox.about( self, self.tr("eric6 Web Browser"), @@ -2801,9 +2814,11 @@ self.__isClosing = True - if not WebBrowserWindow._performingShutdown and \ - len(WebBrowserWindow.BrowserWindows) == 1 and \ - not WebBrowserWindow.isPrivate(): + if ( + not WebBrowserWindow._performingShutdown and + len(WebBrowserWindow.BrowserWindows) == 1 and + not WebBrowserWindow.isPrivate() + ): # shut down the session manager in case the last window is # about to be closed self.sessionManager().shutdown() @@ -2856,8 +2871,10 @@ pass Preferences.syncPreferences() - if not WebBrowserWindow._performingShutdown and \ - len(WebBrowserWindow.BrowserWindows) == 0: + if ( + not WebBrowserWindow._performingShutdown and + len(WebBrowserWindow.BrowserWindows) == 0 + ): # shut down the browser in case the last window was # simply closed self.shutdown() @@ -2905,8 +2922,10 @@ if not self.__shallShutDown(): return False - if WebBrowserWindow._downloadManager is not None and \ - not self.downloadManager().allowQuit(): + if ( + WebBrowserWindow._downloadManager is not None and + not self.downloadManager().allowQuit() + ): return False WebBrowserWindow._performingShutdown = True @@ -3251,8 +3270,10 @@ pass self.__virusTotal.preferencesChanged() - if not Preferences.getWebBrowser("VirusTotalEnabled") or \ - Preferences.getWebBrowser("VirusTotalServiceKey") == "": + if ( + not Preferences.getWebBrowser("VirusTotalEnabled") or + Preferences.getWebBrowser("VirusTotalServiceKey") == "" + ): self.virustotalScanCurrentAct.setEnabled(False) self.virustotalIpReportAct.setEnabled(False) self.virustotalDomainReportAct.setEnabled(False) @@ -3297,8 +3318,9 @@ """ Private slot to configure the cookies handling. """ - from .CookieJar.CookiesConfigurationDialog import \ + from .CookieJar.CookiesConfigurationDialog import ( CookiesConfigurationDialog + ) dlg = CookiesConfigurationDialog(self) dlg.exec_() @@ -3492,8 +3514,9 @@ Private slot to manage the QtHelp documentation database. """ if WebBrowserWindow._useQtHelp: - from .QtHelp.QtHelpDocumentationDialog import \ + from .QtHelp.QtHelpDocumentationDialog import ( QtHelpDocumentationDialog + ) dlg = QtHelpDocumentationDialog(self.__helpEngine, self) dlg.exec_() if dlg.hasDocumentationChanges(): @@ -3551,8 +3574,11 @@ """ Private slot to search for a word. """ - if WebBrowserWindow._useQtHelp and not self.__indexing and \ - self.__searchWord is not None: + if ( + WebBrowserWindow._useQtHelp and + not self.__indexing and + self.__searchWord is not None + ): self.__searchDock.show() self.__searchDock.raise_() query = QHelpSearchQuery(QHelpSearchQuery.DEFAULT, @@ -3655,8 +3681,9 @@ """ Private slot to clear the private data. """ - from .WebBrowserClearPrivateDataDialog import \ + from .WebBrowserClearPrivateDataDialog import ( WebBrowserClearPrivateDataDialog + ) dlg = WebBrowserClearPrivateDataDialog(self) if dlg.exec_() == QDialog.Accepted: # browsing history, search history, favicons, disk cache, cookies, @@ -3949,9 +3976,10 @@ (PersonalInformationManager) """ if cls._personalInformationManager is None: - from .PersonalInformationManager.PersonalInformationManager \ - import PersonalInformationManager - cls._personalInformationManager = PersonalInformationManager() + from .PersonalInformationManager import PersonalInformationManager + cls._personalInformationManager = ( + PersonalInformationManager.PersonalInformationManager() + ) return cls._personalInformationManager @@ -3977,8 +4005,9 @@ @rtype FeaturePermissionManager """ if cls._featurePermissionManager is None: - from .FeaturePermissions.FeaturePermissionManager import \ + from .FeaturePermissions.FeaturePermissionManager import ( FeaturePermissionManager + ) cls._featurePermissionManager = FeaturePermissionManager() return cls._featurePermissionManager @@ -3992,8 +4021,9 @@ @rtype FlashCookieManager """ if cls._flashCookieManager is None: - from .FlashCookieManager.FlashCookieManager import \ + from .FlashCookieManager.FlashCookieManager import ( FlashCookieManager + ) cls._flashCookieManager = FlashCookieManager() return cls._flashCookieManager @@ -4007,8 +4037,9 @@ @rtype ImageSearchEngine """ if cls._imageSearchEngine is None: - from .ImageSearch.ImageSearchEngine import \ + from .ImageSearch.ImageSearchEngine import ( ImageSearchEngine + ) cls._imageSearchEngine = ImageSearchEngine() return cls._imageSearchEngine @@ -4139,8 +4170,7 @@ @type QMenu """ if codecNames: - defaultCodec = \ - self.webSettings().defaultTextEncoding().lower() + defaultCodec = self.webSettings().defaultTextEncoding().lower() menu = QMenu(title, parentMenu) for codec in codecNames: @@ -4560,8 +4590,10 @@ @rtype bool """ if evt.type() == QEvent.WindowStateChange: - if not bool(evt.oldState() & Qt.WindowFullScreen) and \ - bool(self.windowState() & Qt.WindowFullScreen): + if ( + not bool(evt.oldState() & Qt.WindowFullScreen) and + bool(self.windowState() & Qt.WindowFullScreen) + ): # enter full screen mode self.__windowStates = evt.oldState() self.__toolbarStates = self.saveState() @@ -4576,8 +4608,10 @@ self.__navigationBar.exitFullScreenButton().setVisible(True) self.__navigationContainer.hide() - elif bool(evt.oldState() & Qt.WindowFullScreen) and \ - not bool(self.windowState() & Qt.WindowFullScreen): + elif ( + bool(evt.oldState() & Qt.WindowFullScreen) and + not bool(self.windowState() & Qt.WindowFullScreen) + ): # leave full screen mode self.setWindowState(self.__windowStates) self.__htmlFullScreen = False @@ -4697,8 +4731,10 @@ name = "_eric_userstylesheet" userStyle = "" - userStyle += WebBrowserTools.readAllFileContents(styleSheetFile)\ + userStyle += ( + WebBrowserTools.readAllFileContents(styleSheetFile) .replace("\n", "") + ) oldScript = self.webProfile().scripts().findScript(name) if not oldScript.isNull():
--- a/eric6/WebBrowser/WebInspector.py Wed Sep 25 19:00:09 2019 +0200 +++ b/eric6/WebBrowser/WebInspector.py Wed Sep 25 19:11:13 2019 +0200 @@ -13,8 +13,9 @@ from PyQt5.QtCore import pyqtSignal, QSize, QUrl from PyQt5.QtNetwork import QNetworkRequest -from PyQt5.QtWebEngineWidgets import QWebEngineView, QWebEnginePage, \ - QWebEngineSettings +from PyQt5.QtWebEngineWidgets import ( + QWebEngineView, QWebEnginePage, QWebEngineSettings +) from Globals import qVersionTuple