bgPVdZddlmZddlZddlZddlZddlmZddlm Z ddlm Z ddlm Z ddlm Z dd lm Z dd lmZdd lmZdd lmZdd lmZddlmZddlmZddlmZddlmZddlmZer ddlmZddlmZedZede defZeeefZeZ e e!edee!efe"geee effZ#e deee deedfffZ$erGddeZ%GddeZ&Gdd Z'Gd!d"Z(d5d&Z)e*ed'Z+d6d+Z,Gd,d-Z-e eee!efee e gdffZ.Gd.d/Z/Gd0d1e/Z0Gd2dZ1Gd3d4Z2dS)7zA Internal hook annotation, representation and calling machinery. ) annotationsN) ModuleType) AbstractSet)Any)Callable) Generator)List)Mapping)Optional)overload)Sequence)Tuple) TYPE_CHECKING)TypeVar)Union)_Result) TypedDict)Final_T_F.)boundHookImplc.eZdZUded<ded<ded<dS) _HookSpecOptsbool firstresulthistoricWarning | None warn_on_implN__name__ __module__ __qualname____annotations__^/builddir/build/BUILD/cloudlinux-venv-1.0.7/venv/lib/python3.11/site-packages/pluggy/_hooks.pyrr*s3$$$$$$r'rcLeZdZUded<ded<ded<ded<ded<ded<d S) _HookImplOptsrwrapper hookwrapper optionalhooktryfirsttrylast str | NonespecnameNr!r&r'r(r*r*/sQ  r'r*creZdZdZdZddZe dddZe dddZ dddZd S)HookspecMarkeraDecorator 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_namer5strreturnNonec||_dSNr4selfr5s r(__init__zHookspecMarker.__init__B#/r'FNfunctionrrrrr rcdSr:r&r<r?rrr s r(__call__zHookspecMarker.__call__E  r'.Callable[[_F], _F]cdSr:r&rAs r(rBzHookspecMarker.__call__OrCr' _F | None_F | Callable[[_F], _F]c:dfd }| ||S|S)aIf 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. If ``firstresult`` is ``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. If ``historic`` is ``True``, every call to the hook will be memorized and replayed on plugins registered after the call was made. funcrr7clrrtdd}t|jdz||S)Nz'cannot have a historic firstresult hook)rrr _spec) ValueErrorsetattrr5)rIoptsrrr<r s r(setattr_hookspec_optsz6HookspecMarker.__call__..setattr_hookspec_optsnsY LK L !JKKK*$ ,##D D$+g5t < < <Kr'NrIrr7rr&)r<r?rrr rOs` ``` r(rBzHookspecMarker.__call__YsR*           ((22 2( (r'r5r6r7r8)FFN) r?rrrrrr rr7r)....) r?r8rrrrr rr7rD)NFFN) r?rFrrrrr rr7rGr"r#r$__doc__ __slots__r=r rBr&r'r(r3r38s"I0000"'+     X '*     X #!'+ #)#)#)#)#)#)#)r'r3ceZdZdZdZddZe dddZe dddZ d d!dZdS)"HookimplMarkeraDecorator 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. r4r5r6r7r8c||_dSr:r4r;s r(r=zHookimplMarker.__init__r>r'.r?rr,rr-r.r/r1r0r+cdSr:r&r<r?r,r-r.r/r1r+s r(rBzHookimplMarker.__call__  r'rDcdSr:r&rYs r(rBzHookimplMarker.__call__rZr'NFrFrGcFdfd }||S||S)aIf 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. If ``optionalhook`` is ``True``, a missing matching hook specification will not result in an error (by default it is an error if no matching spec is found). If ``tryfirst`` is ``True``, this hook implementation will run as early as possible in the chain of N hook implementations for a specification. If ``trylast`` is ``True``, this hook implementation will run as late as possible in the chain of N hook implementations. If ``wrapper`` is ``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. If ``hookwrapper`` is ``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``. If ``specname`` is provided, it will be used instead of the function name when matching this hook implementation to a hook specification during registration. .. versionadded:: 1.2.0 The ``wrapper`` parameter. rIrr7cLd}t|jdz||S)N)r+r,r-r.r/r1_impl)rMr5) rIrNr,r-r<r1r.r/r+s r(setattr_hookimpl_optsz6HookimplMarker.__call__..setattr_hookimpl_optssB"* ,$"$ ##D D$+g5t < < <Kr'NrPr&) r<r?r,r-r.r/r1r+r_s ` `````` r(rBzHookimplMarker.__call__sef              ( (((22 2r'rQ)......)r?rr,rr-rr.rr/rr1r0r+rr7r).......)r?r8r,rr-rr.rr/rr1r0r+rr7rD)NFFFFNF)r?rFr,rr-rr.rr/rr1r0r+rr7rGrRr&r'r(rVrVs"I0000  "     X   "     X  #!"#B3B3B3B3B3B3B3r'rVrNr7r8c|dd|dd|dd|dd|dd|dddS)Nr.Fr/r+r,r-r1) setdefault)rNs r(normalize_hookimpl_optsrbsOOJ&&&OOIu%%%OOIu%%%OOM5)))OONE***OOJ%%%%%r'pypy_version_inforIobject'tuple[tuple[str, ...], tuple[str, ...]]cd tj|r |j}nI#t$rYdSwxYwtj|s$ t |d|}n#t $rYdSwxYw tjtj|r|j n|}n#t$rYdSwxYwtj j tj j f fd|jD}t!|}t!d|Dpd}|r2t%| }|d|t!||d}}nd}t&sd}nd}|r=t |d d }tj|sd |vr|d |vr |d d}||fS)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&rBc.i|]\}}|jv||Sr&)kind).0nameparam_valid_param_kindss r( zvarnames..s7 D% :+ + + e + + +r'c3@K|]}|j|ju|jVdSr:)defaultempty)rirks r( zvarnames..s?  }EK// M////  r'Nr&r<)r<objr$.rr)inspectisclassr=AttributeError isroutinegetattr Exception signatureismethod__func__ TypeError ParameterPOSITIONAL_ONLYPOSITIONAL_OR_KEYWORD parametersitemstuplevalueslen_PYPY) rIsig _valid_paramsargsdefaultsindexkwargsimplicit_namesqualnamerls @r(varnamesrs=t  =DD   66   t $ $ 4T22DD   66 $-d33 =DMM   vv )/>//11M   D   &--//         XFUF|U4<%8%8f )*3( nb99  D ! ! cXoo$q'^:S:S8D <s0 --A A%$A%)/B B'&B'c&eZdZdZdZerd dZdSdS) _HookRelayzaHook holder object for performing 1:N hook calls where N is the number of registered plugins.)__dict__rjr6r7 _HookCallercdSr:r&)r<rjs r( __getattr__z_HookRelay.__getattr__@s Cr'N)rjr6r7r)r"r#r$rSrTrrr&r'r(rr8sKI      r'rceZdZdZ d,d-d Zd.dZd/dZd.dZd0dZd1dZ d2dZ d3dZ d4dZ d5d"Z d,d6d&Zd7d)Zd8d+ZdS)9r)rjspec _hookexec _hookimpls _call_historyNrjr6 hook_execute _HookExecspecmodule_or_class_Namespace | None spec_opts_HookSpecOpts | Noner7r8c||_||_g|_d|_d|_||J|||dSdSr:)rjrrrrset_specification)r<rjrrrs r(r=z_HookCaller.__init__Ps_  ,1326%)  *(((  " "#6 B B B B B + *r'rc|jduSr:)rrrs r(has_specz_HookCaller.has_spec`sy$$r' _Namespacerc|j)td|jjd|jjt ||j||_|dr g|_dSdS)NzHook z( is already registered within namespace r)rrLrj namespaceHookSpecgetr)r<rrs r(rz_HookCaller.set_specificationcs 9 : ::$(I$7:: 0$)YGG == $ $ $!#D    $ $r'c|jduSr:)rrrs r( is_historicz_HookCaller.is_historicqs!--r'plugin_Pluginct|jD]\}}|j|kr |j|=dStd|d)Nzplugin z not found) enumeraterrrL)r<rimethods r(_remove_pluginz_HookCaller._remove_plugints^"4?33  IAv}&&OA&'76777888r'list[HookImpl]c4|jSr:)rcopyrrs r( get_hookimplsz_HookCaller.get_hookimpls{s##%%%r'hookimplrct|jD]\}}|js|jr|}nt |j}|js|jr|t |j}}nd|}}|jr|j||dS|jr|j||dS|dz }||kr/|j|jr|dz}||kr|j|j|j|dz|dS)z,Add an implementation to the callback chain.rrN)rrr,r+rr/insertr.)r<rrr splitpointstartends r( _add_hookimplz_HookCaller._add_hookimpl~s>"4?33 . .IAv! V^   T_--J   '8#3 '#S%9%93EEJ3E   4 O " "5( 3 3 3 3 3   4 O " "3 1 1 1 1 1aAu**!3!<*Qu**!3!<* O " "1q5( 3 3 3 3 3r'cd|jdS)Nz <_HookCaller >rjrrs r(__repr__z_HookCaller.__repr__s-ty----r'rMapping[str, object]c|jrj|jjD]_}|vrWdfd|jjD}tjd|ddS^dSdS)Nz, c3bK|])}|vt|V*dSr:)keysrepr)riargnamers r(rqz<_HookCaller._verify_all_args_are_provided..sJ**#"&++--77W 8777 **r'zSArgument(s) {} which are declared in the hookspec cannot be found in this hook call) stacklevel)rargnamesjoinwarningswarnformat)r<rr notincalls ` r(_verify_all_args_are_providedz)_HookCaller._verify_all_args_are_provideds 9 9-  &(( $ ****'+y'9***!!I M<>>QV ~~di&+NNNr'result_callbackCallable[[Any], None] | NoneMapping[str, object] | Nonec|jJ|pi}|||j||f||j|j|d}|dSt |tr|D]}||dSdS)aCall the hook with given ``kwargs`` for all registered plugins and for all plugins which will be registered afterwards. If ``result_callback`` is provided, it will be called for each non-``None`` result obtained from a hook implementation. NF)rrappendrrjr isinstancelist)r<rrresxs r( call_historicz_HookCaller.call_historics!---2 **6222 !!6?";<<<nnTYGG  " F c4  # # #"""" # # # #r'methodsSequence[Callable[..., object]]cz|r Jd||ddddddd}|j}|D]}t dd||}t |dz }|dkrY||jrL||js?||js2|dz}|dkr'||jr||js ||j2| |dz||j r |j j ddnd}| |j|||S) zCall the hook with some additional temporarily participating methods using the specified ``kwargs`` as call parameters.rFN)r+r,r-r/r.r1zrrr)rrrrrrr.r,r+rrrNrrrj) r<rrrN hookimplsrrrrs r( call_extraz_HookCaller.call_extras   "" O O N O O " **6222 !   O((**  . .Fh==HI"AQaL)"115>q\5IQ QaL)"115>q\5I   QUH - - - -BF)Vdin((>>>QV ~~diFKHHHr'rc|r`|jJ|jD]Q\}}||j|g|d}|r*|(t |t sJ||dPdSdS)zAApply call history to a new hookimpl if it is marked as historic.NFr)rrrrjrr)r<rrrrs r(_maybe_apply_historyz _HookCaller._maybe_apply_historys      ,%111+/+= , ,'nnTY&%HH,?6%c400000#OCF+++ , , , ,r')NN) rjr6rrrrrrr7r8)r7r)rrrrr7r8)rrr7r8r7r)rrr7r8r7r6)rrr7r8)rrdr7r)rrrrr7r8)rrrrr7r)rrr7r8)r"r#r$rTr=rrrrrrrrrBrrrr&r'r(rrGsGI26*. CCCCC %%%% $ $ $ $....9999&&&&44440....$OOOO9=.2#####0IIII@ , , , , , ,r'rcneZdZdZdZdd Zedd Zedd ZeddZ ddZ dS)_SubsetHookCallerztA proxy to another HookCaller which manages calls to all registered plugins except the ones from remove_plugins.)_orig_remove_pluginsorigrremove_pluginsAbstractSet[_Plugin]r7r8cR||_||_|j|_|j|_dSr:)rrrjr)r<rrs r(r=z_SubsetHookCaller.__init__ s' -I r'rc4fdjjDS)Nc0g|]}|jjv|Sr&)rr)riimplr<s r( z0_SubsetHookCaller._hookimpls..s3   {$"666 666r')rrrrs`r(rz_SubsetHookCaller._hookimplss3     -    r'HookSpec | Nonec|jjSr:)rrrrs r(rz_SubsetHookCaller.specs zr'_CallHistory | Nonec|jjSr:)rrrrs r(rz_SubsetHookCaller._call_historys z''r'r6cd|jdS)Nz<_SubsetHookCaller rrrrs r(rz_SubsetHookCaller.__repr__ s3TY3333r'N)rrrrr7r8r)r7r)r7rr) r"r#r$rSrTr=propertyrrrrr&r'r(rrs44I ((((    X X(((X(444444r'rc"eZdZdZdd Zdd ZdS)r) r?r kwargnamesrrN plugin_namer+r,r-r.r/rrrr6r?_HookImplFunction[object]hook_impl_optsr*r7r8c||_t|j\|_|_||_||_||_|d|_|d|_|d|_ |d|_ |d|_ dS)Nr+r,r-r.r/) r?rrrrrNrr+r,r-r.r/)r<rrr?rs r(r=zHookImpl.__init__3s{ ( )1$-)@)@& t " &%i0 )-8*>:&z2 %i0 r'c(d|jd|jdS)Nzr s/#"""""  (++++++'''''' WT]] WT#v+./// :t# $  (: V 4d; &$v, !  S%IdGBK6M,N(N"OOP %%%%% %%%  D)D)D)D)D)D)D)D)Ni3i3i3i3i3i3i3i3X&&&& ())>>>>B        E'#v+.3%+9N0OOPQ m,m,m,m,m,m,m,m,`*4*4*4*4*4 *4*4*4Z"V"V"V"V"V"V"V"VJ5555555555r'