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)
评论列表
文章目录