Continued to shorten the code lines to max. 79 characters.

Wed, 09 Oct 2013 19:45:07 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Wed, 09 Oct 2013 19:45:07 +0200
changeset 3000
971d84f7a6d6
parent 2999
28c75409a78f
child 3001
3674ff5fa8f8

Continued to shorten the code lines to max. 79 characters.

Helpviewer/AdBlock/AdBlockAccessHandler.py file | annotate | diff | comparison | revisions
Helpviewer/AdBlock/AdBlockBlockedNetworkReply.py file | annotate | diff | comparison | revisions
Helpviewer/AdBlock/AdBlockDialog.py file | annotate | diff | comparison | revisions
Helpviewer/AdBlock/AdBlockIcon.py file | annotate | diff | comparison | revisions
Helpviewer/AdBlock/AdBlockManager.py file | annotate | diff | comparison | revisions
Helpviewer/AdBlock/AdBlockPage.py file | annotate | diff | comparison | revisions
Helpviewer/AdBlock/AdBlockRule.py file | annotate | diff | comparison | revisions
Helpviewer/AdBlock/AdBlockSubscription.py file | annotate | diff | comparison | revisions
Helpviewer/AdBlock/AdBlockTreeWidget.py file | annotate | diff | comparison | revisions
--- a/Helpviewer/AdBlock/AdBlockAccessHandler.py	Wed Oct 09 19:26:41 2013 +0200
+++ b/Helpviewer/AdBlock/AdBlockAccessHandler.py	Wed Oct 09 19:45:07 2013 +0200
@@ -24,7 +24,8 @@
         """
         Protected method to create a request.
         
-        @param op the operation to be performed (QNetworkAccessManager.Operation)
+        @param op the operation to be performed
+            (QNetworkAccessManager.Operation)
         @param request reference to the request object (QNetworkRequest)
         @param outgoingData reference to an IODevice containing data to be sent
             (QIODevice)
@@ -42,13 +43,15 @@
             return None
         res = E5MessageBox.yesNo(None,
             self.trUtf8("Subscribe?"),
-            self.trUtf8("""<p>Subscribe to this AdBlock subscription?</p><p>{0}</p>""")\
-                .format(title))
+            self.trUtf8(
+                """<p>Subscribe to this AdBlock subscription?</p>"""
+                """<p>{0}</p>""").format(title))
         if res:
             from .AdBlockSubscription import AdBlockSubscription
             import Helpviewer.HelpWindow
             
-            dlg = Helpviewer.HelpWindow.HelpWindow.adBlockManager().showDialog()
+            dlg = Helpviewer.HelpWindow.HelpWindow.adBlockManager()\
+                .showDialog()
             subscription = AdBlockSubscription(url, False,
                 Helpviewer.HelpWindow.HelpWindow.adBlockManager())
             Helpviewer.HelpWindow.HelpWindow.adBlockManager()\
--- a/Helpviewer/AdBlock/AdBlockBlockedNetworkReply.py	Wed Oct 09 19:26:41 2013 +0200
+++ b/Helpviewer/AdBlock/AdBlockBlockedNetworkReply.py	Wed Oct 09 19:45:07 2013 +0200
@@ -20,7 +20,8 @@
         Constructor
         
         @param request reference to the request object (QNetworkRequest)
-        @param subscription subscription containing the matched rule (AdBlockSubscription)
+        @param subscription subscription containing the matched rule
+            (AdBlockSubscription)
         @param rule matching rule (AdBlockRule)
         @param parent reference to the parent object (QObject)
         """
@@ -28,15 +29,18 @@
         self.setOperation(QNetworkAccessManager.GetOperation)
         self.setRequest(request)
         self.setUrl(request.url())
-        self.setError(QNetworkReply.ContentAccessDenied,
-                      "AdBlockRule:{0} ({1})".format(subscription.title(), rule.filter()))
+        self.setError(
+            QNetworkReply.ContentAccessDenied,
+            "AdBlockRule:{0} ({1})"
+                .format(subscription.title(), rule.filter()))
         QTimer.singleShot(0, self.__fireSignals)
     
     def __fireSignals(self):
         """
         Private method to send some signals to end the connection.
         """
-        self.error[QNetworkReply.NetworkError].emit(QNetworkReply.ContentAccessDenied)
+        self.error[QNetworkReply.NetworkError].emit(
+            QNetworkReply.ContentAccessDenied)
         self.finished.emit()
     
     def readData(self, maxlen):
--- a/Helpviewer/AdBlock/AdBlockDialog.py	Wed Oct 09 19:26:41 2013 +0200
+++ b/Helpviewer/AdBlock/AdBlockDialog.py	Wed Oct 09 19:45:07 2013 +0200
@@ -78,7 +78,8 @@
                 icon = UI.PixmapCache.getIcon("adBlockPlus.png")
             else:
                 icon = UI.PixmapCache.getIcon("adBlockPlusDisabled.png")
-            self.subscriptionsTabWidget.addTab(tree, icon, subscription.title())
+            self.subscriptionsTabWidget.addTab(
+                tree, icon, subscription.title())
         
         self.__loaded = True
         QCoreApplication.processEvents()
@@ -96,7 +97,8 @@
         from .AdBlockTreeWidget import AdBlockTreeWidget
         tree = AdBlockTreeWidget(subscription, self.subscriptionsTabWidget)
         index = self.subscriptionsTabWidget.insertTab(
-            self.subscriptionsTabWidget.count() - 1, tree, subscription.title())
+            self.subscriptionsTabWidget.count() - 1, tree,
+            subscription.title())
         self.subscriptionsTabWidget.setCurrentIndex(index)
         QCoreApplication.processEvents()
         if refresh:
@@ -122,8 +124,10 @@
         menu.addAction(self.trUtf8("Remove Rule"), self.__removeCustomRule)\
             .setEnabled(subscriptionEditable)
         menu.addSeparator()
-        menu.addAction(self.trUtf8("Browse Subscriptions..."), self.__browseSubscriptions)
-        menu.addAction(self.trUtf8("Remove Subscription"), self.__removeSubscription)\
+        menu.addAction(
+            self.trUtf8("Browse Subscriptions..."), self.__browseSubscriptions)
+        menu.addAction(
+            self.trUtf8("Remove Subscription"), self.__removeSubscription)\
             .setEnabled(subscriptionRemovable)
         if self.__currentSubscription:
             menu.addSeparator()
@@ -133,7 +137,8 @@
                 txt = self.trUtf8("Enable Subscription")
             menu.addAction(txt, self.__switchSubscriptionEnabled)
         menu.addSeparator()
-        menu.addAction(self.trUtf8("Update Subscription"), self.__updateSubscription)\
+        menu.addAction(
+            self.trUtf8("Update Subscription"), self.__updateSubscription)\
             .setEnabled(not subscriptionEditable)
         menu.addAction(self.trUtf8("Update All Subscriptions"),
             self.__updateAllSubscriptions)
@@ -203,13 +208,15 @@
         for subscription in requiresSubscriptions:
             requiresTitles.append(subscription.title())
         if requiresTitles:
-            message = self.trUtf8("<p>Do you really want to remove subscription"
+            message = self.trUtf8(
+                "<p>Do you really want to remove subscription"
                 " <b>{0}</b> and all subscriptions requiring it?</p>"
                 "<ul><li>{1}</li></ul>").format(
                     self.__currentSubscription.title(),
                     "</li><li>".join(requiresTitles))
         else:
-            message = self.trUtf8("<p>Do you really want to remove subscription"
+            message = self.trUtf8(
+                "<p>Do you really want to remove subscription"
                 " <b>{0}</b>?</p>").format(self.__currentSubscription.title())
         res = E5MessageBox.yesNo(self,
             self.trUtf8("Remove Subscription"),
@@ -238,7 +245,8 @@
         """
         Private slot to set the enabled state of a subscription.
         
-        @param subscription subscription to set the state for (AdBlockSubscription)
+        @param subscription subscription to set the state for
+            (AdBlockSubscription)
         @param enable state to set to (boolean)
         """
         if enable:
@@ -284,8 +292,10 @@
         @param index index of the new current tab (integer)
         """
         if index != -1:
-            self.__currentTreeWidget = self.subscriptionsTabWidget.widget(index)
-            self.__currentSubscription = self.__currentTreeWidget.subscription()
+            self.__currentTreeWidget = \
+                self.subscriptionsTabWidget.widget(index)
+            self.__currentSubscription = \
+                self.__currentTreeWidget.subscription()
     
     @pyqtSlot(str)
     def on_searchEdit_textChanged(self, filter):
--- a/Helpviewer/AdBlock/AdBlockIcon.py	Wed Oct 09 19:26:41 2013 +0200
+++ b/Helpviewer/AdBlock/AdBlockIcon.py	Wed Oct 09 19:45:07 2013 +0200
@@ -33,8 +33,8 @@
         
         self.setMaximumHeight(16)
         self.setCursor(Qt.PointingHandCursor)
-        self.setToolTip(
-            self.trUtf8("AdBlock lets you block unwanted content on web pages."))
+        self.setToolTip(self.trUtf8(
+            "AdBlock lets you block unwanted content on web pages."))
         
         self.clicked.connect(self.__showMenu)
     
@@ -48,7 +48,8 @@
         if enabled:
             self.currentChanged()
         else:
-            self.setPixmap(UI.PixmapCache.getPixmap("adBlockPlusDisabled16.png"))
+            self.setPixmap(
+                UI.PixmapCache.getPixmap("adBlockPlusDisabled16.png"))
     
     def __createMenu(self, menu=None):
         """
@@ -67,11 +68,15 @@
         manager = Helpviewer.HelpWindow.HelpWindow.adBlockManager()
         
         if manager.isEnabled():
-            menu.addAction(UI.PixmapCache.getIcon("adBlockPlusDisabled.png"),
-                self.trUtf8("Disable AdBlock"), self.__enableAdBlock).setData(False)
+            menu.addAction(
+                UI.PixmapCache.getIcon("adBlockPlusDisabled.png"),
+                self.trUtf8("Disable AdBlock"),
+                self.__enableAdBlock).setData(False)
         else:
-            menu.addAction(UI.PixmapCache.getIcon("adBlockPlus.png"),
-                self.trUtf8("Enable AdBlock"), self.__enableAdBlock).setData(True)
+            menu.addAction(
+                UI.PixmapCache.getIcon("adBlockPlus.png"),
+                self.trUtf8("Enable AdBlock"),
+                self.__enableAdBlock).setData(True)
         menu.addSeparator()
         if manager.isEnabled() and \
            self.__mw.currentBrowser().page().url().host():
@@ -92,8 +97,8 @@
         
         entries = self.__mw.currentBrowser().page().getAdBlockedPageEntries()
         if entries:
-            menu.addAction(
-                self.trUtf8("Blocked URL (AdBlock Rule) - click to edit rule"))\
+            menu.addAction(self.trUtf8(
+                "Blocked URL (AdBlock Rule) - click to edit rule"))\
                 .setEnabled(False)
             for entry in entries:
                 address = entry.urlString()[-55:]
@@ -116,9 +121,11 @@
             self.__menuAction.menu().aboutToShow.connect(self.__createMenu)
         
         if self.__enabled:
-            self.__menuAction.setIcon(UI.PixmapCache.getIcon("adBlockPlus.png"))
+            self.__menuAction.setIcon(
+                UI.PixmapCache.getIcon("adBlockPlus.png"))
         else:
-            self.__menuAction.setIcon(UI.PixmapCache.getIcon("adBlockPlusDisabled.png"))
+            self.__menuAction.setIcon(
+                UI.PixmapCache.getIcon("adBlockPlusDisabled.png"))
         
         return self.__menuAction
     
@@ -139,11 +146,13 @@
         act = self.sender()
         if act is not None:
             import Helpviewer.HelpWindow
-            Helpviewer.HelpWindow.HelpWindow.adBlockManager().setEnabled(act.data())
+            Helpviewer.HelpWindow.HelpWindow.adBlockManager().setEnabled(
+                act.data())
     
     def __isCurrentHostExcepted(self):
         """
-        Private method to check, if the host of the current browser is excepted.
+        Private method to check, if the host of the current browser is
+        excepted.
         
         @return flag indicating an exception (boolean)
         """
@@ -152,7 +161,8 @@
         
         import Helpviewer.HelpWindow
         return urlHost and \
-               Helpviewer.HelpWindow.HelpWindow.adBlockManager().isHostExcepted(urlHost)
+            Helpviewer.HelpWindow.HelpWindow.adBlockManager()\
+                .isHostExcepted(urlHost)
     
     def currentChanged(self):
         """
@@ -160,22 +170,26 @@
         """
         if self.__enabled:
             if self.__isCurrentHostExcepted():
-                self.setPixmap(UI.PixmapCache.getPixmap("adBlockPlusGreen16.png"))
+                self.setPixmap(
+                    UI.PixmapCache.getPixmap("adBlockPlusGreen16.png"))
             else:
                 self.setPixmap(UI.PixmapCache.getPixmap("adBlockPlus16.png"))
     
     def __setException(self):
         """
-        Private slot to add or remove the current host from the list of exceptions.
+        Private slot to add or remove the current host from the list of
+        exceptions.
         """
         act = self.sender()
         if act is not None:
             import Helpviewer.HelpWindow
             urlHost = self.__mw.currentBrowser().page().url().host()
             if act.data():
-                Helpviewer.HelpWindow.HelpWindow.adBlockManager().addException(urlHost)
+                Helpviewer.HelpWindow.HelpWindow.adBlockManager()\
+                    .addException(urlHost)
             else:
-                Helpviewer.HelpWindow.HelpWindow.adBlockManager().removeException(urlHost)
+                Helpviewer.HelpWindow.HelpWindow.adBlockManager()\
+                    .removeException(urlHost)
             self.currentChanged()
     
     def sourceChanged(self, browser, url):
--- a/Helpviewer/AdBlock/AdBlockManager.py	Wed Oct 09 19:26:41 2013 +0200
+++ b/Helpviewer/AdBlock/AdBlockManager.py	Wed Oct 09 19:45:07 2013 +0200
@@ -48,7 +48,8 @@
         
         self.__defaultSubscriptionUrlString = \
             "abp:subscribe?location=" \
-            "https://easylist-downloads.adblockplus.org/easylist.txt&title=EasyList"
+            "https://easylist-downloads.adblockplus.org/easylist.txt&"\
+            "title=EasyList"
         self.__customSubscriptionUrlString = \
             bytes(self.__customSubscriptionUrl().toEncoded()).decode()
         
@@ -59,7 +60,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()
     
@@ -119,7 +121,8 @@
         
         @return URL for custom subscriptions (QUrl)
         """
-        dataDir = os.path.join(Utilities.getConfigDir(), "browser", "subscriptions")
+        dataDir = os.path.join(Utilities.getConfigDir(), "browser",
+                               "subscriptions")
         if not os.path.exists(dataDir):
             os.makedirs(dataDir)
         fileName = os.path.join(dataDir, "adblock_subscription_custom")
@@ -189,14 +192,16 @@
         """
         Public method to remove an AdBlock subscription.
         
-        @param subscription AdBlock subscription to be removed (AdBlockSubscription)
+        @param subscription AdBlock subscription to be removed
+            (AdBlockSubscription)
         @param emitSignal flag indicating to send a signal (boolean)
         """
         if subscription is None:
             return
         
         if subscription.url().toString().startswith(
-            (self.__defaultSubscriptionUrlString, self.__customSubscriptionUrlString)):
+            (self.__defaultSubscriptionUrlString,
+             self.__customSubscriptionUrlString)):
             return
         
         try:
@@ -215,7 +220,8 @@
         """
         Public method to add an AdBlock subscription.
         
-        @param subscription AdBlock subscription to be added (AdBlockSubscription)
+        @param subscription AdBlock subscription to be added
+            (AdBlockSubscription)
         """
         if subscription is None:
             return
@@ -276,7 +282,8 @@
         subscriptions = Preferences.getHelp("AdBlockSubscriptions")
         if subscriptions:
             for subscription in subscriptions:
-                if subscription.startswith(self.__defaultSubscriptionUrlString):
+                if subscription.startswith(
+                        self.__defaultSubscriptionUrlString):
                     break
             else:
                 subscriptions.insert(0, self.__defaultSubscriptionUrlString)
@@ -309,7 +316,8 @@
         @param title title of the required subscription (string)
         """
         # Step 1: check, if the subscription is in the list of subscriptions
-        urlString = "abp:subscribe?location={0}&title={1}".format(location, title)
+        urlString = "abp:subscribe?location={0}&title={1}".format(
+            location, title)
         for subscription in self.__subscriptions:
             if subscription.url().toString().startswith(urlString):
                 # We found it!
@@ -323,10 +331,12 @@
     
     def getRequiresSubscriptions(self, subscription):
         """
-        Public method to get a list of subscriptions, that require the given one.
+        Public method to get a list of subscriptions, that require the given
+        one.
         
         @param subscription subscription to check for (AdBlockSubscription)
-        @return list of subscription requiring the given one (list of AdBlockSubscription)
+        @return list of subscription requiring the given one (list of
+            AdBlockSubscription)
         """
         subscriptions = []
         location = subscription.location().toString()
--- a/Helpviewer/AdBlock/AdBlockPage.py	Wed Oct 09 19:26:41 2013 +0200
+++ b/Helpviewer/AdBlock/AdBlockPage.py	Wed Oct 09 19:45:07 2013 +0200
@@ -60,8 +60,9 @@
         elementHiding += "{display: none !important;}\n</style>"
         
         bodyElement = docElement.findFirst("body")
-        bodyElement.appendInside('<style type="text/css">\n/* AdBlock for eric */\n' +
-                                 elementHiding)
+        bodyElement.appendInside(
+            '<style type="text/css">\n/* AdBlock for eric */\n' +
+            elementHiding)
 
 
 class AdBlockedPageEntry(object):
--- a/Helpviewer/AdBlock/AdBlockRule.py	Wed Oct 09 19:26:41 2013 +0200
+++ b/Helpviewer/AdBlock/AdBlockRule.py	Wed Oct 09 19:45:07 2013 +0200
@@ -184,7 +184,8 @@
                     # Hiding placeholders of blocked elements
                     handledOptions += 1
             
-            # If we don't handle all options, it's safer to just disable this rule
+            # If we don't handle all options, it's safer to just disable
+            # this rule
             if handledOptions != len(options):
                 self.__internalDisabled = True
                 return
@@ -228,7 +229,8 @@
         if "*" in parsedLine or "^" in parsedLine or "|" in parsedLine:
             pattern = self.__convertPatternToRegExp(parsedLine)
             self.__useRegExp = True
-            self.__regExp = QRegExp(pattern, self.__caseSensitivity, QRegExp.RegExp)
+            self.__regExp = QRegExp(pattern, self.__caseSensitivity,
+                                    QRegExp.RegExp)
             return
         
         # no regexp required
@@ -275,7 +277,8 @@
             matched = domain.endswith(self.__matchString)
         elif self.__useEndsMatch:
             if self.__caseSensitivity == Qt.CaseInsensitive:
-                matched = encodedUrl.lower().endswith(self.__matchString.lower())
+                matched = encodedUrl.lower().endswith(
+                    self.__matchString.lower())
             else:
                 matched = encodedUrl.endswith(self.__matchString)
         else:
@@ -542,19 +545,26 @@
         """
         pattern = wildcardPattern
         
-        pattern = re.sub(r"\*+", "*", pattern)       # remove multiple wildcards
-        pattern = re.sub(r"\^\|$", "^", pattern)     # remove anchors following separator
-                                                     # placeholder
-        pattern = re.sub(r"^(\*)", "", pattern)      # remove leading wildcards
-        pattern = re.sub(r"(\*)$", "", pattern)      # remove trailing wildcards
-        pattern = re.sub(r"(\W)", r"\\\1", pattern)  # escape special symbols
+        # remove multiple wildcards
+        pattern = re.sub(r"\*+", "*", pattern)
+        # remove anchors following separator placeholder
+        pattern = re.sub(r"\^\|$", "^", pattern)
+        # remove leading wildcards
+        pattern = re.sub(r"^(\*)", "", pattern)
+        # remove trailing wildcards
+        pattern = re.sub(r"(\*)$", "", pattern)
+        # escape special symbols
+        pattern = re.sub(r"(\W)", r"\\\1", pattern)
+        # process extended anchor at expression start
         pattern = re.sub(r"^\\\|\\\|",
-            r"^[\w\-]+:\/+(?!\/)(?:[^\/]+\.)?", pattern)  # process extended anchor at
-                                                          # expression start
-        pattern = re.sub(r"\\\^",
-            r"(?:[^\w\d\-.%]|$)", pattern)           # process separator placeholders
-        pattern = re.sub(r"^\\\|", "^", pattern)     # process anchor at expression start
-        pattern = re.sub(r"\\\|$", "$", pattern)     # process anchor at expression end
-        pattern = re.sub(r"\\\*", ".*", pattern)     # replace wildcards by .*
+            r"^[\w\-]+:\/+(?!\/)(?:[^\/]+\.)?", pattern)
+        # process separator placeholders
+        pattern = re.sub(r"\\\^", r"(?:[^\w\d\-.%]|$)", pattern)
+        # process anchor at expression start
+        pattern = re.sub(r"^\\\|", "^", pattern)
+        # process anchor at expression end
+        pattern = re.sub(r"\\\|$", "$", pattern)
+        # replace wildcards by .*
+        pattern = re.sub(r"\\\*", ".*", pattern)
         
         return pattern
--- a/Helpviewer/AdBlock/AdBlockSubscription.py	Wed Oct 09 19:26:41 2013 +0200
+++ b/Helpviewer/AdBlock/AdBlockSubscription.py	Wed Oct 09 19:45:07 2013 +0200
@@ -12,8 +12,8 @@
 import hashlib
 import base64
 
-from PyQt4.QtCore import pyqtSignal, Qt, QObject, QByteArray, QDateTime, QUrl, \
-    QCryptographicHash, QFile, QIODevice, QTextStream, QDate, QTime
+from PyQt4.QtCore import pyqtSignal, Qt, QObject, QByteArray, QDateTime, \
+    QUrl, QCryptographicHash, QFile, QIODevice, QTextStream, QDate, QTime
 from PyQt4.QtNetwork import QNetworkReply
 
 from E5Gui import E5MessageBox
@@ -69,7 +69,8 @@
         self.__documentRules = []
         self.__elemhideRules = []
         
-        self.__checksumRe = re.compile(r"""^\s*!\s*checksum[\s\-:]+([\w\+\/=]+).*\n""",
+        self.__checksumRe = re.compile(
+            r"""^\s*!\s*checksum[\s\-:]+([\w\+\/=]+).*\n""",
             re.IGNORECASE | re.MULTILINE)
         self.__expiresRe = re.compile(
             r"""(?:expires:|expires after)\s*(\d+)\s*(hour|h)?""",
@@ -111,20 +112,21 @@
         
         self.__title = \
             QUrl.fromPercentEncoding(url.encodedQueryItemValue("title"))
-        self.__enabled = \
-            QUrl.fromPercentEncoding(url.encodedQueryItemValue("enabled")) != "false"
-        self.__location = \
-            QByteArray(QUrl.fromPercentEncoding(url.encodedQueryItemValue("location")))
+        self.__enabled = QUrl.fromPercentEncoding(
+            url.encodedQueryItemValue("enabled")) != "false"
+        self.__location = QByteArray(QUrl.fromPercentEncoding(
+            url.encodedQueryItemValue("location")))
         
         # Check for required subscription
-        self.__requiresLocation = \
-            QUrl.fromPercentEncoding(url.encodedQueryItemValue("requiresLocation"))
-        self.__requiresTitle = \
-            QUrl.fromPercentEncoding(url.encodedQueryItemValue("requiresTitle"))
+        self.__requiresLocation = QUrl.fromPercentEncoding(
+            url.encodedQueryItemValue("requiresLocation"))
+        self.__requiresTitle = QUrl.fromPercentEncoding(
+            url.encodedQueryItemValue("requiresTitle"))
         if self.__requiresLocation and self.__requiresTitle:
             import Helpviewer.HelpWindow
-            Helpviewer.HelpWindow.HelpWindow.adBlockManager().loadRequiredSubscription(
-                self.__requiresLocation, self.__requiresTitle)
+            Helpviewer.HelpWindow.HelpWindow.adBlockManager()\
+                .loadRequiredSubscription(self.__requiresLocation,
+                                          self.__requiresTitle)
         
         lastUpdateByteArray = url.encodedQueryItemValue("lastUpdate")
         lastUpdateString = QUrl.fromPercentEncoding(lastUpdateByteArray)
@@ -245,13 +247,14 @@
         if self.__location.isEmpty():
             return ""
         
-        sha1 = bytes(
-            QCryptographicHash.hash(self.__location, QCryptographicHash.Sha1).toHex())\
-            .decode()
-        dataDir = os.path.join(Utilities.getConfigDir(), "browser", "subscriptions")
+        sha1 = bytes(QCryptographicHash.hash(
+            self.__location, QCryptographicHash.Sha1).toHex()).decode()
+        dataDir = os.path.join(
+            Utilities.getConfigDir(), "browser", "subscriptions")
         if not os.path.exists(dataDir):
             os.makedirs(dataDir)
-        fileName = os.path.join(dataDir, "adblock_subscription_{0}".format(sha1))
+        fileName = os.path.join(
+            dataDir, "adblock_subscription_{0}".format(sha1))
         return fileName
     
     def __loadRules(self):
@@ -264,7 +267,8 @@
             if not f.open(QIODevice.ReadOnly):
                 E5MessageBox.warning(None,
                     self.trUtf8("Load subscription rules"),
-                    self.trUtf8("""Unable to open adblock file '{0}' for reading.""")\
+                    self.trUtf8(
+                        """Unable to open adblock file '{0}' for reading.""")\
                         .format(fileName))
             else:
                 textStream = QTextStream(f)
@@ -299,10 +303,13 @@
                                 self.__updatePeriod = int(period) * 24
                         remoteModified = self.__remoteModifiedRe.search(line)
                         if remoteModified:
-                            day, month, year, time, hour, minute = remoteModified.groups()
+                            day, month, year, time, hour, minute = \
+                                remoteModified.groups()
                             self.__remoteModified.setDate(
-                                QDate(int(year), self.__monthNameToNumber[month],
-                                      int(day)))
+                                QDate(int(year),
+                                      self.__monthNameToNumber[month],
+                                      int(day))
+                            )
                             if time:
                                 self.__remoteModified.setTime(
                                     QTime(int(hour), int(minute)))
@@ -365,8 +372,10 @@
                 # don't show error if we try to load the default
                 E5MessageBox.warning(None,
                     self.trUtf8("Downloading subscription rules"),
-                    self.trUtf8("""<p>Subscription rules could not be downloaded.</p>"""
-                                """<p>Error: {0}</p>""").format(reply.errorString()))
+                    self.trUtf8(
+                        """<p>Subscription rules could not be"""
+                        """ downloaded.</p><p>Error: {0}</p>""")
+                        .format(reply.errorString()))
             else:
                 # reset after first download attempt
                 self.__defaultSubscription = False
@@ -384,7 +393,8 @@
         if not f.open(QIODevice.ReadWrite):
             E5MessageBox.warning(None,
                 self.trUtf8("Downloading subscription rules"),
-                self.trUtf8("""Unable to open adblock file '{0}' for writing.""")\
+                self.trUtf8(
+                    """Unable to open adblock file '{0}' for writing.""")\
                     .file(fileName))
             return
         f.write(response)
@@ -427,18 +437,21 @@
         # calculate checksum
         md5 = hashlib.md5()
         md5.update(data.encode("utf-8"))
-        calculatedChecksum = base64.b64encode(md5.digest()).decode().rstrip("=")
+        calculatedChecksum = base64.b64encode(md5.digest()).decode()\
+            .rstrip("=")
         if calculatedChecksum == expectedChecksum:
             return True
         else:
             res = E5MessageBox.yesNo(None,
                 self.trUtf8("Downloading subscription rules"),
-                self.trUtf8("""<p>AdBlock subscription <b>{0}</b> has a wrong"""
-                            """ checksum.<br/>"""
-                            """Found: {1}<br/>"""
-                            """Calculated: {2}<br/>"""
-                            """Use it anyway?</p>""")\
-                    .format(self.__title, expectedChecksum, calculatedChecksum))
+                self.trUtf8(
+                    """<p>AdBlock subscription <b>{0}</b> has a wrong"""
+                    """ checksum.<br/>"""
+                    """Found: {1}<br/>"""
+                    """Calculated: {2}<br/>"""
+                    """Use it anyway?</p>""")\
+                    .format(self.__title, expectedChecksum,
+                            calculatedChecksum))
             return res
     
     def saveRules(self):
@@ -453,7 +466,8 @@
         if not f.open(QIODevice.ReadWrite | QIODevice.Truncate):
             E5MessageBox.warning(None,
                 self.trUtf8("Saving subscription rules"),
-                self.trUtf8("""Unable to open adblock file '{0}' for writing.""")\
+                self.trUtf8(
+                    """Unable to open adblock file '{0}' for writing.""")\
                     .format(fileName))
             return
         
@@ -497,7 +511,8 @@
     
     def elemHideDisabledForUrl(self, url):
         """
-        Public method to check, if element hiding is disabled for the given URL.
+        Public method to check, if element hiding is disabled for the given
+        URL.
         
         @param url URL to check (QUrl)
         @return flag indicating disabled state (boolean)
@@ -658,6 +673,7 @@
         if rule.isCSSRule():
             import Helpviewer.HelpWindow
             self.__populateCache()
-            Helpviewer.HelpWindow.HelpWindow.mainWindow().reloadUserStyleSheet()
+            Helpviewer.HelpWindow.HelpWindow.mainWindow()\
+                .reloadUserStyleSheet()
         
         return rule
--- a/Helpviewer/AdBlock/AdBlockTreeWidget.py	Wed Oct 09 19:26:41 2013 +0200
+++ b/Helpviewer/AdBlock/AdBlockTreeWidget.py	Wed Oct 09 19:45:07 2013 +0200
@@ -8,8 +8,8 @@
 """
 
 from PyQt4.QtCore import Qt
-from PyQt4.QtGui import QAbstractItemView, QFont, QTreeWidgetItem, QInputDialog, \
-    QLineEdit, QMenu, QApplication, QColor
+from PyQt4.QtGui import QAbstractItemView, QFont, QTreeWidgetItem, \
+    QInputDialog, QLineEdit, QMenu, QApplication, QColor
 
 from E5Gui.E5TreeWidget import E5TreeWidget
 
@@ -219,7 +219,8 @@
         
         self.__itemChangingBlock = True
         self.__topItem.setText(0,
-            self.trUtf8("{0} (recently updated)").format(self.__subscription.title()))
+            self.trUtf8("{0} (recently updated)").format(
+                self.__subscription.title()))
         self.__itemChangingBlock = False
     
     def __adjustItemFeatures(self, itm, rule):

eric ide

mercurial