From f45d572677ed6356a798b9ed109bca62e85a0bf9 Mon Sep 17 00:00:00 2001 From: George Edward Bulmer Date: Tue, 6 Feb 2018 19:48:31 +0000 Subject: [PATCH] Some style fixes in PR #3480's review --- qutebrowser/browser/qutescheme.py | 2 +- qutebrowser/misc/pastebin.py | 6 +++--- qutebrowser/misc/utilcmds.py | 6 +++++- qutebrowser/utils/utils.py | 8 ++++---- 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/qutebrowser/browser/qutescheme.py b/qutebrowser/browser/qutescheme.py index 50b25aa74..9779b3949 100644 --- a/qutebrowser/browser/qutescheme.py +++ b/qutebrowser/browser/qutescheme.py @@ -479,7 +479,7 @@ def qute_configdiff(url): @add_handler('pastebin-version') -def qute_pastebin_version(url): # transfusion: pylint: disable=unused-argument +def qute_pastebin_version(_url): """Handler that pastebins the version string.""" utils.pastebin_version() return 'text/plain', b'Paste called.' diff --git a/qutebrowser/misc/pastebin.py b/qutebrowser/misc/pastebin.py index 423709910..0f2ed8ce4 100644 --- a/qutebrowser/misc/pastebin.py +++ b/qutebrowser/misc/pastebin.py @@ -42,7 +42,7 @@ class PastebinClient(QObject): """ API_URL = 'https://crashes.qutebrowser.org/api/' - MISC_API_URL = 'http://paste.the-compiler.org/api/' + MISC_API_URL = 'https://paste.the-compiler.org/api/' success = pyqtSignal(str) error = pyqtSignal(str) @@ -58,7 +58,7 @@ class PastebinClient(QObject): client.error.connect(self.error) client.success.connect(self.on_client_success) self._client = client - self.api_url = api_url + self._api_url = api_url def paste(self, name, title, text, parent=None): """Paste the text into a pastebin and return the URL. @@ -77,7 +77,7 @@ class PastebinClient(QObject): } if parent is not None: data['reply'] = parent - url = QUrl(urllib.parse.urljoin(self.api_url, 'create')) + url = QUrl(urllib.parse.urljoin(self._api_url, 'create')) self._client.post(url, data) @pyqtSlot(str) diff --git a/qutebrowser/misc/utilcmds.py b/qutebrowser/misc/utilcmds.py index 093f79aaa..e1ad25350 100644 --- a/qutebrowser/misc/utilcmds.py +++ b/qutebrowser/misc/utilcmds.py @@ -370,7 +370,11 @@ def nop(): @cmdutils.register() @cmdutils.argument('win_id', win_id=True) def version(win_id, paste=False): - """Show version information.""" + """Show version information. + + Args: + paste: Paste to pastebin. + """ tabbed_browser = objreg.get('tabbed-browser', scope='window', window=win_id) tabbed_browser.openurl(QUrl('qute://version'), newtab=True) diff --git a/qutebrowser/utils/utils.py b/qutebrowser/utils/utils.py index 3579ac243..afad0f0c2 100644 --- a/qutebrowser/utils/utils.py +++ b/qutebrowser/utils/utils.py @@ -920,8 +920,7 @@ def yaml_dump(data, f=None): def pastebin_version(): - """Pastebins version and logs to messages""" - + """Pastebin the version and log the url to messages.""" app = qutebrowser.utils.objreg.get('app') http_client = httpclient.HTTPClient() @@ -938,9 +937,10 @@ def pastebin_version(): qutebrowser.utils.message.info("Failed to pastebin version" " info: {}".format(text)) + misc_api = pastebin.PastebinClient.MISC_API_URL pbclient = pastebin.PastebinClient(http_client, parent=app, - api_url= - pastebin.PastebinClient.MISC_API_URL) + api_url=misc_api) + pbclient.success.connect(_on_paste_version_success) pbclient.error.connect(_on_paste_version_err)