首页 > 代码库 > 测试一下代码

测试一下代码

def filter_hook(func):
tag = func.__name__
func.__doc__ = "``filter_hook``\n\n" + (func.__doc__ or "")

@functools.wraps(func)
def method(self, *args, **kwargs):

def _inner_method():
return func(self, *args, **kwargs)

if self.plugins:
filters = [(getattr(getattr(p, tag), ‘priority‘, 10), getattr(p, tag))
for p in self.plugins if callable(getattr(p, tag, None))]
filters = [f for p, f in sorted(filters, key=lambda x:x[0])]
return filter_chain(filters, len(filters) - 1, _inner_method, *args, **kwargs)
else:
return _inner_method()
return method

测试一下代码