Explorar o código

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).
Marta Marczykowska-Górecka %!s(int64=6) %!d(string=hai) anos
pai
achega
8cfc93c70c
Modificáronse 2 ficheiros con 12 adicións e 13 borrados
  1. 10 10
      qubesmanager/firewall.py
  2. 2 3
      qubesmanager/global_settings.py

+ 10 - 10
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}(?<!-)$", re.IGNORECASE)
         if all(allowed.match(x) for x in hostname.split(".")):
-            return (QtGui.QValidator.Acceptable, input, pos)
+            return (QtGui.QValidator.Acceptable, input_string, pos)
 
-        return (QtGui.QValidator.Invalid, input, pos)
+        return (QtGui.QValidator.Invalid, input_string, pos)
 
 class NewFwRuleDlg(QtGui.QDialog, ui_newfwruledlg.Ui_NewFwRuleDlg):
     def __init__(self, parent=None):

+ 2 - 3
qubesmanager/global_settings.py

@@ -22,6 +22,8 @@
 
 import sys
 import os
+import os.path
+import traceback
 from PyQt4 import QtCore, QtGui
 
 from qubesadmin import Qubes
@@ -297,9 +299,6 @@ class GlobalSettingsWindow(ui_globalsettingsdlg.Ui_GlobalSettings,
 # Copyright (c) 2002-2007 Pascal Varet <p.varet@gmail.com>
 
 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)