def ovrprototype(*outer_args,**outer_kwargs):
""" Verify that a method is called with a valid data type value.
The datatype of a parameter must be a list of type defined
in package types.
"""
def decorator(fn):
def decorated(*args,**kwargs):
#do_something(*outer_args,**outer_kwargs)
if len(outer_args)!=len(args):
sys.excepthook = __exceptionHandler__
raise Exception("Invalid Number of "
"arguments in function call")
for [typ, var] in zip(outer_args, args):
matched = False
for i_typ in typ:
if ( isinstance(var, i_typ)):
matched = True
break
if matched == False:
sys.excepthook = __exceptionHandler__
raise Exception("Invalid Type")
return fn(*args,**kwargs)
return decorated
return decorator
评论列表
文章目录