Your IP : 18.119.158.142


Current Path : /opt/cloudlinux/venv/lib64/python3.11/site-packages/pluggy/__pycache__/
Upload File :
Current File : //opt/cloudlinux/venv/lib64/python3.11/site-packages/pluggy/__pycache__/_manager.cpython-311.pyc

�

��bgF��<�ddlmZddlZddlZddlZddlZddlmZddlmZddlm	Z	ddlm
Z
ddlmZddlmZdd	lm
Z
d
dlmZd
dlmZd
d
lmZd
dlmZd
dlmZd
dlmZd
dlmZd
dlmZd
dlmZd
dlmZd
dlmZd
dlmZejdkrddlm Z!nddl!Z!e
rddl"m#Z#d
dlm$Z$m%Z%ee&eeee&efgdfZ'eeee&eeee&efgdfZ(d+d!�Z)Gd"�d#e*��Z+Gd$�d%��Z,Gd&�d'��Z-d,d*�Z.dS)-�)�annotationsN)�Any)�Callable)�cast)�Iterable)�Mapping)�Sequence)�
TYPE_CHECKING�)�_tracing)�
_multicall)�_HookCaller)�_HookImplFunction)�
_HookRelay)�
_Namespace)�_Plugin)�_SubsetHookCaller)�HookImpl)�HookSpec)�normalize_hookimpl_opts)�_Result)����metadata)�Final)�
_HookImplOpts�
_HookSpecOpts�warning�Warning�function�Callable[..., object]�return�Nonec��ttj|��}tj|t|��|jj|jj���dS)N)�lineno�filename)	r�types�FunctionType�warnings�
warn_explicit�type�__code__�co_firstlineno�co_filename)rr!�funcs   �`/builddir/build/BUILD/cloudlinux-venv-1.0.7/venv/lib/python3.11/site-packages/pluggy/_manager.py�_warn_for_functionr2*sT����"�H�-�-�D�����W�
�
��}�+���*�	������c�$��eZdZdZd	�fd�Z�xZS)
�PluginValidationErrorzVPlugin failed validation.

    :param plugin: The plugin which failed validation.
    �pluginr�message�strr#r$c�X��t���|��||_dS�N)�super�__init__r6)�selfr6r7�	__class__s   �r1r<zPluginValidationError.__init__:s&���
������!�!�!�����r3)r6rr7r8r#r$)�__name__�
__module__�__qualname__�__doc__r<�
__classcell__)r>s@r1r5r54sG���������
���������r3r5c�D�eZdZdZdd�Zedd���Zddd�Zdd
�Zd	S)�
DistFacadez$Emulate a pkg_resources Distribution�dist�importlib_metadata.Distributionr#r$c��||_dSr:)�_dist)r=rFs  r1r<zDistFacade.__init__Bs
����
�
�
r3r8c� �|jd}|S)N�namer�r=rKs  r1�project_namezDistFacade.project_nameEs���M�&�)���r3N�attrc�.�t|j||��Sr:)�getattrrI)r=rN�defaults   r1�__getattr__zDistFacade.__getattr__Js���t�z�4��1�1�1r3�	list[str]c�N�tt|j��ddgz��S)NrIrM)�sorted�dirrI�r=s r1�__dir__zDistFacade.__dir__Ms"���c�$�*�o�o��.�(A�A�B�B�Br3)rFrGr#r$)r#r8r:)rNr8)r#rS)	r?r@rArBr<�propertyrMrRrX�r3r1rErE?s�������.�.����������X��2�2�2�2�2�C�C�C�C�C�Cr3rEc���eZdZdZdBd�ZdCd�ZdDdEd�ZdFd�Z	dGdHd�ZdId�Z	dJd�Z
dKd�ZdLd �ZdMd"�Z
dNd#�ZdOd$�ZdPd&�ZdJd'�ZdQd(�ZdRd-�ZdSd.�ZdDdTd1�ZdUd3�ZdVd5�ZdWd7�ZdXd=�ZdYd>�ZdZdA�ZdS)[�
PluginManagera�Core class which manages registration of plugin objects and 1:N hook
    calling.

    You can register new hooks by calling :meth:`add_hookspecs(module_or_class)
    <PluginManager.add_hookspecs>`.

    You can register plugin objects (which contain hook implementations) by
    calling :meth:`register(plugin) <PluginManager.register>`.

    For debugging purposes you can call :meth:`PluginManager.enable_tracing`
    which will subsequently send debug information to the trace helper.
    rMr8r#r$c���||_i|_g|_tj���d��|_t��|_t|_
dS)N�pluginmanage)rM�_name2plugin�_plugin_distinfor�	TagTracer�get�tracer�hookr
�_inner_hookexec)r=rMs  r1r<zPluginManager.__init___sQ��#/���79���IK���$�.�0�0�4�4�^�D�D��
�%�<�<��	�)����r3�	hook_name�methods�Sequence[HookImpl]�kwargs�Mapping[str, object]�firstresult�bool�object | list[object]c�2�|�||||��Sr:�re)r=rfrgrirks     r1�	_hookexeczPluginManager._hookexecgs���#�#�I�w���L�L�Lr3Nr6rrK�
str | Nonec�R�|p|�|��}||jvr:|j�|d���dStd|�d|�d|j�����||j���vrtd|�d|�d|j�����||j|<t|��D]�}|�||��}|��t|��t||��}t||||��}|�d��p|}t|j
|d��}|�,t||j��}t|j
||��n?|���r+|�||��|�|��|�|����|S)a"Register a plugin and return its name.

        If a name is not specified, a name is generated using
        :func:`get_canonical_name`.

        If the name is blocked from registering, returns ``None``.

        If the plugin is already registered, raises a :class:`ValueError`.
        ���Nz Plugin name already registered: �=�
z2Plugin already registered under a different name: �specname)�get_canonical_namer_rb�
ValueError�valuesrV�parse_hookimpl_optsrrPrrdrrp�setattr�has_spec�_verify_hook�_maybe_apply_history�
_add_hookimpl)r=r6rK�plugin_name�
hookimpl_opts�method�hookimplrds        r1�registerzPluginManager.registerrs����=�d�5�5�f�=�=���$�+�+�+�� �$�$�[�"�5�5�=��t��*��;�;�����(9�(9�;���
�
�T�&�-�-�/�/�/�/��*��;�;�����(9�(9�;���
�*0���+�&���K�K�	-�	-�D� �4�4�V�T�B�B�M��(�'�
�6�6�6�4;�F�D�4I�4I��#�F�K���O�O��$�(�(��4�4�<���+2�4�9�d�D�+I�+I���<�&�t�T�^�<�<�D��D�I�t�T�2�2�2�2��]�]�_�_�8��%�%�d�H�5�5�5��-�-�h�7�7�7��"�"�8�,�,�,���r3�_HookImplOpts | Nonec���t||��}tj|��sdS	t||jdzd��}n#t$ri}YnwxYw|�t|t��sd}|S)N�_impl)rP�inspect�	isroutinerM�	Exception�
isinstance�dict)r=r6rKr��ress     r1rzz!PluginManager.parse_hookimpl_opts�s��� ���.�.��� ��(�(�	��4�	�(/���)�G�3�T�)�)�C�C���	�	�	��C�C�C�	�����?�:�c�4�#8�#8�?��C��
s�A�A�A�_Plugin | Nonec�@�|�-|�
Jd���|�|��}|�
Jd���|�|�|��}|�|��}|r|D]}|�|���|j�|��r|�J�|j|=|S)z�Unregister a plugin and all of its hook implementations.

        The plugin can be specified either by the plugin object or the plugin
        name. If both are specified, they must agree.
        Nz+one of name or plugin needs to be specifiedzplugin is not registered)�get_name�
get_plugin�get_hookcallers�_remove_pluginr_rb)r=r6rK�hookcallers�
hookcallers     r1�
unregisterzPluginManager.unregister�s����<��%�%�'T�%�%�%��=�=��(�(�D��#�#�%?�#�#�#��>��_�_�T�*�*�F��*�*�6�2�2���	2�)�
2�
2�
��)�)�&�1�1�1�1��� � ��&�&�	(��#�#�#��!�$�'��
r3c�F�|�|���d|j|<dS)zHBlock registrations of the given name, unregister if already registered.�rKN)r�r_rLs  r1�set_blockedzPluginManager.set_blocked�s)�����T��"�"�"�"&���$���r3c�2�||jvo|j|duS)z0Return whether the given plugin name is blocked.N)r_rLs  r1�
is_blockedzPluginManager.is_blocked�s"���t�(�(�L�T�->�t�-D��-L�Lr3�module_or_classrc���g}t|��D]�}|�||��}|��t|j|d��}|�.t	||j||��}t
|j||��nC|�||��|���D]}|�	||���|�
|����|std|j�d|�����dS)z�Add new hook specifications defined in the given ``module_or_class``.

        Functions are recognized as hook specifications if they have been
        decorated with a matching :class:`HookspecMarker`.
        Nzdid not find any z
 hooks in )
rV�parse_hookspec_optsrPrdrrpr{�set_specification�
get_hookimplsr}�appendrxrM)r=r��namesrK�	spec_opts�hc�hookfunctions       r1�
add_hookspecszPluginManager.add_hookspecs�s������(�(�	#�	#�D��0�0��$�G�G�I��$�)0���D�$�)G�)G���:�$�T�4�>�?�I�V�V�B��D�I�t�R�0�0�0�0��(�(��)�D�D�D�(*�(8�(8�(:�(:�<�<���)�)�"�l�;�;�;�;����T�"�"�"���	��V�D�$5�V�V�?�V�V���
�	�	r3�_HookSpecOpts | Nonec�X�t||��}t||jdzd��}|S)N�_spec)rPrM)r=r�rKr��optss     r1r�z!PluginManager.parse_hookspec_opts�s2��#�?�D�9�9��%,�V�T�5F��5P�RV�%W�%W���r3�set[Any]c�N�t|j�����S)z.Return a set of all registered plugin objects.)�setr_ryrWs r1�get_pluginszPluginManager.get_plugins�s���4�$�+�+�-�-�.�.�.r3c�h��t�fd�|j���D����S)z0Return whether the plugin is already registered.c3�$�K�|]
}�|kV��dSr:rZ)�.0�valr6s  �r1�	<genexpr>z.PluginManager.is_registered.<locals>.<genexpr>�s'�����G�G�S�6�S�=�G�G�G�G�G�Gr3)�anyr_ry)r=r6s `r1�
is_registeredzPluginManager.is_registered�s5����G�G�G�G�D�,=�,D�,D�,F�,F�G�G�G�G�G�Gr3c�`�t|dd��}|ptt|����S)a3Return a canonical name for a plugin object.

        Note that a plugin may be registered under a different name
        specified by the caller of :meth:`register(plugin, name) <register>`.
        To obtain the name of n registered plugin use :meth:`get_name(plugin)
        <get_name>` instead.
        r?N)rPr8�id)r=r6rKs   r1rwz PluginManager.get_canonical_name�s,��#�6�:�t�<�<���&�s�2�f�:�:���&r3�
Any | Nonec�6�|j�|��S)z:Return the plugin registered under the given name, if any.)r_rbrLs  r1r�zPluginManager.get_plugin
s��� �$�$�T�*�*�*r3c�0�|�|��duS)z:Return whether a plugin with the given name is registered.N)r�rLs  r1�
has_pluginzPluginManager.has_plugins�����t�$�$�D�0�0r3c�X�|j���D]\}}||kr|cS�dS)zPReturn the name the plugin is registered under, or ``None`` if
        is isn't.N)r_�items)r=r6rKr�s    r1r�zPluginManager.get_namesB���*�0�0�2�2�	�	�I�D�#���}�}�������tr3rdrr�rc�4�|���r4|js|jr&t|jd|j�d|j�d����|j�J�|jjrt|jj|j
��t|j��t|jj��z
}|r>t|jd|j�d|j�dt|j
���d|�d�	���|js|jrTtj|j
��s;t|jd|j�d|j�dt|j
���d����|jrB|jr=t|jd|j�d|j�dt|j
���d	����dSdS)
NzPlugin z
hook z5
historic incompatible with yield/wrapper/hookwrapperz
 for hook z
hookimpl definition: z
Argument(s) zB are declared in the hookimpl but can not be found in the hookspeczV
Declared as wrapper=True or hookwrapper=True but function is not a generator functionzE
The wrapper=True and hookwrapper=True options are mutually exclusive)�is_historic�hookwrapper�wrapperr5r6r�rK�spec�warn_on_implr2r!r��argnames�
_formatdefr��isgeneratorfunction)r=rdr��	notinspecs    r1r}zPluginManager._verify_hooks��������	�8�#7�	�8�;K�	�'�����'�'�'�����4���
��y�$�$�$��9�!�	J��t�y�5�x�7H�I�I�I���)�*�*�S���1C�-D�-D�D�	��	�'����
�(�(�(��I�I�I��x�0�1�1�1�1��I�I����
�
��		� (� 4�		��-�h�.?�@�@�		�(�����'�'�'�����J�x�?P�4Q�4Q�4Q�4Q�S���
���	�� 4�	�'�����'�'�'�����J�x�?P�4Q�4Q�4Q�4Q�S���
�	�	�	�	r3c	�
�|jjD]u}|ddkrgt|j|��}|���s>|���D])}|js t
|jd|�d|j������*�vdS)z�Verify that all hooks which have not been verified against a
        hook specification are optional, otherwise raise
        :class:`PluginValidationError`.r�_z
unknown hook z in plugin N)rd�__dict__rPr|r��optionalhookr5r6)r=rKrdr�s    r1�
check_pendingzPluginManager.check_pendingIs����I�&�
	�
	�D��A�w�#�~�~�$+�D�I�t�$<�$<���}�}����$(�$6�$6�$8�$8����'�4��"7� (���#'�4�4����!:�#�#����
	�
	r3�group�intc��d}ttj����D]�}|jD]�}|j|ksA|�|j|ks4|�|j��s|�|j��r�O|���}|�	||j���|j
�|t|��f��|dz
}����|S)a$Load modules from querying the specified setuptools ``group``.

        :param str group: Entry point group to load plugins.
        :param str name: If given, loads only plugins with the given ``name``.
        :rtype: int
        :return: The number of plugins loaded by this call.
        rNr�r)
�list�importlib_metadata�
distributions�entry_pointsr�rKr�r��loadr�r`r�rE)r=r�rK�countrF�epr6s       r1�load_setuptools_entrypointsz)PluginManager.load_setuptools_entrypointsYs������+�9�;�;�<�<�
	�
	�D��'�
�
���H��%�%��(�R�W��_�_����r�w�/�/�.=����r�w�/�/�.=�
��������
�
�f�2�7�
�3�3�3��%�,�,�f�j��6F�6F�-G�H�H�H���
���
��r3� list[tuple[_Plugin, DistFacade]]c�*�t|j��S)zXReturn a list of (plugin, distinfo) pairs for all
        setuptools-registered plugins.)r�r`rWs r1�list_plugin_distinfoz"PluginManager.list_plugin_distinfors���D�)�*�*�*r3�list[tuple[str, _Plugin]]c�N�t|j�����S)zAReturn a list of (name, plugin) pairs for all registered plugins.)r�r_r�rWs r1�list_name_pluginzPluginManager.list_name_pluginws���D�%�+�+�-�-�.�.�.r3�list[_HookCaller] | Nonec���|�|���dSg}|jj���D]7}|���D] }|j|ur|�|���!�8|S)z.Get all hook callers for the specified plugin.N)r�rdr�ryr�r6r�)r=r6r�r�r�s     r1r�zPluginManager.get_hookcallers{s����=�=�� � �(��4����)�,�3�3�5�5�	3�	3�J�&�4�4�6�6�
3�
3���?�f�,�,��&�&�z�2�2�2��
3��r3�before�_BeforeTrace�after�_AfterTrace�Callable[[], None]c�H������j�d���fd�}|�_d��fd
�}|S)a0Add before/after tracing functions for all hooks.

        Returns an undo function which, when called, removes the added tracers.

        ``before(hook_name, hook_impls, kwargs)`` will be called ahead
        of all hook calls and receive a hookcaller instance, a list
        of HookImpl instances and the keyword arguments for the hook call.

        ``after(outcome, hook_name, hook_impls, kwargs)`` receives the
        same arguments as ``before`` but also a :class:`_Result` object
        which represents the result of the overall hook call.
        rfr8�
hook_implsrh�
caller_kwargsrjrkrlr#rmc�������������tj�����fd���}�|�����|���S)Nc� ���������Sr:rZ)r�rkr�rf�oldcalls�����r1�<lambda>zPPluginManager.add_hookcall_monitoring.<locals>.traced_hookexec.<locals>.<lambda>�s�����	�:�}�k�R�R�r3)r�	from_call�
get_result)rfr�r�rk�outcomer�r�r�s```` ���r1�traced_hookexecz>PluginManager.add_hookcall_monitoring.<locals>.traced_hookexec�sq�������
�F�9�j�-�8�8�8��'�R�R�R�R�R�R�R�R���G�
�E�'�9�j�-�@�@�@��%�%�'�'�'r3r$c�����_dSr:ro)r�r=s��r1�undoz3PluginManager.add_hookcall_monitoring.<locals>.undo�s���#*�D� � � r3)
rfr8r�rhr�rjrkrlr#rm�r#r$ro)r=r�r�r�r�r�s```  @r1�add_hookcall_monitoringz%PluginManager.add_hookcall_monitoring�sl�������&��	(�	(�	(�	(�	(�	(�	(�	(� /���	+�	+�	+�	+�	+�	+�	+��r3c���|jj�d���d�fd
�}d�fd
�}|�||��S)zwEnable tracing of hook calls.

        Returns an undo function which, when called, removes the added tracing.
        rdrfr8rgrhrirjr#r$c�J���jxjdz
c_�||��dS)Nr)�root�indent)rfrgri�	hooktraces   �r1r�z,PluginManager.enable_tracing.<locals>.before�s3���
�N�!�!�Q�&�!�!��I�i��(�(�(�(�(r3r��_Result[object]c���|j� �d|d|������jxjdzc_dS)N�finishz-->r)�	exceptionr�r�r�)r�rfrgrir�s    �r1r�z+PluginManager.enable_tracing.<locals>.after�sL���� �(��	�(�I�u�g�6H�6H�6J�6J�K�K�K��N�!�!�Q�&�!�!�!�!r3)rfr8rgrhrirjr#r$)
r�r�rfr8rgrhrirjr#r$)rcr�rbr�)r=r�r�r�s   @r1�enable_tracingzPluginManager.enable_tracing�sp���
�J�O�'�'��/�/�	�	)�	)�	)�	)�	)�	)�	'�	'�	'�	'�	'�	'��+�+�F�E�:�:�:r3�remove_plugins�Iterable[_Plugin]c�r��t|j���}�fd�|D��}|rt||��S|S)z�Return a proxy :py:class:`._hooks._HookCaller` instance for the named
        method which manages calls to all registered plugins except the ones
        from remove_plugins.c�4��h|]}t|����|��SrZ)�hasattr)r��plugrKs  �r1�	<setcomp>z3PluginManager.subset_hook_caller.<locals>.<setcomp>�s(���T�T�T�d���d�@S�@S�T�T�T�T�Tr3)rPrdr)r=rKr��orig�plugins_to_removes `   r1�subset_hook_callerz PluginManager.subset_hook_caller�sN���$�D�I�t�4�4��T�T�T�T�n�T�T�T���	>�$�T�+<�=�=�=��r3)rMr8r#r$)
rfr8rgrhrirjrkrlr#rmr:)r6rrKrqr#rq)r6rrKr8r#r�)NN)r6r�rKrqr#r)rKr8r#r$)rKr8r#rl)r�rr#r$)r�rrKr8r#r�)r#r�)r6rr#rl)r6rr#r8)rKr8r#r�)r6rr#rq)rdrr�rr#r$r�)r�r8rKrqr#r�)r#r�)r#r�)r6rr#r�)r�r�r�r�r#r�)r#r�)rKr8r�r�r#r)r?r@rArBr<rpr�rzr�r�r�r�r�r�r�rwr�r�r�r}r�r�r�r�r�r�r�rrZr3r1r\r\Qs#��������*�*�*�*�	M�	M�	M�	M�.�.�.�.�.�`
�
�
�
� AE������8'�'�'�'�
M�M�M�M�����4����/�/�/�/�H�H�H�H�	'�	'�	'�	'�+�+�+�+�1�1�1�1�����-�-�-�-�^���� �����2+�+�+�+�
/�/�/�/�	�	�	�	�#�#�#�#�J;�;�;�;�2
�
�
�
�
�
r3r\r0r8c�<�|j�tj|����Sr:)r?r��	signature)r0s r1r�r��s ���m�6�W�.�t�4�4�6�6�6r3)rr r!r"r#r$)r0r"r#r8)/�
__future__rr��sysr(r*�typingrrrrrr	r
�r�_callersr
�_hooksrrrrrrrrr�_resultr�version_info�	importlibrr��typing_extensionsrrrr8r�r�r2r�r5rEr\r�rZr3r1�<module>rs���"�"�"�"�"�"�����
�
�
�
��������������������������������������������� � � � � � ������� � � � � � �������%�%�%�%�%�%�������������������%�%�%�%�%�%�������������+�+�+�+�+�+���������v���8�8�8�8�8�8�8������5�'�'�'�'�'�'�4�4�4�4�4�4�4�4���h�x�0�'�#�s�(�2C�D�d�J�K������c�8�H�+=�w�s�C�x�?P�Q�SW�W�X�����������I����C�C�C�C�C�C�C�C�$}�}�}�}�}�}�}�}�@7�7�7�7�7�7r3

?>