def adapt_call(func):
    """Adapt called func.

    Adapt called funcfrom taking n params to only taking 1 or 2 params
    """
    cached = [None]

    def func1(arg1, *_):
        return func(arg1)

    def func2(arg1, arg2=None, *_):
        return func(arg1, arg2)

    def func_wrapped(*args, **kw):
        if cached[0]:
            return cached[0](*args, **kw)

        for fn in (func1, func2):
            try:
                ret = fn(*args, **kw)
            except __HOLE__:
                continue
            else:
                cached[0] = fn
            return ret

        # Error if we get here. Just call original function to generate a
        # meaningful error message
        return func(*args, **kw)
    return func_wrapped
dataset/ETHPy150Open ReactiveX/RxPY/rx/internal/utils.py/adapt_call