1
Fork 0
mirror of https://github.com/Steffo99/async-chain.git synced 2024-11-22 04:54:21 +00:00
async-chain/async_chain/decorators.py

21 lines
454 B
Python
Raw Normal View History

2021-06-13 18:42:02 +00:00
import functools
from .chain import ChainStart
class FunctionWrapper:
def __init__(self, func):
self._func = func
def __repr__(self):
return self._func.__name__
def __call__(self, *args, **kwargs):
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