diff -r a28338eaf694 -r 0c63ea7f94bd eric6/WebBrowser/SafeBrowsing/SafeBrowsingManager.py --- a/eric6/WebBrowser/SafeBrowsing/SafeBrowsingManager.py Wed Sep 25 18:48:22 2019 +0200 +++ b/eric6/WebBrowser/SafeBrowsing/SafeBrowsingManager.py Wed Sep 25 18:52:40 2019 +0200 @@ -18,8 +18,9 @@ import os import base64 -from PyQt5.QtCore import pyqtSignal, pyqtSlot, QObject, QCoreApplication, \ - QUrl, QDateTime, QTimer +from PyQt5.QtCore import ( + pyqtSignal, pyqtSlot, QObject, QCoreApplication, QUrl, QDateTime, QTimer +) import Preferences import Utilities @@ -177,16 +178,18 @@ """ Private method to set auto update for the threat lists. """ - autoUpdateEnabled = \ - Preferences.getWebBrowser("SafeBrowsingAutoUpdate") and \ + autoUpdateEnabled = ( + Preferences.getWebBrowser("SafeBrowsingAutoUpdate") and not Preferences.getWebBrowser("SafeBrowsingUseLookupApi") + ) if autoUpdateEnabled and self.isEnabled(): nextUpdateDateTime = Preferences.getWebBrowser( "SafeBrowsingUpdateDateTime") if nextUpdateDateTime.isValid(): - interval = \ + interval = ( QDateTime.currentDateTime().secsTo(nextUpdateDateTime) + 2 - # 2 seconds extra wait time; interval in milliseconds + # 2 seconds extra wait time; interval in milliseconds + ) if interval < 5: interval = 5 @@ -217,8 +220,9 @@ self.tr("Updating threat lists failed")) if ok: - nextUpdateDateTime = \ + nextUpdateDateTime = ( self.__apiClient.getFairUseDelayExpirationDateTime() + ) Preferences.setWebBrowser("SafeBrowsingUpdateDateTime", nextUpdateDateTime) self.__threatListsUpdateTimer.start( @@ -240,11 +244,13 @@ return False, self.tr("Safe Browsing is disabled.") if not self.__apiClient.fairUseDelayExpired(): - return False, \ + return ( + False, self.tr("The fair use wait period has not expired yet." "Expiration will be at {0}.").format( self.__apiClient.getFairUseDelayExpirationDateTime() .toString("yyyy-MM-dd, HH:mm:ss")) + ) self.__updatingThreatLists = True ok = True @@ -270,8 +276,10 @@ self.progress.emit(current) QCoreApplication.processEvents() threatList = ThreatList.fromApiEntry(entry) - if self.__platforms is None or \ - threatList.platformType in self.__platforms: + if ( + self.__platforms is None or + threatList.platformType in self.__platforms + ): self.__cache.addThreatList(threatList) key = repr(threatList) if key in threatListsForRemove: @@ -293,8 +301,8 @@ clientStates = {} for threatList, clientState in threatLists: clientStates[threatList.asTuple()] = clientState - threatsUpdateResponses, error = \ - self.__apiClient.getThreatsUpdate(clientStates) + threatsUpdateResponses, error = self.__apiClient.getThreatsUpdate( + clientStates) if error: return False, error @@ -396,8 +404,8 @@ if url.isEmpty(): raise ValueError("Empty URL given.") - listNames, error = \ - self.__apiClient.lookupUrl(url, self.__platforms) + listNames, error = self.__apiClient.lookupUrl( + url, self.__platforms) return listNames, error else: if isinstance(url, QUrl): @@ -432,8 +440,9 @@ matchingFullHashes = set() isPotentialThreat = False # Lookup hash prefixes which match full URL hash - for _threatList, hashPrefix, negativeCacheExpired in \ - self.__cache.lookupHashPrefix(cues): + for _threatList, hashPrefix, negativeCacheExpired in ( + self.__cache.lookupHashPrefix(cues) + ): for fullHash in fullHashes: if fullHash.startswith(hashPrefix): isPotentialThreat = True @@ -460,8 +469,10 @@ # If there are no matching expired full hash entries and negative # cache is still current for all prefixes, consider it safe. - if len(matchingExpiredThreatLists) == 0 and \ - sum(map(int, matchingPrefixes.values())) == 0: + if ( + len(matchingExpiredThreatLists) == 0 and + sum(map(int, matchingPrefixes.values())) == 0 + ): return [] # Now it can be assumed that there are expired matching full hash