From: Ben Pfaff Date: Tue, 23 Aug 2011 16:50:46 +0000 (-0700) Subject: python: Avoid using 'type' as a variable name. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8758e8a373338e409d7f2863ee91e01060f35628;p=openvswitch 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 --- diff --git a/python/ovs/db/data.py b/python/ovs/db/data.py index 551eef17..b68d4e32 100644 --- a/python/ovs/db/data.py +++ b/python/ovs/db/data.py @@ -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) diff --git a/python/ovs/db/parser.py b/python/ovs/db/parser.py index 073f7606..67b3bd53 100644 --- a/python/ovs/db/parser.py +++ b/python/ovs/db/parser.py @@ -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 "" diff --git a/python/ovs/db/schema.py b/python/ovs/db/schema.py index e76d6f67..2d053a04 100644 --- a/python/ovs/db/schema.py +++ b/python/ovs/db/schema.py @@ -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 diff --git a/python/ovs/jsonrpc.py b/python/ovs/jsonrpc.py index 2e3c2e06..906e93c6 100644 --- a/python/ovs/jsonrpc.py +++ b/python/ovs/jsonrpc.py @@ -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): diff --git a/python/ovs/process.py b/python/ovs/process.py index 7367f793..f8182f19 100644 --- a/python/ovs/process.py +++ b/python/ovs/process.py @@ -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) diff --git a/python/ovs/reconnect.py b/python/ovs/reconnect.py index 5fc96bc8..757e7304 100644 --- a/python/ovs/reconnect.py +++ b/python/ovs/reconnect.py @@ -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