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 PyQt5.QtCore import pyqtSignal, pyqtSlot, QObject, QUrl
from qutebrowser.misc import httpclient
class PastebinClient(QObject): class PastebinClient(QObject):
@ -47,11 +45,17 @@ class PastebinClient(QObject):
success = pyqtSignal(str) success = pyqtSignal(str)
error = 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) super().__init__(parent)
self._client = httpclient.HTTPClient(self) client.setParent(self)
self._client.error.connect(self.error) client.error.connect(self.error)
self._client.success.connect(self.on_client_success) client.success.connect(self.on_client_success)
self._client = client
def paste(self, name, title, text, parent=None): def paste(self, name, title, text, parent=None):
"""Paste the text into a pastebin and return the URL. """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 import qutebrowser
from qutebrowser.utils import version, log, utils, objreg, qtutils 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.browser.network import pastebin
from qutebrowser.config import config from qutebrowser.config import config
@ -141,7 +141,8 @@ class _CrashDialog(QDialog):
self.setWindowTitle("Whoops!") self.setWindowTitle("Whoops!")
self.resize(QSize(640, 600)) self.resize(QSize(640, 600))
self._vbox = QVBoxLayout(self) 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._pypi_client = autoupdate.PyPIVersionClient(self)
self._init_text() self._init_text()