2
0
mirror of https://github.com/openvswitch/ovs synced 2025-10-25 15:07:05 +00:00

python: Avoid shadowing standard or global names.

Found by pychecker.
This commit is contained in:
Ben Pfaff
2011-08-24 17:12:53 -07:00
parent 28c781df8a
commit 9b46cccc33
6 changed files with 25 additions and 25 deletions

View 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()}

View 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))

View 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

View 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))

View 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

View 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)