X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=PLC%2FParameter.py;h=1144ec8f198d617704f1dc8c844ee30192a9e2fb;hb=ae8b10f8363f7a1df02e77cbd820904c4ded10b8;hp=230748362f485bce551a7385099b361571fc7dbe;hpb=d3caf68dfe082cd1f623550ee78b259ad3b019f0;p=plcapi.git diff --git a/PLC/Parameter.py b/PLC/Parameter.py index 2307483..1144ec8 100644 --- a/PLC/Parameter.py +++ b/PLC/Parameter.py @@ -4,10 +4,7 @@ # Mark Huang # Copyright (C) 2006 The Trustees of Princeton University # -# $Id: Parameter.py,v 1.6 2006/11/08 22:10:00 mlhuang Exp $ -# -from types import * from PLC.Faults import * class Parameter: @@ -17,14 +14,14 @@ class Parameter: sub-parameters (i.e., dict fields). """ - def __init__(self, type, doc = "", - min = None, max = None, - optional = None, - ro = False, - nullok = False): + def __init__(self, typeval, doc="", + min=None, max=None, + optional=None, + ro=False, + nullok=False): # Basic type of the parameter. Must be a builtin type # that can be marshalled by XML-RPC. - self.type = type + self.type = typeval # Documentation string for the parameter self.doc = doc @@ -60,7 +57,6 @@ class Mixed(tuple): def __new__(cls, *types): return tuple.__new__(cls, types) - def python_type(arg): """ Returns the Python type of the specified argument, which may be a @@ -83,23 +79,23 @@ def xmlrpc_type(arg): arg_type = python_type(arg) - if arg_type == NoneType: + if arg_type is type(None): return "nil" - elif arg_type == IntType or arg_type == LongType: + elif arg_type is int: return "int" - elif arg_type == bool: + elif arg_type is bool: return "boolean" - elif arg_type == FloatType: + elif arg_type is float: return "double" - elif arg_type in StringTypes: + elif arg_type is str: return "string" - elif arg_type == ListType or arg_type == TupleType: + elif arg_type in (list, tuple): return "array" - elif arg_type == DictType: + elif arg_type is dict: return "struct" elif arg_type == Mixed: # Not really an XML-RPC type but return "mixed" for # documentation purposes. return "mixed" else: - raise PLCAPIError, "XML-RPC cannot marshal %s objects" % arg_type + raise PLCAPIError("XML-RPC cannot marshal %s objects" % arg_type)