| 111 | |
| 112 | @curry |
| 113 | def wrap(wrap_func, func, func_like=None, **kwargs): |
| 114 | if func_like is None: |
| 115 | f = partial(wrap_func, func, **kwargs) |
| 116 | else: |
| 117 | f = partial(wrap_func, func_like, **kwargs) |
| 118 | template = """ |
| 119 | Blocked variant of %(name)s |
| 120 | |
| 121 | Follows the signature of %(name)s exactly except that it also features |
| 122 | optional keyword arguments ``chunks: int, tuple, or dict`` and ``name: str``. |
| 123 | |
| 124 | Original signature follows below. |
| 125 | """ |
| 126 | if func.__doc__ is not None: |
| 127 | f.__doc__ = template % {"name": func.__name__} + func.__doc__ |
| 128 | f.__name__ = "blocked_" + func.__name__ |
| 129 | return f |
| 130 | |
| 131 | |
| 132 | w = wrap(wrap_func_shape_as_first_arg) |