How to use the injectable.container.injection_container.InjectionContainer.NAMESPACES 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 / injection_utils.py View on Github external
def get_namespace_injectables(
    dependency_name: str, registry_type: RegistryType, namespace: str
) -> Set[Injectable]:
    if len(InjectionContainer.NAMESPACES) == 0:
        logging.warning(
            "Injection Container is empty. Make sure 'load_injection_container'"
            " is being called before any injections are made."
        )
    injection_namespace = InjectionContainer.NAMESPACES.get(namespace)
    if not injection_namespace:
        return set()
    registry = (
        injection_namespace.class_registry
        if registry_type is RegistryType.CLASS
        else injection_namespace.qualifier_registry
    )
    injectables = registry.get(dependency_name)
    return injectables
github allrod5 / injectable / injectable / injection / utils.py View on Github external
def get_namespace_injectables(
    dependency: Injectable, namespace: str
) -> Tuple[Set[Injectable], str, str]:
    if len(InjectionContainer.NAMESPACES) == 0:
        raise InjectionContainerNotLoadedError(
            "InjectionContainer::load was not invoked"
        )
    injection_namespace = InjectionContainer.NAMESPACES[
        namespace or InjectionContainer.DEFAULT_NAMESPACE
    ]
    if isinstance(dependency, str):
        registry = injection_namespace.qualifier_registry
        lookup_key = dependency
        lookup_type = "qualifier"
    else:
        registry = injection_namespace.class_registry
        lookup_key = dependency.__qualname__
        lookup_type = "class"

    injectables = registry.get(lookup_key)
github allrod5 / injectable / injectable / injection / utils.py View on Github external
def get_namespace_injectables(
    dependency: Injectable, namespace: str
) -> Tuple[Set[Injectable], str, str]:
    if len(InjectionContainer.NAMESPACES) == 0:
        raise InjectionContainerNotLoadedError(
            "InjectionContainer::load was not invoked"
        )
    injection_namespace = InjectionContainer.NAMESPACES[
        namespace or InjectionContainer.DEFAULT_NAMESPACE
    ]
    if isinstance(dependency, str):
        registry = injection_namespace.qualifier_registry
        lookup_key = dependency
        lookup_type = "qualifier"
    else:
        registry = injection_namespace.class_registry
        lookup_key = dependency.__qualname__
        lookup_type = "class"

    injectables = registry.get(lookup_key)
    return injectables, lookup_key, lookup_type