
    z	i%                     t    S SK r SSKJr  SSKJr  \ R
                  " \5      r " S S\5      r " S S\5      r	g)	    N   )EnabledExtensionManager)	NoMatchesc                   $    \ rS rSrSrS rS rSrg)DispatchExtensionManager   a  Loads all plugins and filters on execution.

This is useful for long-running processes that need to pass
different inputs to different extensions.

:param namespace: The namespace for the entry points.
:type namespace: str
:param check_func: Function to determine which extensions to load.
:type check_func: callable
:param invoke_on_load: Boolean controlling whether to invoke the
    object returned by the entry point after the driver is loaded.
:type invoke_on_load: bool
:param invoke_args: Positional arguments to pass when invoking
    the object returned by the entry point. Only used if invoke_on_load
    is True.
:type invoke_args: tuple
:param invoke_kwds: Named arguments to pass when invoking
    the object returned by the entry point. Only used if invoke_on_load
    is True.
:type invoke_kwds: dict
:param propagate_map_exceptions: Boolean controlling whether exceptions
    are propagated up through the map call or whether they are logged and
    then ignored
:type invoke_on_load: bool
c                     U R                   (       d  [        SU R                  -  5      e/ nU R                    H3  nU" U/UQ70 UD6(       d  M  U R                  UR                  X&X45        M5     U$ )a  Iterate over the extensions invoking func() for any where
filter_func() returns True.

The signature of filter_func() should be::

    def filter_func(ext, *args, **kwds):
        pass

The first argument to filter_func(), 'ext', is the
:class:`~stevedore.extension.Extension`
instance. filter_func() should return True if the extension
should be invoked for the input arguments.

The signature for func() should be::

    def func(ext, *args, **kwds):
        pass

The first argument to func(), 'ext', is the
:class:`~stevedore.extension.Extension` instance.

Exceptions raised from within func() are propagated up and
processing stopped if self.propagate_map_exceptions is True,
otherwise they are logged and ignored.

:param filter_func: Callable to test each extension.
:param func: Callable to invoke for each extension.
:param args: Variable arguments to pass to func()
:param kwds: Keyword arguments to pass to func()
:returns: List of values returned from func()
zNo %s extensions found)
extensionsr   	namespace_invoke_one_pluginappend)selffilter_funcfuncargskwdsresponsees          L/home/james-whalen/.local/lib/python3.13/site-packages/stevedore/dispatch.pymapDispatchExtensionManager.map0   sf    @ 4t~~EFFA1,t,t,,''$M !     c                 D    U R                   " XR                  U/UQ70 UD6$ )a  Iterate over the extensions invoking each one's object method called
`method_name` for any where filter_func() returns True.

This is equivalent of using :meth:`map` with func set to
`lambda x: x.obj.method_name()`
while being more convenient.

Exceptions raised from within the called method are propagated up
and processing stopped if self.propagate_map_exceptions is True,
otherwise they are logged and ignored.

.. versionadded:: 0.12

:param filter_func: Callable to test each extension.
:param method_name: The extension method name to call
                    for each extension.
:param args: Variable arguments to pass to method
:param kwds: Keyword arguments to pass to method
:returns: List of values returned from methods
r   _call_extension_method)r   r   method_namer   r   s        r   
map_method#DispatchExtensionManager.map_methodY   s0    * xx%@%@#4&*4.24 	4r    N)__name__
__module____qualname____firstlineno____doc__r   r   __static_attributes__r   r   r   r   r      s    4'R4r   r   c                   T   ^  \ rS rSrSrSS0 SSS4U 4S jjrU 4S jrS rS	 rS
r	U =r
$ )NameDispatchExtensionManagerr   a  Loads all plugins and filters on execution.

This is useful for long-running processes that need to pass
different inputs to different extensions and can predict the name
of the extensions before calling them.

The check_func argument should return a boolean, with ``True``
indicating that the extension should be loaded and made available
and ``False`` indicating that the extension should be ignored.

:param namespace: The namespace for the entry points.
:type namespace: str
:param check_func: Function to determine which extensions to load.
:type check_func: callable
:param invoke_on_load: Boolean controlling whether to invoke the
    object returned by the entry point after the driver is loaded.
:type invoke_on_load: bool
:param invoke_args: Positional arguments to pass when invoking
    the object returned by the entry point. Only used if invoke_on_load
    is True.
:type invoke_args: tuple
:param invoke_kwds: Named arguments to pass when invoking
    the object returned by the entry point. Only used if invoke_on_load
    is True.
:type invoke_kwds: dict
:param propagate_map_exceptions: Boolean controlling whether exceptions
    are propagated up through the map call or whether they are logged and
    then ignored
:type invoke_on_load: bool
:param on_load_failure_callback: Callback function that will be called when
    an entrypoint can not be loaded. The arguments that will be provided
    when this is called (when an entrypoint fails to load) are
    (manager, entrypoint, exception)
:type on_load_failure_callback: function
:param verify_requirements: Use setuptools to enforce the
    dependencies of the plugin(s) being loaded. Defaults to False.
:type verify_requirements: bool

Fr   Nc	                 .   > [         T	U ]  UUUUUUUUS9  g )N)r   
check_funcinvoke_on_loadinvoke_argsinvoke_kwdspropagate_map_exceptionson_load_failure_callbackverify_requirements)super__init__)
r   r   r*   r+   r,   r-   r.   r/   r0   	__class__s
            r   r2   %NameDispatchExtensionManager.__init__   s/    
 	!)##%=%= 3 	 		
r   c                    > [         TU ]  U5        U R                   Vs0 s H  o"R                  U_M     snU l        g s  snf )N)r1   _init_pluginsr
   nameby_name)r   r
   r   r3   s      r   r6   *NameDispatchExtensionManager._init_plugins   s3    j)+/??;?a	?;;s   >c                     / nU H0  n U R                   U   nU R                  UR                  X'X45        M2     U$ ! [         a    [        R                  SU5         MY  f = f)a  Iterate over the extensions invoking func() for any where
the name is in the given list of names.

The signature for func() should be::

    def func(ext, *args, **kwds):
        pass

The first argument to func(), 'ext', is the
:class:`~stevedore.extension.Extension` instance.

Exceptions raised from within func() are propagated up and
processing stopped if self.propagate_map_exceptions is True,
otherwise they are logged and ignored.

:param names: List or set of name(s) of extension(s) to invoke.
:param func: Callable to invoke for each extension.
:param args: Variable arguments to pass to func()
:param kwds: Keyword arguments to pass to func()
:returns: List of values returned from func()
z"Missing extension %r being ignored)r8   r   r   KeyErrorLOGdebug)r   namesr   r   r   r   r7   r   s           r   r    NameDispatchExtensionManager.map   sh    , DNLL& ''$M  	  F		>EFs   ; AAc                 D    U R                   " XR                  U/UQ70 UD6$ )a  Iterate over the extensions invoking each one's object method called
`method_name` for any where the name is in the given list of names.

This is equivalent of using :meth:`map` with func set to
`lambda x: x.obj.method_name()`
while being more convenient.

Exceptions raised from within the called method are propagated up
and processing stopped if self.propagate_map_exceptions is True,
otherwise they are logged and ignored.

.. versionadded:: 0.12

:param names: List or set of name(s) of extension(s) to invoke.
:param method_name: The extension method name
                    to call for each extension.
:param args: Variable arguments to pass to method
:param kwds: Keyword arguments to pass to method
:returns: List of values returned from methods
r   )r   r>   r   r   r   s        r   r   'NameDispatchExtensionManager.map_method   s0    * xx::#4&*4.24 	4r   )r8   )r    r!   r"   r#   r$   r2   r6   r   r   r%   __classcell__)r3   s   @r   r'   r'   r   s7    &P >CR*/*.%*	
 <@4 4r   r'   )
loggingenabledr   	exceptionr   	getLoggerr    r<   r   r'   r   r   r   <module>rG      s?     ,  !Z46 Z4zs4#; s4r   