eric6/Helpviewer/AdBlock/AdBlockBlockedNetworkReply.py

changeset 6942
2602857055c5
parent 6891
93f82da09f22
equal deleted inserted replaced
6941:f99d60d6b59b 6942:2602857055c5
1 # -*- coding: utf-8 -*-
2
3 # Copyright (c) 2009 - 2019 Detlev Offenbach <detlev@die-offenbachs.de>
4 #
5
6 """
7 Module implementing a QNetworkReply subclass reporting a blocked request.
8 """
9
10 from __future__ import unicode_literals
11
12 from PyQt5.QtCore import QTimer
13 from PyQt5.QtNetwork import QNetworkReply, QNetworkAccessManager
14
15
16 class AdBlockBlockedNetworkReply(QNetworkReply):
17 """
18 Class implementing a QNetworkReply subclass reporting a blocked request.
19 """
20 def __init__(self, request, subscription, rule, parent=None):
21 """
22 Constructor
23
24 @param request reference to the request object (QNetworkRequest)
25 @param subscription subscription containing the matched rule
26 (AdBlockSubscription)
27 @param rule matching rule (AdBlockRule)
28 @param parent reference to the parent object (QObject)
29 """
30 super(AdBlockBlockedNetworkReply, self).__init__(parent)
31 self.setOperation(QNetworkAccessManager.GetOperation)
32 self.setRequest(request)
33 self.setUrl(request.url())
34 self.setError(
35 QNetworkReply.ContentAccessDenied,
36 "AdBlockRule:{0} ({1})"
37 .format(subscription.title(), rule.filter()))
38 QTimer.singleShot(0, self.__fireSignals)
39
40 def __fireSignals(self):
41 """
42 Private method to send some signals to end the connection.
43 """
44 self.error[QNetworkReply.NetworkError].emit(
45 QNetworkReply.ContentAccessDenied)
46 self.finished.emit()
47
48 def readData(self, maxlen):
49 """
50 Public method to retrieve data from the reply object.
51
52 @param maxlen maximum number of bytes to read (integer)
53 @return string containing the data (string)
54 """
55 return ""
56
57 def abort(self):
58 """
59 Public slot to abort the operation.
60 """
61 # do nothing
62 pass

eric ide

mercurial