2021-06-13 18:42:02 +00:00
|
|
|
import functools
|
2021-06-14 02:39:43 +00:00
|
|
|
import typing as t
|
2021-06-13 18:42:02 +00:00
|
|
|
from .chain import ChainStart
|
|
|
|
|
|
|
|
|
|
|
|
class FunctionWrapper:
|
|
|
|
def __init__(self, func):
|
|
|
|
self._func = func
|
|
|
|
|
2021-06-14 02:39:43 +00:00
|
|
|
def __repr__(self) -> str:
|
2021-06-13 18:42:02 +00:00
|
|
|
return self._func.__name__
|
|
|
|
|
2021-06-14 02:39:43 +00:00
|
|
|
def __call__(self, *args, **kwargs) -> t.Any:
|
2021-06-13 18:42:02 +00:00
|
|
|
return self._func(*args, **kwargs)
|
|
|
|
|
|
|
|
|
|
|
|
def method_deco(func):
|
|
|
|
@functools.wraps(func)
|
|
|
|
def decorated(*args, **kwargs):
|
|
|
|
return ChainStart(start=FunctionWrapper(func))(*args, **kwargs)
|
|
|
|
return decorated
|