def make_wrapper(func, how): @functools.wraps(func) def wrapper(self, *args, **kwargs): results = object.__getattribute__(self, '_results') data = results.model.data if how and isinstance(how, tuple): obj = data.wrap_output(func(results, *args, **kwargs), how[0], how[1:]) elif how: obj = data.wrap_output(func(results, *args, **kwargs), how) return obj try: # Python 3.3+ sig = inspect.signature(func) formatted = str(sig) except AttributeError: # TODO: Remove when Python 2.7 is dropped argspec = getargspec(func) formatted = inspect.formatargspec(argspec[0], varargs=argspec[1], defaults=argspec[3]) wrapper.__doc__ = "%s%s\n%s" % (func.__name__, formatted, wrapper.__doc__) return wrapper
def make_wrapper(func, how): @functools.wraps(func) def wrapper(self, *args, **kwargs): results = object.__getattribute__(self, '_results') data = results.model.data if how and isinstance(how, tuple): obj = data.wrap_output(func(results, *args, **kwargs), how[0], how[1:]) elif how: obj = data.wrap_output(func(results, *args, **kwargs), how) return obj argspec = getargspec(func) formatted = inspect.formatargspec(argspec[0], varargs=argspec[1], defaults=argspec[3]) func_name = get_function_name(func) wrapper.__doc__ = "%s%s\n%s" % (func_name, formatted, wrapper.__doc__) return wrapper