diff -r aedc309827c7 -r a28338eaf694 eric6/WebBrowser/AdBlock/AdBlockManager.py --- a/eric6/WebBrowser/AdBlock/AdBlockManager.py Wed Sep 25 18:37:35 2019 +0200 +++ b/eric6/WebBrowser/AdBlock/AdBlockManager.py Wed Sep 25 18:48:22 2019 +0200 @@ -10,8 +10,10 @@ import os -from PyQt5.QtCore import pyqtSignal, QObject, QUrl, QUrlQuery, QFile, \ - QByteArray, QMutex, QMutexLocker +from PyQt5.QtCore import ( + pyqtSignal, QObject, QUrl, QUrlQuery, QFile, QByteArray, QMutex, + QMutexLocker +) from PyQt5.QtWebEngineCore import QWebEngineUrlRequestInfo from E5Gui import E5MessageBox @@ -61,17 +63,19 @@ self.__limitedEasyList = Preferences.getWebBrowser( "AdBlockUseLimitedEasyList") - self.__defaultSubscriptionUrlString = \ - "abp:subscribe?location=" \ - "https://easylist-downloads.adblockplus.org/easylist.txt&"\ + self.__defaultSubscriptionUrlString = ( + "abp:subscribe?location=" + "https://easylist-downloads.adblockplus.org/easylist.txt&" "title=EasyList" + ) self.__additionalDefaultSubscriptionUrlStrings = ( "abp:subscribe?location=https://raw.githubusercontent.com/" "hoshsadiq/adblock-nocoin-list/master/nocoin.txt&" "title=NoCoin", ) - self.__customSubscriptionUrlString = \ + self.__customSubscriptionUrlString = ( bytes(self.__customSubscriptionUrl().toEncoded()).decode() + ) self.__mutex = QMutex() self.__matcher = AdBlockMatcher(self) @@ -98,8 +102,8 @@ Public method to close the open search engines manager. """ self.__adBlockDialog and self.__adBlockDialog.close() - self.__adBlockExceptionsDialog and \ - self.__adBlockExceptionsDialog.close() + (self.__adBlockExceptionsDialog and + self.__adBlockExceptionsDialog.close()) self.__saveTimer.saveIfNeccessary() @@ -153,8 +157,10 @@ urlDomain = info.requestUrl().host().lower() urlScheme = info.requestUrl().scheme().lower() - if not self.canRunOnScheme(urlScheme) or \ - not self.__canBeBlocked(info.firstPartyUrl()): + if ( + not self.canRunOnScheme(urlScheme) or + not self.__canBeBlocked(info.firstPartyUrl()) + ): return False res = False @@ -162,8 +168,10 @@ if blockedRule: res = True - if info.resourceType() == \ - QWebEngineUrlRequestInfo.ResourceTypeMainFrame: + if ( + info.resourceType() == + QWebEngineUrlRequestInfo.ResourceTypeMainFrame + ): url = QUrl("eric:adblock") query = QUrlQuery() query.addQueryItem("rule", blockedRule.filter()) @@ -416,9 +424,11 @@ else: subscriptions.append(self.__customSubscriptionUrlString) else: - subscriptions = [self.__defaultSubscriptionUrlString] + \ - self.__additionalDefaultSubscriptionUrlStrings + \ + subscriptions = ( + [self.__defaultSubscriptionUrlString] + + self.__additionalDefaultSubscriptionUrlStrings + [self.__customSubscriptionUrlString] + ) for subscription in subscriptions: url = QUrl.fromEncoded(subscription.encode("utf-8")) adBlockSubscription = AdBlockSubscription( @@ -504,9 +514,11 @@ @return element hiding rules @rtype str """ - if not self.isEnabled() or \ - not self.canRunOnScheme(url.scheme()) or \ - not self.__canBeBlocked(url): + if ( + not self.isEnabled() or + not self.canRunOnScheme(url.scheme()) or + not self.__canBeBlocked(url) + ): return "" return self.__matcher.elementHidingRules() @@ -520,9 +532,11 @@ @return element hiding rules @rtype str """ - if not self.isEnabled() or \ - not self.canRunOnScheme(url.scheme()) or \ - not self.__canBeBlocked(url): + if ( + not self.isEnabled() or + not self.canRunOnScheme(url.scheme()) or + not self.__canBeBlocked(url) + ): return "" return self.__matcher.elementHidingRulesForDomain(url.host())