Fix ALL the lint
This commit is contained in:
parent
1f4ca39e53
commit
ecc838d02c
@ -23,7 +23,7 @@ disable=no-self-use,
|
||||
[BASIC]
|
||||
module-rgx=[a-z_]*$
|
||||
const-rgx=[A-Za-z_][A-Za-z0-9_]{0,30}$
|
||||
method-rgx=[a-z_][A-Za-z0-9_]{2,30}$
|
||||
method-rgx=[a-z_][A-Za-z0-9_]{2,40}$
|
||||
attr-rgx=[a-z_][a-z0-9_]{0,30}$
|
||||
argument-rgx=[a-z_][a-z0-9_]{0,30}$
|
||||
variable-rgx=[a-z_][a-z0-9_]{0,30}$
|
||||
|
@ -20,11 +20,10 @@
|
||||
import os
|
||||
import logging
|
||||
import subprocess
|
||||
from tempfile import mkstemp
|
||||
from functools import partial
|
||||
|
||||
from PyQt5.QtWidgets import QApplication
|
||||
from PyQt5.QtCore import Qt, QObject, QProcess
|
||||
from PyQt5.QtCore import Qt, QObject
|
||||
from PyQt5.QtGui import QClipboard
|
||||
from PyQt5.QtPrintSupport import QPrintDialog, QPrintPreviewDialog
|
||||
|
||||
@ -607,7 +606,8 @@ class CommandDispatcher(QObject):
|
||||
return
|
||||
text = elem.evaluateJavaScript('this.value')
|
||||
self._editor = ExternalEditor()
|
||||
self._editor.editing_finished.connect(partial(self.on_editing_finished, elem))
|
||||
self._editor.editing_finished.connect(
|
||||
partial(self.on_editing_finished, elem))
|
||||
self._editor.edit(text)
|
||||
|
||||
def on_editing_finished(self, elem, text):
|
||||
|
@ -49,6 +49,16 @@ class NetworkManager(QNetworkAccessManager):
|
||||
self.proxyAuthenticationRequired.connect(
|
||||
self.on_proxy_authentication_required)
|
||||
|
||||
def _fill_authenticator(self, authenticator, answer):
|
||||
"""Fill a given QAuthenticator object with an answer."""
|
||||
if answer is not None:
|
||||
# Since the answer could be something else than (user, password)
|
||||
# pylint seems to think we're unpacking a non-sequence. However we
|
||||
# *did* explicitely ask for a tuple, so it *will* always be one.
|
||||
user, password = answer # pylint: disable=unpacking-non-sequence
|
||||
authenticator.setUser(user)
|
||||
authenticator.setPassword(password)
|
||||
|
||||
def abort_requests(self):
|
||||
"""Abort all running requests."""
|
||||
for request in self._requests.values():
|
||||
@ -73,25 +83,20 @@ class NetworkManager(QNetworkAccessManager):
|
||||
reply.ignoreSslErrors()
|
||||
|
||||
@pyqtSlot('QNetworkReply', 'QAuthenticator')
|
||||
def on_authentication_required(self, reply, authenticator):
|
||||
def on_authentication_required(self, _reply, authenticator):
|
||||
"""Called when a website needs authentication."""
|
||||
answer = message.modular_question(
|
||||
text="Username ({}):".format(authenticator.realm()),
|
||||
"Username ({}):".format(authenticator.realm()),
|
||||
mode=PromptMode.user_pwd)
|
||||
if answer is not None:
|
||||
user, password = answer
|
||||
authenticator.setUser(user)
|
||||
authenticator.setPassword(password)
|
||||
self._fill_authenticator(authenticator, answer)
|
||||
|
||||
@pyqtSlot('QNetworkProxy', 'QAuthenticator')
|
||||
def on_proxy_authentication_required(self, proxy, authenticator):
|
||||
def on_proxy_authentication_required(self, _proxy, authenticator):
|
||||
"""Called when a proxy needs authentication."""
|
||||
answer = message.modular_question(
|
||||
text="Proxy username ({}):".format(authenticator.realm()),
|
||||
"Proxy username ({}):".format(authenticator.realm()),
|
||||
mode=PromptMode.user_pwd)
|
||||
if answer is not None:
|
||||
user, password = answer
|
||||
authenticator.setUser(user)
|
||||
authenticator.setPassword(password)
|
||||
self._fill_authenticator(authenticator, answer)
|
||||
|
||||
def createRequest(self, op, req, outgoing_data):
|
||||
"""Return a new QNetworkReply object.
|
||||
|
@ -24,6 +24,7 @@ from tempfile import mkstemp
|
||||
from PyQt5.QtCore import pyqtSignal, QProcess, QObject
|
||||
|
||||
import qutebrowser.config.config as config
|
||||
import qutebrowser.utils.message as message
|
||||
|
||||
|
||||
class ExternalEditor(QObject):
|
||||
@ -40,6 +41,7 @@ class ExternalEditor(QObject):
|
||||
self.proc = None
|
||||
|
||||
def _cleanup(self):
|
||||
"""Clean up temporary files after the editor closed."""
|
||||
os.close(self.oshandle)
|
||||
try:
|
||||
os.remove(self.filename)
|
||||
@ -81,7 +83,7 @@ class ExternalEditor(QObject):
|
||||
QProcess.WriteError: ("An error occurred when attempting to write "
|
||||
"to the process."),
|
||||
QProcess.ReadError: ("An error occurred when attempting to read "
|
||||
"from the process."),
|
||||
"from the process."),
|
||||
QProcess.UnknownError: "An unknown error occurred.",
|
||||
}
|
||||
message.error("Error while calling editor: {}".format(messages[error]))
|
||||
|
@ -62,11 +62,11 @@ def text(message):
|
||||
instance().text.emit(message)
|
||||
|
||||
|
||||
def modular_question(text, mode, default=None):
|
||||
def modular_question(message, mode, default=None):
|
||||
"""Ask a modular question in the statusbar.
|
||||
|
||||
Args:
|
||||
text: The message to display to the user.
|
||||
message: The message to display to the user.
|
||||
mode: A PromptMode.
|
||||
default: The default value to display.
|
||||
|
||||
@ -74,7 +74,7 @@ def modular_question(text, mode, default=None):
|
||||
The answer the user gave or None if the prompt was cancelled.
|
||||
"""
|
||||
q = Question()
|
||||
q.text = text
|
||||
q.text = message
|
||||
q.mode = mode
|
||||
q.default = default
|
||||
instance().question.emit(q, True)
|
||||
|
@ -35,7 +35,6 @@ from PyQt5.QtCore import QCoreApplication, QStandardPaths
|
||||
from pkg_resources import resource_string
|
||||
|
||||
import qutebrowser
|
||||
import qutebrowser.utils.message as message
|
||||
|
||||
|
||||
MAXVALS = {
|
||||
@ -106,7 +105,6 @@ def read_file(filename):
|
||||
with open(fn, 'r', encoding='UTF-8') as f:
|
||||
return f.read()
|
||||
else:
|
||||
from pkg_resources import resource_string
|
||||
return resource_string(qutebrowser.__name__, filename).decode('UTF-8')
|
||||
|
||||
|
||||
|
@ -22,7 +22,6 @@ from PyQt5.QtWidgets import QHBoxLayout, QWidget, QLineEdit
|
||||
|
||||
import qutebrowser.keyinput.modeman as modeman
|
||||
import qutebrowser.commands.utils as cmdutils
|
||||
import qutebrowser.config.config as config
|
||||
from qutebrowser.widgets.statusbar._textbase import TextBase
|
||||
from qutebrowser.widgets.misc import MinimalLineEdit
|
||||
from qutebrowser.utils.usertypes import PromptMode, Question
|
||||
|
@ -206,7 +206,8 @@ class StatusBar(QWidget):
|
||||
|
||||
def _hide_prompt_widget(self):
|
||||
"""Show temporary text instead of prompt widget."""
|
||||
logging.debug("Hiding prompt widget, queue: {}".format(self._text_queue))
|
||||
logging.debug("Hiding prompt widget, queue: {}".format(
|
||||
self._text_queue))
|
||||
if self._timer_was_active:
|
||||
# Restart the text pop timer if it was active before hiding.
|
||||
self._pop_text()
|
||||
@ -317,19 +318,6 @@ class StatusBar(QWidget):
|
||||
self._text_pop_timer.setInterval(config.get('ui',
|
||||
'message-timeout'))
|
||||
|
||||
@pyqtSlot('QNetworkProxy', 'QAuthenticator')
|
||||
def on_proxy_authentication_required(self, proxy, authenticator):
|
||||
q = Question()
|
||||
q.mode = PromptMode.user_pwd
|
||||
q.text = "Proxy username ({}):".format(authenticator.realm())
|
||||
self.prompt.question = q
|
||||
answer = self.prompt.exec_()
|
||||
if answer is not None:
|
||||
user, password = answer
|
||||
logging.debug("user: {} / pwd: {}".format(user, password))
|
||||
authenticator.setUser(user)
|
||||
authenticator.setPassword(password)
|
||||
|
||||
def resizeEvent(self, e):
|
||||
"""Extend resizeEvent of QWidget to emit a resized signal afterwards.
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user