# Path: turbo/util.py
# def get_func_name(func):
#     name = getattr(func, 'func_name', None)
#     if not name:
#         name = getattr(func, '__name__', None)
#     return name


import os
import functools
import inspect
import weakref
from turbo.util import get_func_name


class CallFuncAsAttr(object):

    class __CallObject(object):

        def __init__(self, func):
            self.func = func

        def __call__(self, *args, **kwargs):
            return self.func(*args, **kwargs)

    def __init__(self, file_attr):
        name = file_attr
        filepath = os.path.abspath(file_attr)
        if os.path.isfile(filepath):
            name, ext = os.path.splitext(os.path.basename(filepath))

        setattr(self, self._name, {})
        _mutation[name] = weakref.ref(self)

    @property
    def __get_func(self):
        return getattr(self, self._name)

    def register(self, func):
        if not inspect.isfunction(func):
            raise TypeError("argument expect function, now is '%s'" % func)

        name = get_func_name(func)

# Path: turbo/util.py
# def get_func_name(func):
#     name = getattr(func, 'func_name', None)
#     if not name:
#         name = getattr(func, '__name__', None)
#     return name


# Path: turbo/flux.py
import os
import functools
import inspect
import weakref
from turbo.util import get_func_name



class CallFuncAsAttr(object):

    class __CallObject(object):

        def __init__(self, func):
            self.func = func

        def __call__(self, *args, **kwargs):
            return self.func(*args, **kwargs)

    def __init__(self, file_attr):
        name = file_attr
        filepath = os.path.abspath(file_attr)
        if os.path.isfile(filepath):
            name, ext = os.path.splitext(os.path.basename(filepath))

        setattr(self, self._name, {})
        _mutation[name] = weakref.ref(self)

    @property
    def __get_func(self):
        return getattr(self, self._name)

    def register(self, func):
        if not inspect.isfunction(func):
            raise TypeError("argument expect function, now is '%s'" % func)

        name = get_func_name(func)

        lambda_name = get_func_name(lambda x: x)