X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=sfa%2Futil%2Fmethod.py;h=7329036e400a55b03c3ff5f777eebc9124c19c80;hb=130e896408741add08ebc3a1b6c74aca11023c1e;hp=44c368a08438f1e2ef7b3c8c06cdc0958b006d6a;hpb=04a3f20dc71bf8b3f96b1e3172623aa346a638a7;p=sfa.git diff --git a/sfa/util/method.py b/sfa/util/method.py index 44c368a0..7329036e 100644 --- a/sfa/util/method.py +++ b/sfa/util/method.py @@ -4,11 +4,9 @@ # import time -from types import IntType, LongType import textwrap from sfa.util.sfalogging import logger -from sfa.util.py23 import StringType from sfa.util.faults import SfaFault, SfaInvalidAPIMethod, SfaInvalidArgumentCount, SfaInvalidArgument from sfa.storage.parameter import Parameter, Mixed, python_type, xmlrpc_type @@ -143,7 +141,7 @@ class Method: # Indent struct fields and mixed types if isinstance(param, dict): - for name, subparam in param.iteritems(): + for name, subparam in param.items(): text += param_text(name, subparam, indent + step, step) elif isinstance(param, Mixed): for subparam in param: @@ -176,9 +174,9 @@ class Method: """ # Inspect call. Remove self from the argument list. - max_args = self.call.func_code.co_varnames[ - 1:self.call.func_code.co_argcount] - defaults = self.call.func_defaults + max_args = self.call.__code__.co_varnames[ + 1:self.call.__code__.co_argcount] + defaults = self.call.__defaults__ if defaults is None: defaults = () @@ -239,12 +237,12 @@ class Method: # Strings are a special case. Accept either unicode or str # types if a string is expected. - if issubclass(expected_type, StringType) and isinstance(value, StringType): + if issubclass(expected_type, str) and isinstance(value, str): pass # Integers and long integers are also special types. Accept # either int or long types if an int or long is expected. - elif expected_type in (IntType, LongType) and isinstance(value, (IntType, LongType)): + elif expected_type is int and isinstance(value, int): pass elif not isinstance(value, expected_type): @@ -254,7 +252,7 @@ class Method: name) # If a minimum or maximum (length, value) has been specified - if issubclass(expected_type, StringType): + if issubclass(expected_type, str): if min is not None and \ len(value.encode(self.api.encoding)) < min: raise SfaInvalidArgument( @@ -288,14 +286,14 @@ class Method: # If a struct with particular (or required) types of items is # expected. elif isinstance(expected, dict): - for key in value.keys(): + for key in list(value.keys()): if key in expected: self.type_check(name + "['%s']" % key, value[key], expected[key], args) - for key, subparam in expected.iteritems(): + for key, subparam in expected.items(): if isinstance(subparam, Parameter) and \ subparam.optional is not None and \ - not subparam.optional and key not in value.keys(): + not subparam.optional and key not in list(value.keys()): raise SfaInvalidArgument("'%s' not specified" % key, name) # if auth is not None: