
    ZeIi6                     l    d Z ddlZddlZddlZ	 ddlZn# e$ r ddlZY nw xY w G d de          ZeZ	dS )a  
Parameters deprecation
======================

.. _Tantale's Blog: https://tantale.github.io/
.. _Deprecated Parameters: https://tantale.github.io/articles/deprecated_params/

This module introduces a :class:`deprecated_params` decorator to specify that one (or more)
parameter(s) are deprecated: when the user executes a function with a deprecated parameter,
he will see a warning message in the console.

The decorator is customizable, the user can specify the deprecated parameter names
and associate to each of them a message providing the reason of the deprecation.
As with the :func:`~deprecated.classic.deprecated` decorator, the user can specify
a version number (using the *version* parameter) and also define the warning message category
(a subclass of :class:`Warning`) and when to display the messages (using the *action* parameter).

The complete study concerning the implementation of this decorator is available on the `Tantale's blog`_,
on the `Deprecated Parameters`_ page.
    Nc                   8    e Zd ZdZdefdZd	dZd Zd Zd Z	dS )
DeprecatedParamszg
    Decorator used to decorate a function which at least one
    of the parameters is deprecated.
     c                 P    i | _         || _        |                     ||           d S )N)reason)messagescategorypopulate_messages)selfparamr   r	   s       V/var/www/html/MCyber-Diagnostic/venv/lib/python3.11/site-packages/deprecated/params.py__init__zDeprecatedParams.__init__'   s/     uV44444    c                     t          |t                    r| j                            |           d S t          |t                    r&d}|p|                    |          }|| j        |<   d S t          |          )Nz!'{param}' parameter is deprecated)r   )
isinstancedictr   updatestrformat	TypeError)r   r   r   fmts       r   r
   z"DeprecatedParams.populate_messages,   s    eT"" 	#M  '''''s## 	#5C6szzz66F#)DM%   E"""r   c                 r      |j         |i |}t          j        |j        fi |j        } fd|D             S )Nc                 &    g | ]}|j         v |S  r   .0r   r   s     r   
<listcomp>z1DeprecatedParams.check_params.<locals>.<listcomp>9   s%    CCC%ET],B,B,B,B,Br   )bindcollectionsOrderedDict	argumentskwargs)r   	signatureargsr#   bindingbounds   `     r   check_paramszDeprecatedParams.check_params6   sP     ).$1&11'(9LLW^LLCCCC5CCCCr   c                 H    |D ]}t          j        || j        d           d S )N   )r	   
stacklevel)warningswarnr	   )r   r   messages      r   warn_messageszDeprecatedParams.warn_messages;   s;     	I 	IGM'DMaHHHHH	I 	Ir   c                 v     t          j                  t          j                   fd            }|S )Nc                  x     j         g| R i |}                    fd|D                         | i |S )Nc                 *    g | ]}j         |         S r   r   r   s     r   r   z>DeprecatedParams.__call__.<locals>.wrapper.<locals>.<listcomp>G   s     QQQe 4QQQr   )r(   r/   )r%   r#   invalid_paramsfr   r$   s      r   wrapperz*DeprecatedParams.__call__.<locals>.wrapperD   sc    .T.yJ4JJJ6JJNQQQQ.QQQRRR1d%f%%%r   )inspectr$   	functoolswraps)r   r4   r5   r$   s   `` @r   __call__zDeprecatedParams.__call__@   sT    %a((					& 	& 	& 	& 	& 	& 
		&
 r   N)r   )
__name__
__module____qualname____doc__DeprecationWarningr   r
   r(   r/   r9   r   r   r   r   r   !   s         
 &(2D 5 5 5 5
# # # #D D D
I I I

 
 
 
 
r   r   )
r=   r    r7   r,   inspect2r6   ImportErrorobjectr   deprecated_paramsr   r   r   <module>rC      s    (            NNNNN) ) ) ) )v ) ) )\ %   s    	!!