| 31 | | |
| | 31 | |
| | 32 | def deco_connect(self, *args, **kwargs): |
| | 33 | """Decorate a receiver, connecting it to sender for signal.""" |
| | 34 | # ``deco_connect`` is being called with a function. |
| | 35 | if args: |
| | 36 | self.connect(*args, **kwargs) |
| | 37 | # Return the receiver, if being used for decoration. |
| | 38 | return args[0] |
| | 39 | # Create a wrapper which closes over the given kwargs, a sort-of |
| | 40 | # implementation of currying. |
| | 41 | def connection_wrapper(receiver): |
| | 42 | self.connect(receiver, **kwargs) |
| | 43 | return receiver |
| | 44 | # Return this wrapper so that it can be used to decorate a function. |
| | 45 | return connection_wrapper |
| | 46 | |