2
0
mirror of https://github.com/openvswitch/ovs synced 2025-09-05 00:35:33 +00:00

python: Avoid using 'type' as a variable name.

'type' is a Python built-in function, so it's best to avoid using it as
a variable name.

Reported-by: Reid Price <reid@nicira.com>
This commit is contained in:
Ben Pfaff
2011-08-23 09:50:46 -07:00
parent d272c10ecd
commit 8758e8a373
6 changed files with 35 additions and 35 deletions

View File

@@ -64,12 +64,12 @@ def returnUnchanged(x):
return x
class Atom(object):
def __init__(self, type, value=None):
self.type = type
def __init__(self, type_, value=None):
self.type = type_
if value is not None:
self.value = value
else:
self.value = type.default_atom()
self.value = type_.default_atom()
def __cmp__(self, other):
if not isinstance(other, Atom) or self.type != other.type:
@@ -85,8 +85,8 @@ class Atom(object):
return hash(self.value)
@staticmethod
def default(type):
return Atom(type)
def default(type_):
return Atom(type_)
def is_default(self):
return self == self.default(self.type)
@@ -227,8 +227,8 @@ class Atom(object):
return Atom(t, x)
class Datum(object):
def __init__(self, type, values={}):
self.type = type
def __init__(self, type_, values={}):
self.type = type_
self.values = values
def __cmp__(self, other):
@@ -250,14 +250,14 @@ class Datum(object):
return Datum(self.type, dict(self.values))
@staticmethod
def default(type):
if type.n_min == 0:
def default(type_):
if type_.n_min == 0:
values = {}
elif type.is_map():
values = {type.key.default(): type.value.default()}
elif type_.is_map():
values = {type_.key.default(): type_.value.default()}
else:
values = {type.key.default(): None}
return Datum(type, values)
values = {type_.key.default(): None}
return Datum(type_, values)
def is_default(self):
return self == Datum.default(self.type)

View File

@@ -75,18 +75,18 @@ id_re = re.compile("[_a-zA-Z][_a-zA-Z0-9]*$")
def is_identifier(s):
return type(s) in [str, unicode] and id_re.match(s)
def json_type_to_string(type):
if type == None:
def json_type_to_string(type_):
if type_ == None:
return "null"
elif type == bool:
elif type_ == bool:
return "boolean"
elif type == dict:
elif type_ == dict:
return "object"
elif type == list:
elif type_ == list:
return "array"
elif type in [int, long, float]:
elif type_ in [int, long, float]:
return "number"
elif type in [str, unicode]:
elif type_ in [str, unicode]:
return "string"
else:
return "<invalid>"

View File

@@ -239,11 +239,11 @@ class TableSchema(object):
return json
class ColumnSchema(object):
def __init__(self, name, mutable, persistent, type):
def __init__(self, name, mutable, persistent, type_):
self.name = name
self.mutable = mutable
self.persistent = persistent
self.type = type
self.type = type_
self.unique = False
@staticmethod

View File

@@ -1,4 +1,4 @@
# Copyright (c) 2010 Nicira Networks
# Copyright (c) 2010, 2011 Nicira Networks
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -36,8 +36,8 @@ class Message(object):
T_ERROR: "error"}
__next_id = 0
def __init__(self, type, method, params, result, error, id):
self.type = type
def __init__(self, type_, method, params, result, error, id):
self.type = type_
self.method = method
self.params = params
self.result = result
@@ -70,8 +70,8 @@ class Message(object):
return Message(Message.T_ERROR, None, None, None, error, id)
@staticmethod
def type_to_string(type):
return Message.__types[type]
def type_to_string(type_):
return Message.__types[type_]
@staticmethod
def __validate_arg(value, name, must_have):

View File

@@ -1,4 +1,4 @@
# Copyright (c) 2010 Nicira Networks
# Copyright (c) 2010, 2011 Nicira Networks
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -15,8 +15,8 @@
import os
import signal
def _signal_status_msg(type, signr):
s = "%s by signal %d" % (type, signr)
def _signal_status_msg(type_, signr):
s = "%s by signal %d" % (type_, signr)
for name in signal.__dict__:
if name.startswith("SIG") and getattr(signal, name) == signr:
return "%s (%s)" % (s, name)

View File

@@ -1,4 +1,4 @@
# Copyright (c) 2010 Nicira Networks
# Copyright (c) 2010, 2011 Nicira Networks
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -332,15 +332,15 @@ class Reconnect(object):
% self.name)
else:
if self.passive:
type = "listen"
type_ = "listen"
else:
type = "connection"
type_ = "connection"
if error > 0:
logging.warning("%s: %s attempt failed (%s)"
% (self.name, type, os.strerror(error)))
% (self.name, type_, os.strerror(error)))
else:
self.info_level("%s: %s attempt timed out"
% (self.name, type))
% (self.name, type_))
if (self.state in (Reconnect.Active, Reconnect.Idle)):
self.last_disconnected = now