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:
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)
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):
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)
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>"
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
-# 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.
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
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):
-# 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.
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)
-# 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.
% 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