From 8cfc93c70c3c3348a886ff9c3df5ac5f61d3dba2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marta=20Marczykowska-G=C3=B3recka?= Date: Thu, 9 Nov 2017 17:57:21 +0100 Subject: [PATCH] Misc errors part 2 Renamed variable from 'input' to 'input_string' and moved imports to a better place (that is, at the beginning of the module and not inside of a function). --- qubesmanager/firewall.py | 20 ++++++++++---------- qubesmanager/global_settings.py | 5 ++--- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/qubesmanager/firewall.py b/qubesmanager/firewall.py index a5d9d75..68b5cc0 100644 --- a/qubesmanager/firewall.py +++ b/qubesmanager/firewall.py @@ -34,15 +34,15 @@ class QIPAddressValidator(QtGui.QValidator): def __init__(self, parent=None): super(QIPAddressValidator, self).__init__(parent) - def validate(self, input, pos): + def validate(self, input_string, pos): # pylint: disable=too-many-return-statements,no-self-use - hostname = str(input) + hostname = str(input_string) if len(hostname) > 255 or len(hostname) == 0: - return (QtGui.QValidator.Intermediate, input, pos) + return (QtGui.QValidator.Intermediate, input_string, pos) if hostname == "*": - return (QtGui.QValidator.Acceptable, input, pos) + return (QtGui.QValidator.Acceptable, input_string, pos) unmask = hostname.split("/", 1) if len(unmask) == 2: @@ -50,25 +50,25 @@ class QIPAddressValidator(QtGui.QValidator): mask = unmask[1] if mask.isdigit() or mask == "": if re.match(r"^([0-9]{1,3}\.){3}[0-9]{1,3}$", hostname) is None: - return (QtGui.QValidator.Invalid, input, pos) + return (QtGui.QValidator.Invalid, input_string, pos) if mask != "": mask = int(unmask[1]) if mask < 0 or mask > 32: - return (QtGui.QValidator.Invalid, input, pos) + return (QtGui.QValidator.Invalid, input_string, pos) else: - return (QtGui.QValidator.Invalid, input, pos) + return (QtGui.QValidator.Invalid, input_string, pos) if hostname[-1:] == ".": hostname = hostname[:-1] if hostname[-1:] == "-": - return (QtGui.QValidator.Intermediate, input, pos) + return (QtGui.QValidator.Intermediate, input_string, pos) allowed = re.compile(r"(?!-)[A-Z\d-]{1,63}(? def handle_exception(exc_type, exc_value, exc_traceback): - import os.path - import traceback - filename, line, dummy, dummy = traceback.extract_tb(exc_traceback).pop() filename = os.path.basename(filename) error = "%s: %s" % (exc_type.__name__, exc_value)