How to use the injectable.common_utils.get_caller_filepath function in injectable

To help you get started, we’ve selected a few injectable examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github allrod5 / injectable / injectable / injection / injectable_decorator.py View on Github external
def decorator(klass: T, direct_call: bool = False) -> T:
        steps_back = 3 if direct_call else 2
        caller_filepath = get_caller_filepath(steps_back)
        if caller_filepath == InjectionContainer.LOADING_FILEPATH:
            InjectionContainer._register_injectable(
                klass, caller_filepath, qualifier, primary, namespace, group, singleton
            )
        return klass
github allrod5 / injectable / injectable / injection / injectable_factory_decorator.py View on Github external
def decorator(fn: Callable[..., T]) -> Callable[..., T]:
        caller_filepath = get_caller_filepath()
        if caller_filepath == InjectionContainer.LOADING_FILEPATH:
            InjectionContainer._register_factory(
                fn,
                caller_filepath,
                dependency,
                qualifier,
                primary,
                namespace,
                group,
                singleton,
            )
        return fn
github allrod5 / injectable / injectable / container / injection_container.py View on Github external
This method will be removed from the public API in the future. Use
            :func:`load_injection_container` instead.
        """
        warnings.warn(
            "Using 'load' directly from the 'InjectionContainer' is deprecated."
            " Use 'load_injection_container' instead. This class will be removed from"
            " the injectable's public API in the future.",
            DeprecationWarning,
            2,
        )
        cls.LOADING_DEFAULT_NAMESPACE = default_namespace or DEFAULT_NAMESPACE
        cls.NAMESPACES[default_namespace] = Namespace()
        if search_path is None:
            search_path = os.path.dirname(get_caller_filepath())
        elif not os.path.isabs(search_path):
            caller_path = os.path.dirname(get_caller_filepath())
            search_path = os.path.normpath(os.path.join(caller_path, search_path))
        cls._link_dependencies(search_path)
        cls.LOADING_DEFAULT_NAMESPACE = None