mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 01:18:58 +00:00
The wrapped function now uses the same name as the original.
This commit is contained in:
parent
4855c9427c
commit
1f83aa6743
@ -137,11 +137,18 @@ def identical_signature_wrapper(original_function, wrapped_function):
|
|||||||
Return a function with identical signature as ``original_function``'s which
|
Return a function with identical signature as ``original_function``'s which
|
||||||
will call the ``wrapped_function``.
|
will call the ``wrapped_function``.
|
||||||
'''
|
'''
|
||||||
function_def = 'lambda {0}: __wrapped__({0})'.format(
|
context = {'__wrapped__': wrapped_function}
|
||||||
inspect.formatargspec(
|
function_def = compile(
|
||||||
formatvalue=lambda val: '',
|
'def {0}({1}):\n'
|
||||||
*inspect.getargspec(original_function)
|
' return __wrapped__({1})'.format(
|
||||||
)[1:-1]
|
original_function.__name__,
|
||||||
|
inspect.formatargspec(
|
||||||
|
formatvalue=lambda val: '',
|
||||||
|
*inspect.getargspec(original_function)
|
||||||
|
)[1:-1]
|
||||||
|
),
|
||||||
|
'<string>',
|
||||||
|
'exec'
|
||||||
)
|
)
|
||||||
fake_function = eval(function_def, {'__wrapped__': wrapped_function})
|
exec function_def in context
|
||||||
return wraps(original_function)(fake_function)
|
return wraps(original_function)(context[original_function.__name__])
|
||||||
|
Loading…
Reference in New Issue
Block a user