python: Avoid shadowing standard or global names.
authorBen Pfaff <blp@nicira.com>
Thu, 25 Aug 2011 00:12:53 +0000 (17:12 -0700)
committerBen Pfaff <blp@nicira.com>
Fri, 23 Sep 2011 16:10:44 +0000 (09:10 -0700)
Found by pychecker.

python/ovs/db/schema.py
python/ovs/db/types.py
python/ovs/fatal_signal.py
python/ovs/json.py
python/ovs/jsonrpc.py
python/ovs/util.py

index 29fe986a254c56a0f47aa9057914f21d21903d8b..65ddca60042b615a70dd972a29352a87392e0be3 100644 (file)
@@ -249,10 +249,10 @@ class ColumnSchema(object):
         parser = ovs.db.parser.Parser(json, "schema for column %s" % name)
         mutable = parser.get_optional("mutable", [bool], True)
         ephemeral = parser.get_optional("ephemeral", [bool], False)
-        type = types.Type.from_json(parser.get("type", [dict, unicode]))
+        type_ = types.Type.from_json(parser.get("type", [dict, unicode]))
         parser.finish()
 
-        return ColumnSchema(name, mutable, not ephemeral, type)
+        return ColumnSchema(name, mutable, not ephemeral, type_)
 
     def to_json(self):
         json = {"type": self.type.to_json()}
index 8b29000596f34fb94c1cc40745b10c60efd1e1cd..dc19f85c86aca0552122fdf7e6ddf9c278be369b 100644 (file)
@@ -539,9 +539,9 @@ class Type(object):
                          'OVSDB_TYPE_VOID);' % (indent, var))
         initMin = "%s%s.n_min = %s;" % (indent, var, self.n_min)
         if self.n_max == sys.maxint:
-            max = "UINT_MAX"
+            n_max = "UINT_MAX"
         else:
-            max = self.n_max
-        initMax = "%s%s.n_max = %s;" % (indent, var, max)
+            n_max = self.n_max
+        initMax = "%s%s.n_max = %s;" % (indent, var, n_max)
         return "\n".join((initKey, initValue, initMin, initMax))
 
index 765f6831963b2ddad1ffff580e7804710aa2a84c..de8f37c011b373dec4df324618b6f5e4835a339c 100644 (file)
@@ -68,8 +68,8 @@ def unlink_file_now(file):
     return error
 
 def _unlink_files():
-    for file in _files:
-        _unlink(file)
+    for file_ in _files:
+        _unlink(file_)
 
 def _cancel_files():
     global _added_hook
@@ -77,9 +77,9 @@ def _cancel_files():
     _added_hook = False
     _files = {}
 
-def _unlink(file):
+def _unlink(file_):
     try:
-        os.unlink(file)
+        os.unlink(file_)
         return 0
     except OSError, e:
         return e.errno
index 6283c9132bcec406d2ed4f203e65caa9fc778f0e..2d7e2ec37d4b91a09452483d1461da489b8199b8 100644 (file)
@@ -23,9 +23,9 @@ escapes = {ord('"'): u"\\\"",
            ord("\n"): u"\\n",
            ord("\r"): u"\\r",
            ord("\t"): u"\\t"}
-for i in range(32):
-    if i not in escapes:
-        escapes[i] = u"\\u%04x" % i
+for esc in range(32):
+    if esc not in escapes:
+        escapes[esc] = u"\\u%04x" % esc
 
 def __dump_string(stream, s):
     stream.write(u'"%s"' % ''.join(escapes.get(ord(c), c) for c in s))
index 5117944137e7ac15661c1ff4789f27c07c2c5cd3..7aea31b1b2917d7a35fb60980c9d345b8a6afddc 100644 (file)
@@ -119,7 +119,7 @@ class Message(object):
         params = json.pop("params", None)
         result = json.pop("result", None)
         error = json.pop("error", None)
-        id = json.pop("id", None)
+        id_ = json.pop("id", None)
         if len(json):
             return "message has unexpected member \"%s\"" % json.popitem()[0]
 
@@ -127,12 +127,12 @@ class Message(object):
             msg_type = Message.T_REPLY
         elif error is not None:
             msg_type = Message.T_ERROR
-        elif id is not None:
+        elif id_ is not None:
             msg_type = Message.T_REQUEST
         else:
             msg_type = Message.T_NOTIFY
         
-        msg = Message(msg_type, method, params, result, error, id)
+        msg = Message(msg_type, method, params, result, error, id_)
         validation_error = msg.is_valid()
         if validation_error is not None:
             return validation_error
@@ -289,13 +289,13 @@ class Connection(object):
             poller.block()
     
     def transact_block(self, request):
-        id = request.id
+        id_ = request.id
 
         error = self.send(request)
         reply = None
         while not error:
             error, reply = self.recv_block()
-            if reply and reply.type == Message.T_REPLY and reply.id == id:
+            if reply and reply.type == Message.T_REPLY and reply.id == id_:
                 break
         return error, reply
 
index aa4b9bc3dadb125bf5942b4265ae85cca029d564..d218d3d076f2d0a4d60dd23e88d2163e84e5a2a3 100644 (file)
@@ -18,26 +18,26 @@ import sys
 
 PROGRAM_NAME = os.path.basename(sys.argv[0])
 
-def abs_file_name(dir, file_name):
+def abs_file_name(dir_, file_name):
     """If 'file_name' starts with '/', returns a copy of 'file_name'.
     Otherwise, returns an absolute path to 'file_name' considering it relative
-    to 'dir', which itself must be absolute.  'dir' may be None or the empty
+    to 'dir_', which itself must be absolute.  'dir_' may be None or the empty
     string, in which case the current working directory is used.
 
-    Returns None if 'dir' is null and getcwd() fails.
+    Returns None if 'dir_' is None and getcwd() fails.
 
     This differs from os.path.abspath() in that it will never change the
     meaning of a file name."""
     if file_name.startswith('/'):
         return file_name
     else:
-        if dir is None or dir == "":
+        if dir_ is None or dir_ == "":
             try:
-                dir = os.getcwd()
+                dir_ = os.getcwd()
             except OSError:
                 return None
 
-        if dir.endswith('/'):
-            return dir + file_name
+        if dir_.endswith('/'):
+            return dir_ + file_name
         else:
-            return "%s/%s" % (dir, file_name)
+            return "%s/%s" % (dir_, file_name)