plugins.py 文件源码

python
阅读 31 收藏 0 点赞 0 评论 0

项目:server 作者: happypandax 项目源码 文件源码
def _add_capture_handler(self, handler, node=None):
        assert callable(handler)
        assert node is None or isinstance(PluginNode)

        capture_dict = self._capture_handlers
        if not node:
            capture_dict = self.default_capture_handlers

        sig = inspect.signature(handler)

        if 'capture' in sig.parameters:
            cap = sig.parameters['capture'].default

            if not cap == inspect._empty:

                if not isinstance(cap, (list, tuple)):
                    cap = (cap,)

                for c in cap:
                    if c not in capture_dict:
                        capture_dict[c] = []

                    if node:
                        capture_dict[c].append((node, handler))
                    else:
                        capture_dict[c].append(handler)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号