Return the callback. If the callback is a decorated function, try to recover the original function.
(self)
| 559 | return callback |
| 560 | |
| 561 | def get_undecorated_callback(self): |
| 562 | """ Return the callback. If the callback is a decorated function, try to |
| 563 | recover the original function. """ |
| 564 | func = self.callback |
| 565 | func = getattr(func, '__func__' if py3k else 'im_func', func) |
| 566 | closure_attr = '__closure__' if py3k else 'func_closure' |
| 567 | while hasattr(func, closure_attr) and getattr(func, closure_attr): |
| 568 | attributes = getattr(func, closure_attr) |
| 569 | func = attributes[0].cell_contents |
| 570 | |
| 571 | # in case of decorators with multiple arguments |
| 572 | if not isinstance(func, FunctionType): |
| 573 | # pick first FunctionType instance from multiple arguments |
| 574 | func = filter(lambda x: isinstance(x, FunctionType), |
| 575 | map(lambda x: x.cell_contents, attributes)) |
| 576 | func = list(func)[0] # py3 support |
| 577 | return func |
| 578 | |
| 579 | def get_callback_args(self): |
| 580 | """ Return a list of argument names the callback (most likely) accepts |
no outgoing calls
no test coverage detected