
    F-Phb                       d Z ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlZddl	Z	ddl
mZ dd	lmZ dd
lmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlZddlmZ  ed          Z ededef                   Zeeef         ZeZee ed         ee ef         e!geee"e         f         f         Z#edeeedee         df         f         f         Z$ G d de          Z% G d de          Z&e G d d                      Z'e G d  d!                      Z(d4d%Z) e*e	d&          Z+d5d*Z,e G d+ d,                      Z-e-Z.e"e/ee ef         eeegdf                  f                  Z0 G d- d.          Z1e1Z2 G d/ d0e1          Z3e G d1 d                      Z4e G d2 d3                      Z5dS )6zA
Internal hook annotation, representation and calling machinery.
    )annotations)	Generator)Mapping)Sequence)SetN)
ModuleType)Any)Callable)Final)final)Optional)overload)TYPE_CHECKING)	TypedDict)TypeVar)Union   )Result_T_F.)boundHookImplc                  <    e Zd ZU dZded<   ded<   ded<   ded<   d	S )
HookspecOptsz!Options for a hook specification.boolfirstresulthistoricWarning | Nonewarn_on_implMapping[str, Warning] | Nonewarn_on_impl_argsN__name__
__module____qualname____doc____annotations__     M/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/pluggy/_hooks.pyr   r   (   sI         ++ NNN    
 433333r)   r   c                  P    e Zd ZU dZded<   ded<   ded<   ded<   ded<   ded	<   d
S )HookimplOptsz"Options for a hook implementation.r   wrapperhookwrapperoptionalhooktryfirsttrylast
str | NonespecnameNr"   r(   r)   r*   r,   r,   8   sa         ,, MMM   NNN MMMr)   r,   c                  x    e Zd ZdZdZddZe	 	 	 	 ddd            Ze	 	 	 	 	 ddd            Z	 	 	 	 	 dd dZd	S )!HookspecMarkera  Decorator for marking functions as hook specifications.

    Instantiate it with a project_name to get a decorator.
    Calling :meth:`PluginManager.add_hookspecs` later will discover all marked
    functions if the :class:`PluginManager` uses the same project name.
    project_namer7   strreturnNonec                    || _         d S Nr6   selfr7   s     r*   __init__zHookspecMarker.__init__X       #/r)   FNfunctionr   r   r   r   r   r   r!   r    c                    d S r<   r(   r>   rA   r   r   r   r!   s         r*   __call__zHookspecMarker.__call__[   s	     Sr)   .Callable[[_F], _F]c                    d S r<   r(   rC   s         r*   rD   zHookspecMarker.__call__e   s	     !Sr)   	_F | None_F | Callable[[_F], _F]c                >     d fd}| ||          S |S )aw  If passed a function, directly sets attributes on the function
        which will make it discoverable to :meth:`PluginManager.add_hookspecs`.

        If passed no function, returns a decorator which can be applied to a
        function later using the attributes supplied.

        :param firstresult:
            If ``True``, the 1:N hook call (N being the number of registered
            hook implementation functions) will stop at I<=N when the I'th
            function returns a non-``None`` result. See :ref:`firstresult`.

        :param historic:
            If ``True``, every call to the hook will be memorized and replayed
            on plugins registered after the call was made. See :ref:`historic`.

        :param warn_on_impl:
            If given, every implementation of this hook will trigger the given
            warning. See :ref:`warn_on_impl`.

        :param warn_on_impl_args:
            If given, every implementation of this hook which requests one of
            the arguments in the dict will trigger the corresponding warning.
            See :ref:`warn_on_impl`.

            .. versionadded:: 1.5
        funcr   r9   c                n    rrt          d          d}t          | j        dz   |           | S )Nz'cannot have a historic firstresult hook)r   r   r   r!   _spec)
ValueErrorsetattrr7   )rJ   optsr   r   r>   r   r!   s     r*   setattr_hookspec_optsz6HookspecMarker.__call__.<locals>.setattr_hookspec_opts   s\     LK L !JKKK*$ ,%6	" "D D$+g5t<<<Kr)   NrJ   r   r9   r   r(   )r>   rA   r   r   r   r!   rP   s   ` ```` r*   rD   zHookspecMarker.__call__o   sY    F
	 
	 
	 
	 
	 
	 
	 
	 
	 
	 ((222((r)   r7   r8   r9   r:   )FFNN)rA   r   r   r   r   r   r   r   r!   r    r9   r   ).....)rA   r:   r   r   r   r   r   r   r!   r    r9   rE   )NFFNN)rA   rG   r   r   r   r   r   r   r!   r    r9   rH   r#   r$   r%   r&   	__slots__r?   r   rD   r(   r)   r*   r5   r5   M   s          "I0 0 0 0  "'+:>    X  '*:=! ! ! ! X! #!'+:>2) 2) 2) 2) 2) 2) 2)r)   r5   c                      e Zd ZdZdZddZe	 	 	 	 	 	 ddd            Ze	 	 	 	 	 	 	 ddd            Z	 	 	 	 	 	 	 d d!dZdS )"HookimplMarkera  Decorator for marking functions as hook implementations.

    Instantiate it with a ``project_name`` to get a decorator.
    Calling :meth:`PluginManager.register` later will discover all marked
    functions if the :class:`PluginManager` uses the same project name.
    r6   r7   r8   r9   r:   c                    || _         d S r<   r6   r=   s     r*   r?   zHookimplMarker.__init__   r@   r)   .rA   r   r.   r   r/   r0   r1   r3   r2   r-   c                    d S r<   r(   r>   rA   r.   r/   r0   r1   r3   r-   s           r*   rD   zHookimplMarker.__call__   s	     Sr)   rE   c                    d S r<   r(   rY   s           r*   rD   zHookimplMarker.__call__   s	     !Sr)   NFrG   rH   c                F     d fd}||S  ||          S )a
  If passed a function, directly sets attributes on the function
        which will make it discoverable to :meth:`PluginManager.register`.

        If passed no function, returns a decorator which can be applied to a
        function later using the attributes supplied.

        :param optionalhook:
            If ``True``, a missing matching hook specification will not result
            in an error (by default it is an error if no matching spec is
            found). See :ref:`optionalhook`.

        :param tryfirst:
            If ``True``, this hook implementation will run as early as possible
            in the chain of N hook implementations for a specification. See
            :ref:`callorder`.

        :param trylast:
            If ``True``, this hook implementation will run as late as possible
            in the chain of N hook implementations for a specification. See
            :ref:`callorder`.

        :param wrapper:
            If ``True`` ("new-style hook wrapper"), the hook implementation
            needs to execute exactly one ``yield``. The code before the
            ``yield`` is run early before any non-hook-wrapper function is run.
            The code after the ``yield`` is run after all non-hook-wrapper
            functions have run. The ``yield`` receives the result value of the
            inner calls, or raises the exception of inner calls (including
            earlier hook wrapper calls). The return value of the function
            becomes the return value of the hook, and a raised exception becomes
            the exception of the hook. See :ref:`hookwrapper`.

        :param hookwrapper:
            If ``True`` ("old-style hook wrapper"), the hook implementation
            needs to execute exactly one ``yield``. The code before the
            ``yield`` is run early before any non-hook-wrapper function is run.
            The code after the ``yield`` is run after all non-hook-wrapper
            function have run  The ``yield`` receives a :class:`Result` object
            representing the exception or result outcome of the inner calls
            (including earlier hook wrapper calls). This option is mutually
            exclusive with ``wrapper``. See :ref:`old_style_hookwrapper`.

        :param specname:
            If provided, the given name will be used instead of the function
            name when matching this hook implementation to a hook specification
            during registration. See :ref:`specname`.

        .. versionadded:: 1.2.0
            The ``wrapper`` parameter.
        rJ   r   r9   c                L    d}t          | j        dz   |           | S )N)r-   r.   r/   r0   r1   r3   _impl)rN   r7   )	rJ   rO   r.   r/   r>   r3   r0   r1   r-   s	     r*   setattr_hookimpl_optsz6HookimplMarker.__call__.<locals>.setattr_hookimpl_opts  sB    "* ,$"$" "D D$+g5t<<<Kr)   NrQ   r(   )	r>   rA   r.   r/   r0   r1   r3   r-   r^   s	   ` `````` r*   rD   zHookimplMarker.__call__   se    z
	 
	 
	 
	 
	 
	 
	 
	 
	 
	 
	 
	 ((((222r)   rR   )......)rA   r   r.   r   r/   r   r0   r   r1   r   r3   r2   r-   r   r9   r   ).......)rA   r:   r.   r   r/   r   r0   r   r1   r   r3   r2   r-   r   r9   rE   )NFFFFNF)rA   rG   r.   r   r/   r   r0   r   r1   r   r3   r2   r-   r   r9   rH   rS   r(   r)   r*   rV   rV      s          "I0 0 0 0    "	 	 	 	 X	   "	! 	! 	! 	! X	! #!"#L3 L3 L3 L3 L3 L3 L3r)   rV   rO   r9   r:   c                   |                      dd           |                      dd           |                      dd           |                      dd           |                      dd           |                      dd            d S )Nr0   Fr1   r-   r.   r/   r3   )
setdefault)rO   s    r*   normalize_hookimpl_optsra     s    OOJ&&&OOIu%%%OOIu%%%OOM5)))OONE***OOJ%%%%%r)   pypy_version_inforJ   object'tuple[tuple[str, ...], tuple[str, ...]]c                d  	 t          j        |           r	 | j        } nI# t          $ r Y dS w xY wt          j        |           s$	 t          | d|           } n# t          $ r Y dS w xY w	 t          j        t          j        |           r| j	        n|           }n# t          $ r Y dS w xY wt           j        j        t           j        j        f		fd|j                                        D             }t!          |          }t!          d |                                D                       pd}|r2t%          |           }|d|         t!          ||d                   }}nd}t&          sd}nd}|r=t          | d	d
          }t          j        |           sd|v r|d         |v r
|dd         }||fS )zReturn tuple of positional and keywrord argument names for a function,
    method, class or callable.

    In case of a class, its ``__init__`` method is considered.
    For methods the ``self`` parameter is not included.
    )r(   r(   rD   c                .    i | ]\  }}|j         v ||S r(   )kind).0nameparam_valid_param_kindss      r*   
<dictcomp>zvarnames.<locals>.<dictcomp>C  s7       D%:+++ 	e+++r)   c              3  @   K   | ]}|j         |j        u|j         V  d S r<   )defaultempty)rh   rj   s     r*   	<genexpr>zvarnames.<locals>.<genexpr>J  s?       
 
}EK// M////
 
r)   Nr(   r>   )r>   objr%    .r   r   )inspectisclassr?   AttributeError	isroutinegetattr	Exception	signatureismethod__func__	TypeError	ParameterPOSITIONAL_ONLYPOSITIONAL_OR_KEYWORD
parametersitemstuplevalueslen_PYPY)
rJ   sig_valid_paramsargsdefaultsindexkwargsimplicit_namesqualnamerk   s
            @r*   varnamesr   %  s=    t 		=DD 	 	 	66	t$$ 	4T22DD 	 	 	66	$-d33=DMM
 
    vv 	)/   >//11  M
 D 
 
&--//
 
 
 	
 	
 	
    XFUF|U4<%8%8f  )*3( nb99D!! 	cXoo$q'^:S:S8D<s0    
--A 
A%$A%)/B 
B'&B'c                  .    e Zd ZdZdZddZerdd	Zd
S d
S )	HookRelayzaHook holder object for performing 1:N hook calls where N is the number
    of registered plugins.)__dict__r9   r:   c                    dS :meta private:Nr(   rq   s    r*   r?   zHookRelay.__init__m        r)   ri   r8   
HookCallerc                    d S r<   r(   )r>   ri   s     r*   __getattr__zHookRelay.__getattr__r  r   r)   N)r9   r:   )ri   r8   r9   r   )r#   r$   r%   r&   rT   r?   r   r   r(   r)   r*   r   r   f  sU          I     <;;;;;;< <r)   r   c                      e Zd ZdZdZ	 	 d-d.dZd/dZd0dZd/dZd1dZ	d2dZ
d3dZd4dZd5d Zd6d#Z	 	 d-d7d'Zd8d*Zd9d,ZdS ):r   zCA caller of all registered implementations of a hook specification.)ri   spec	_hookexec
_hookimpls_call_historyNri   r8   hook_execute	_HookExecspecmodule_or_class_Namespace | None	spec_optsHookspecOpts | Noner9   r:   c                    || _         || _        g | _        d| _        d| _        ||J |                     ||           dS dS r   )ri   r   r   r   r   set_specification)r>   ri   r   r   r   s        r*   r?   zHookCaller.__init__  sa      	 , 2426%)	*(((""#6	BBBBB +*r)   r   c                    | j         d uS r<   )r   rq   s    r*   has_speczHookCaller.has_spec  s    y$$r)   
_Namespacer   c                    | j         )t          d| j         j        d| j         j                   t	          || j        |          | _         |                    d          r	g | _        d S d S )NzHook z( is already registered within namespace r   )r   rM   ri   	namespaceHookSpecgetr   )r>   r   r   s      r*   r   zHookCaller.set_specification  s    
 9 :	 : :$(I$7: :   0$)YGG	==$$ 	$!#D	$ 	$r)   c                    | j         duS )z2Whether this caller is :ref:`historic <historic>`.N)r   rq   s    r*   is_historiczHookCaller.is_historic  s    !--r)   plugin_Pluginc                    t          | j                  D ]\  }}|j        |k    r| j        |=  d S t          d|d          )Nzplugin z
 not found)	enumerater   r   rM   )r>   r   imethods       r*   _remove_pluginzHookCaller._remove_plugin  s^    "4?33 	 	IAv}&&OA& ' 76777888r)   list[HookImpl]c                4    | j                                         S )z6Get all registered hook implementations for this hook.)r   copyrq   s    r*   get_hookimplszHookCaller.get_hookimpls  s    ##%%%r)   hookimplr   c                   t          | j                  D ]\  }}|j        s|j        r|} nt	          | j                  }|j        s|j        r|t	          | j                  }}nd|}}|j        r| j                            ||           dS |j        r| j                            ||           dS |dz
  }||k    r/| j        |         j        r|dz  }||k    r| j        |         j        | j                            |dz   |           dS )z,Add an implementation to the callback chain.r   r   N)r   r   r.   r-   r   r1   insertr0   )r>   r   r   r   
splitpointstartends          r*   _add_hookimplzHookCaller._add_hookimpl  s>   "4?33 	. 	.IAv! V^ 
 T_--J 	'8#3 	'#S%9%93EEJ3E 		4O""5(33333 	4O""311111 aAu**!3!<*Q u**!3!<*O""1q5(33333r)   c                    d| j         dS )Nz<HookCaller >ri   rq   s    r*   __repr__zHookCaller.__repr__  s    ,di,,,,r)   r   Mapping[str, object]c                    | j         r[| j         j        D ]P}|vrHd                    fd| j         j        D                       }t          j        d| dd            d S Od S d S )Nz, c              3  b   K   | ])}|                                 vt          |          V  *d S r<   )keysrepr)rh   argnamer   s     r*   rp   z;HookCaller._verify_all_args_are_provided.<locals>.<genexpr>  sL       * *# #&++--77	 W 8777* *r)   zArgument(s) zE which are declared in the hookspec cannot be found in this hook call   )
stacklevel)r   argnamesjoinwarningswarn)r>   r   r   	notincalls    `  r*   _verify_all_args_are_providedz(HookCaller._verify_all_args_are_provided  s    9 	9-  &(( $		 * * * *'+y'9* * * ! !I M<y < < <#$   
 EE )	 	 r)   rc   r	   c                "   |                                  r
J d            |                     |           | j        r | j        j                            dd          nd}|                     | j        | j                                        ||          S )zCall the hook.

        Only accepts keyword arguments, which should match the hook
        specification.

        Returns the result(s) of calling all registered plugins, see
        :ref:`calling`.
        ACannot directly call a historic hook - use call_historic instead.r   F)	r   r   r   rO   r   r   ri   r   r   )r>   r   r   s      r*   rD   zHookCaller.__call__  s     ##%% 	
 	
O	
 	
 	
 	**6222BF)Vdin((>>>QV~~di)=)=)?)?UUUr)   result_callbackCallable[[Any], None] | NoneMapping[str, object] | Nonec                @   | j         J |pi }|                     |           | j                             ||f           |                     | j        | j                                        |d          }|dS t          |t                    r|D ]} ||           dS dS )a<  Call the hook with given ``kwargs`` for all registered plugins and
        for all plugins which will be registered afterwards, see
        :ref:`historic`.

        :param result_callback:
            If provided, will be called for each non-``None`` result obtained
            from a hook implementation.
        NF)	r   r   appendr   ri   r   r   
isinstancelist)r>   r   r   resxs        r*   call_historiczHookCaller.call_historic  s     !---2**6222!!6?";<<< nnTY(<(<(>(>NN"Fc4   	# # #""""	# 	## #r)   methodsSequence[Callable[..., object]]c                z   |                                  r
J d            |                     |           ddddddd}| j                                        }|D ]}t	          dd||          }t          |          dz
  }|dk    rY||         j        s||         j        s||         j        r2|dz  }|dk    r'||         j        ||         j        %||         j        2|	                    |dz   |           | j
        r | j
        j                            dd          nd}|                     | j        |||          S )	zCall the hook with some additional temporarily participating
        methods using the specified ``kwargs`` as call parameters, see
        :ref:`call_extra`.r   FN)r-   r.   r/   r1   r0   r3   z<temp>r   r   r   )r   r   r   r   r   r   r.   r-   r0   r   r   rO   r   r   ri   )	r>   r   r   rO   	hookimplsr   r   r   r   s	            r*   
call_extrazHookCaller.call_extra  s    ##%% 	
 	
O	
 	
 	
 	**6222 !
 
 O((**	 	. 	.Fh==HI"Aq&&1) -6q\-A  Q<(	  Q q&&1) -6q\-A  Q<(	  QUH----BF)Vdin((>>>QV~~diFKHHHr)   r   c                    |                                  r`| j        J | j        D ]Q\  }}|                     | j        |g|d          }|r*|(t	          |t
                    sJ  ||d                    PdS dS )zAApply call history to a new hookimpl if it is marked as historic.NFr   )r   r   r   ri   r   r   )r>   r   r   r   r   s        r*   _maybe_apply_historyzHookCaller._maybe_apply_history?  s     	,%111+/+= , ,'nnTY&%HH ,?6%c400000#OCF+++	, 	,, ,r)   )NN)
ri   r8   r   r   r   r   r   r   r9   r:   )r9   r   )r   r   r   r   r9   r:   )r   r   r9   r:   r9   r   )r   r   r9   r:   r9   r8   )r   r   r9   r:   )r   rc   r9   r	   )r   r   r   r   r9   r:   )r   r   r   r   r9   r	   )r   r   r9   r:   )r#   r$   r%   r&   rT   r?   r   r   r   r   r   r   r   r   rD   r   r   r   r(   r)   r*   r   r   |  sM       MMI 26)-C C C C C6% % % %$ $ $ $. . . .9 9 9 9& & & &4 4 4 40- - - -   &V V V V& 9=.2# # # # #6 I  I  I  ID	, 	, 	, 	, 	, 	,r)   r   c                  n    e Zd ZdZdZdd	Zedd            Zedd            Zedd            Z	ddZ
dS )_SubsetHookCallerztA proxy to another HookCaller which manages calls to all registered
    plugins except the ones from remove_plugins.)_orig_remove_pluginsorigr   remove_pluginsSet[_Plugin]r9   r:   c                R    || _         || _        |j        | _        |j        | _        d S r<   )r   r   ri   r   )r>   r   r   s      r*   r?   z_SubsetHookCaller.__init__b  s'    
-I	r)   r   c                4      fd j         j        D             S )Nc                0    g | ]}|j         j        v|S r(   )r   r   )rh   implr>   s     r*   
<listcomp>z0_SubsetHookCaller._hookimpls.<locals>.<listcomp>j  s3     
 
 
{$"666 666r)   )r   r   rq   s   `r*   r   z_SubsetHookCaller._hookimplsh  s3    
 
 
 

-
 
 
 	
r)   HookSpec | Nonec                    | j         j        S r<   )r   r   rq   s    r*   r   z_SubsetHookCaller.specp  s    zr)   _CallHistory | Nonec                    | j         j        S r<   )r   r   rq   s    r*   r   z_SubsetHookCaller._call_historyt  s    z''r)   r8   c                    d| j         dS )Nz<_SubsetHookCaller r   r   rq   s    r*   r   z_SubsetHookCaller.__repr__x  s    3TY3333r)   N)r   r   r   r   r9   r:   r   )r9   r   )r9   r   r   )r#   r$   r%   r&   rT   r?   propertyr   r   r   r   r(   r)   r*   r   r   O  s        4 4I
( ( ( ( 
 
 
 X
    X ( ( ( X(4 4 4 4 4 4r)   r   c                  &    e Zd ZdZdZddZddZdS )r   z/A hook implementation in a :class:`HookCaller`.)rA   r   
kwargnamesr   rO   plugin_namer-   r.   r/   r0   r1   r   r   r   r8   rA   _HookImplFunction[object]hook_impl_optsr,   r9   r:   c                
   || _         t          | j                   \  }}|| _        || _        || _        || _        || _        |d         | _        |d         | _        |d         | _	        |d         | _
        |d         | _        dS )r   r-   r.   r/   r0   r1   N)rA   r   r   r   r   rO   r   r-   r.   r/   r0   r1   )r>   r   r   rA   r   r   r   s          r*   r?   zHookImpl.__init__  s      ('66*'!+#)	"-,Y7 #1"? $2.#A  .j9 -Y7r)   c                (    d| j         d| j        dS )Nz<HookImpl plugin_name=z	, plugin=r   )r   r   rq   s    r*   r   zHookImpl.__repr__  s     U(8UUT[UUUUr)   N)
r   r   r   r8   rA   r   r   r,   r9   r:   r   )r#   r$   r%   r&   rT   r?   r   r(   r)   r*   r   r   |  sP        99I"8 "8 "8 "8HV V V V V Vr)   c                      e Zd ZdZdd
ZdS )r   )r   rA   ri   r   r   rO   r   r!   r   r   ri   r8   rO   r   r9   r:   c                   || _         t          ||          | _        || _        t	          | j                  \  | _        | _        || _        |                    d          | _	        |                    d          | _
        d S )Nr   r!   )r   ry   rA   ri   r   r   r   rO   r   r   r!   )r>   r   ri   rO   s       r*   r?   zHookSpec.__init__  so    "/6y$/G/G	)1$-)@)@&t	 HH^44!%*=!>!>r)   N)r   r   ri   r8   rO   r   r9   r:   )r#   r$   r%   rT   r?   r(   r)   r*   r   r     s/        	I? ? ? ? ? ?r)   r   )rO   r,   r9   r:   )rJ   rc   r9   rd   )6r&   
__future__r   collections.abcr   r   r   r   ru   systypesr   typingr	   r
   r   r   r   r   r   r   r   r   r   _resultr   r   rc   r   typer   r   r8   r   r   r   _HookImplFunctionr   r,   r5   rV   ra   hasattrr   r   r   
_HookRelayr   _CallHistoryr   _HookCallerr   r   r   r(   r)   r*   <module>r     sW    # " " " " " % % % % % % # # # # # # $ $ $ $ $ $        



                                                                                WT]]WT#v+.///:t#$

(:
V 4d;	&$v,
!	 S%IdF2J6L,M(M"NNO 4 4 4 4 49 4 4 4     9   * S) S) S) S) S) S) S) S)l q3 q3 q3 q3 q3 q3 q3 q3h& & & & 	())> > > >B < < < < < < < < 
 E'#v+.3%+9N0OOPQL, L, L, L, L, L, L, L,` *4 *4 *4 *4 *4
 *4 *4 *4Z 6V 6V 6V 6V 6V 6V 6V 6Vr ? ? ? ? ? ? ? ? ? ?r)   