Pass HTTPClient to PastebinClient as argument

This commit is contained in:
Florian Bruhin 2016-03-29 19:21:15 +02:00
parent 25555682dc
commit 86ab33c558
2 changed files with 13 additions and 8 deletions

View File

@ -23,8 +23,6 @@ import urllib.parse
from PyQt5.QtCore import pyqtSignal, pyqtSlot, QObject, QUrl
from qutebrowser.misc import httpclient
class PastebinClient(QObject):
@ -47,11 +45,17 @@ class PastebinClient(QObject):
success = pyqtSignal(str)
error = pyqtSignal(str)
def __init__(self, parent=None):
def __init__(self, client, parent=None):
"""Constructor.
Args:
client: The HTTPClient to use. Will be reparented.
"""
super().__init__(parent)
self._client = httpclient.HTTPClient(self)
self._client.error.connect(self.error)
self._client.success.connect(self.on_client_success)
client.setParent(self)
client.error.connect(self.error)
client.success.connect(self.on_client_success)
self._client = client
def paste(self, name, title, text, parent=None):
"""Paste the text into a pastebin and return the URL.

View File

@ -36,7 +36,7 @@ from PyQt5.QtWidgets import (QDialog, QLabel, QTextEdit, QPushButton,
import qutebrowser
from qutebrowser.utils import version, log, utils, objreg, qtutils
from qutebrowser.misc import miscwidgets, autoupdate, msgbox
from qutebrowser.misc import miscwidgets, autoupdate, msgbox, httpclient
from qutebrowser.browser.network import pastebin
from qutebrowser.config import config
@ -141,7 +141,8 @@ class _CrashDialog(QDialog):
self.setWindowTitle("Whoops!")
self.resize(QSize(640, 600))
self._vbox = QVBoxLayout(self)
self._paste_client = pastebin.PastebinClient(self)
http_client = httpclient.HTTPClient()
self._paste_client = pastebin.PastebinClient(http_client, self)
self._pypi_client = autoupdate.PyPIVersionClient(self)
self._init_text()