def get_decorators(function):
# If we have no func_closure, it means we are not wrapping any other functions.
decorators = []
try:
func_closure = six.get_function_closure(function)
except AttributeError:
return decorators
if not func_closure:
return [function]
# Otherwise, we want to collect all of the recursive results for every closure we have.
for closure in func_closure:
if isinstance(closure.cell_contents, types.FunctionType):
decorators.extend(get_decorators(closure.cell_contents))
return [function] + decorators
评论列表
文章目录