o
    u#g;N                     @   s   d Z ddlZddlZddlZddlZddlZG dd deZ		ddddd	Zdddddddd
ddZ	dddddddd
ddZ
G dd dZi ZdddZG dd dZe ZdddZdddZddddZejdd ZdS ) a   
Helper functions for deprecating parts of the Matplotlib API.

This documentation is only relevant for Matplotlib developers, not for users.

.. warning::

    This module is for internal use only.  Do not use it in your own code.
    We may change the API at any time with no warning.

    Nc                   @   s   e Zd ZdZdS )MatplotlibDeprecationWarningz>A class for issuing deprecation warnings for Matplotlib users.N)__name__
__module____qualname____doc__ r   r   /var/www/static.ux5.de/https/Moving-Object-Detection-with-OpenCV/env/lib/python3.10/site-packages/matplotlib/_api/deprecation.pyr      s    r    Fremovalc                C   s   |r	|rt dn|s| d^}}	}
| dt|	d  }d| }|s?|r)dnd|r.dnd d |r6d	nd
 |r<dnd
 }|rCtnt}||t|||| |||d S )Nz5A pending deprecation cannot have a scheduled removal.   zin zThe %(name)s %(obj_type)sz%(name)sz' will be deprecated in a future versionzG was deprecated in Matplotlib %(since)s and will be removed %(removal)sz Use %(alternative)s instead.r	   z %(addendum)s)funcnameobj_typesincer   alternativeaddendum)
ValueErrorsplitintPendingDeprecationWarningr   dict)r   messager   r   pendingr   r   r   macromeso_warning_clsr   r   r   _generate_deprecation_warning   s<   



	

r   r   r   r   r   r   r   r   c          
   
   C   s4   t | |||||||d}ddlm}	 |	|td dS )a  
    Display a standardized deprecation.

    Parameters
    ----------
    since : str
        The release at which this API became deprecated.
    message : str, optional
        Override the default deprecation message.  The ``%(since)s``,
        ``%(name)s``, ``%(alternative)s``, ``%(obj_type)s``, ``%(addendum)s``,
        and ``%(removal)s`` format specifiers will be replaced by the values
        of the respective arguments passed to this function.
    name : str, optional
        The name of the deprecated object.
    alternative : str, optional
        An alternative API that the user may use in place of the deprecated
        API.  The deprecation warning will tell the user about this alternative
        if provided.
    pending : bool, optional
        If True, uses a PendingDeprecationWarning instead of a
        DeprecationWarning.  Cannot be used together with *removal*.
    obj_type : str, optional
        The object type being deprecated.
    addendum : str, optional
        Additional text appended directly to the final message.
    removal : str, optional
        The expected removal version.  With the default (an empty string), a
        removal version is automatically computed from *since*.  Set to other
        Falsy values to not schedule a removal date.  Cannot be used together
        with *pending*.

    Examples
    --------
    ::

        # To warn of the deprecation of "matplotlib.name_of_module"
        warn_deprecated('1.4.0', name='matplotlib.name_of_module',
                        obj_type='module')
    r
      )warn_external)categoryN)r   r	   r"   r   )
r   r   r   r   r   r   r   r   warningr"   r   r   r   warn_deprecated5   s   *r%   c          	         s    ||||||f fdd	}|S )a  
    Decorator to mark a function, a class, or a property as deprecated.

    When deprecating a classmethod, a staticmethod, or a property, the
    ``@deprecated`` decorator should go *under* ``@classmethod`` and
    ``@staticmethod`` (i.e., `deprecated` should directly decorate the
    underlying callable), but *over* ``@property``.

    When deprecating a class ``C`` intended to be used as a base class in a
    multiple inheritance hierarchy, ``C`` *must* define an ``__init__`` method
    (if ``C`` instead inherited its ``__init__`` from its own base class, then
    ``@deprecated`` would mess up ``__init__`` inheritance when installing its
    own (deprecation-emitting) ``C.__init__``).

    Parameters are the same as for `warn_deprecated`, except that *obj_type*
    defaults to 'class' if decorating a class, 'attribute' if decorating a
    property, and 'function' otherwise.

    Examples
    --------
    ::

        @deprecated('1.4.0')
        def the_function_to_deprecate():
            pass
    c                    sv  ddl m ttr#	d u rd	jpjj}fdd}nDttfrQ	d u r0d	d p7jjj}G fdddt  fd	d}n	d u rWd
	p]jj}fdd}	
fddfdd}	t	
|pdd}d}
ddd rd dndfD }d| d|
|vr|
nd d d| }|s|d7 }||	|S )Nr   )classpropertyclassc                    s4   z| _ W n	 ty   Y nw t j|  _ S N)r   AttributeError	functoolswraps__init__wrappernew_doc)objr   r   finalize   s   
z/deprecated.<locals>.deprecate.<locals>.finalize	attributec                       sJ   e Zd Zd
 fdd	Z fddZ fddZfdd	Z  ZS )z;deprecated.<locals>.deprecate.<locals>._deprecated_propertyNc                    s.   |d us|d urt | r  t ||S r(   )
isinstancesuper__get__)selfinstanceowner)	__class__r&   emit_warningr   r   r5      s
   zCdeprecated.<locals>.deprecate.<locals>._deprecated_property.__get__c                    s   |d ur  t  ||S r(   )r4   __set__)r6   r7   valuer9   r:   r   r   r;      s   zCdeprecated.<locals>.deprecate.<locals>._deprecated_property.__set__c                    s   |d ur  t  |S r(   )r4   
__delete__)r6   r7   r=   r   r   r>      s   zFdeprecated.<locals>.deprecate.<locals>._deprecated_property.__delete__c                    s    dkr| d S d S )Nz<lambda>r   )r6   r8   set_namer   r   r   __set_name__   s   zHdeprecated.<locals>.deprecate.<locals>._deprecated_property.__set_name__r(   )r   r   r   r5   r;   r>   rA   __classcell__r   )r&   r:   r   )r9   r   _deprecated_property   s
    rC   c                    s    j jj|dS )N)fgetfsetfdeldoc)rD   rE   rF   )r   r/   )rC   r0   r   r   r1      s   functionc                    s   t  | } || _| S r(   )r*   r+   r   r-   )r   r   r   r1      s   c                
      s   t  d d S )Nr    )r%   r   )r   r   r   r   r   r   r   r   r   r   r:      s
   
z3deprecated.<locals>.deprecate.<locals>.emit_warningc                     s      | i |S r(   r   argskwargs)r:   r   r   r   r.      s   z.deprecated.<locals>.deprecate.<locals>.wrapperr	   
z
Notes
----- c                 S   s   g | ]}|r|  qS r   )strip).0tr   r   r   
<listcomp>   s    z1deprecated.<locals>.deprecate.<locals>.<listcomp>zUse z	 instead.z[*Deprecated*] z
.. deprecated:: z
   z\ )matplotlib._apir&   r3   typer,   r   r   propertyrD   inspectcleandocrN   join)r0   r   r   r   r   r   r   old_docr1   r.   notes_header
second_argr/   r   r   )rC   r   r   r&   r:   r   r   r   r0   r   r   r   	deprecate   sV   




zdeprecated.<locals>.deprecater   )	r   r   r   r   r   r   r   r   r\   r   r[   r   
deprecatedf   s   \r]   c                   @   s    e Zd ZdZdd Zdd ZdS )deprecate_privatize_attributeaT  
    Helper to deprecate public access to an attribute (or method).

    This helper should only be used at class scope, as follows::

        class Foo:
            attr = _deprecate_privatize_attribute(*args, **kwargs)

    where *all* parameters are forwarded to `deprecated`.  This form makes
    ``attr`` a property which forwards read and write access to ``self._attr``
    (same name but with a leading underscore), with a deprecation warning.
    Note that the attribute name is derived from *the name this helper is
    assigned to*.  This helper also works for deprecating methods.
    c                 O   s   t |i || _d S r(   )r]   
deprecator)r6   rJ   rK   r   r   r   r,      s   z&deprecate_privatize_attribute.__init__c              	      s0   t | | jt fdd fdd d d S )Nc                    s   t | d  S Nr   )getattrr6   r@   r   r   <lambda>   s    z<deprecate_privatize_attribute.__set_name__.<locals>.<lambda>c                    s   t | d  |S r`   )setattr)r6   r<   r@   r   r   rc      s    r@   )rd   r_   rT   )r6   r8   r   r   r@   r   rA      s   

z*deprecate_privatize_attribute.__set_name__N)r   r   r   r   r,   rA   r   r   r   r   r^      s    r^   c                    s   t t} du r|S t }|jvs$J dd j d|jv s5J dd j dt   fdd}|t|< |S )a  
    Decorator indicating that parameter *old* of *func* is renamed to *new*.

    The actual implementation of *func* should use *new*, not *old*.  If *old*
    is passed to *func*, a DeprecationWarning is emitted, and its value is
    used, even if *new* is also passed by keyword (this is to simplify pyplot
    wrapper functions, which always pass *new* explicitly to the Axes method).
    If *new* is also passed but positionally, a TypeError will be raised by the
    underlying function during argument binding.

    Examples
    --------
    ::

        @_api.rename_parameter("3.1", "bad_name", "good_name")
        def func(good_name): ...
    NMatplotlib internal error: z cannot be a parameter for () must be a parameter for c                     sL   |v rt dd j dd d	d ||<  | i |S )NzThe z parameter of z() has been renamed z since Matplotlib z7; support for the old name will be dropped %(removal)s.r   )r%   r   poprI   r   newoldr   r   r   r.   $  s   z!rename_parameter.<locals>.wrapper)	r*   partialrename_parameterrU   	signature
parametersr   r+   
DECORATORS)r   rl   rk   r   	decoratorro   r.   r   rj   r   rn     s$   
rn   c                   @   s   e Zd Zdd ZdS )_deprecated_parameter_classc                 C      dS )Nz<deprecated parameter>r   rb   r   r   r   __repr__8  s   z$_deprecated_parameter_class.__repr__N)r   r   r   ru   r   r   r   r   rs   7  s    rs   c                    s6  t jt	fi }du r|S ttdd j D djv rfj j}|tj	j
u |tj	ju scsc|tj	ju rGtjng jjfddj D d _ndnd tjs{J d	d
j ddd t  	f
dd}|t|< |S )aI  
    Decorator indicating that parameter *name* of *func* is being deprecated.

    The actual implementation of *func* should keep the *name* parameter in its
    signature, or accept a ``**kwargs`` argument (through which *name* would be
    passed).

    Parameters that come after the deprecated parameter effectively become
    keyword-only (as they cannot be passed positionally without triggering the
    DeprecationWarning on the deprecated parameter), and should be marked as
    such after the deprecation period has passed and the deprecated parameter
    is removed.

    Parameters other than *since*, *name*, and *func* are keyword-only and
    forwarded to `.warn_deprecated`.

    Examples
    --------
    ::

        @_api.delete_parameter("3.1", "unused")
        def func(used_arg, other_arg, unused, more_args): ...
    Nc                 s   s$    | ]}|j tjjkr|jV  qd S r(   )kindrU   	ParameterVAR_KEYWORDr   rO   paramr   r   r   	<genexpr>a  s    z#delete_parameter.<locals>.<genexpr>c                    s&   g | ]}|j  kr|jtd n|qS ))default)r   replace_deprecated_parameterry   r@   r   r   rQ   n  s    
z$delete_parameter.<locals>.<listcomp>rp   Fre   rg   rf   r   c                     s   t | kr|vr| i |S j| i |j}r-|r-t	dj dd nEr@|r@t	dj dd n2tfdd||i fD rrdd}t	ftd	j d
 rk d | n|d | i |S )Nz#Additional positional arguments to zS() are deprecated since %(since)s and support for them will be removed %(removal)s.rh   z Additional keyword arguments to c                 3   s$    | ]} |v o|  t kV  qd S r(   )r~   )rO   dr@   r   r   r{     s    z4delete_parameter.<locals>.wrapper.<locals>.<genexpr>zIf any parameter follows z5, they should be passed as keyword, not positionally.parameter of rf   rM   )r   r   r   )lenbind	argumentsgetr%   r   anyrepr)
inner_argsinner_kwargsr   deprecation_addendum
r   r   
is_varargsis_varkwargsrK   kwargs_namer   name_idxro   r   r   r   r.   ~  s>   
z!delete_parameter.<locals>.wrapper)r*   rm   delete_parameterrU   ro   nextrp   valuesrv   rw   VAR_POSITIONALrx   KEYWORD_ONLYmathinfindexr}   __signature__r   ri   r+   rq   )r   r   r   rK   rr   rv   r.   r   r   r   r   ?  s>   

  r   c                    s   t t}du r|S ttjjtjj jv r'j j	ks3J ddj
 dg j}|fdd|d D t fdd}j fd	dj D d
|_|t|< |S )a3  
    Decorator indicating that passing parameter *name* (or any of the following
    ones) positionally to *func* is being deprecated.

    When used on a method that has a pyplot wrapper, this should be the
    outermost decorator, so that :file:`boilerplate.py` can access the original
    signature.
    Nre   z/ must be a positional-or-keyword parameter for rf   c                    s    g | ]}j | j kr|qS r   )rp   rv   )rO   r   )POKro   r   r   rQ     s    z%make_keyword_only.<locals>.<listcomp>c                     s4   t | krtdd j dd  | i |S )NzPassing the %(name)s %(obj_type)s positionally is deprecated since Matplotlib %(since)s; the parameter will become keyword-only %(removal)s.r   rf   )r   r   r   )r   r%   r   rI   )r   r   r   r   r   r   r.     s   z"make_keyword_only.<locals>.wrapperc                    s&   g | ]}|j v r|j d n|qS ))rv   )r   r}   ry   )KWOkwonlyr   r   rQ     s    r   )r*   rm   make_keyword_onlyrU   ro   rw   POSITIONAL_OR_KEYWORDr   rp   rv   r   r   r+   r}   r   r   rq   )r   r   r   rr   namesr.   r   )r   r   r   r   r   r   ro   r   r   r     s,   




r   )allow_emptyc          	      K   s   dd }dd }| j }t||}t|t|rt|tr| n| |}||krI|r;tt|dddd|jj|jjfvrItd
i |dd	| |S dS )a  
    Return ``obj.method`` with a deprecation if it was overridden, else None.

    Parameters
    ----------
    method
        An unbound method, i.e. an expression of the form
        ``Class.method_name``.  Remember that within the body of a method, one
        can always use ``__class__`` to refer to the class that is currently
        being defined.
    obj
        Either an object of the class where *method* is defined, or a subclass
        of that class.
    allow_empty : bool, default: False
        Whether to allow overrides by "empty" methods without emitting a
        warning.
    **kwargs
        Additional parameters passed to `warn_deprecated` to generate the
        deprecation warning; must at least include the "since" key.
    c                   S   s   d S r(   r   r   r   r   r   empty      z(deprecate_method_override.<locals>.emptyc                   S   rt   )rG   Nr   r   r   r   r   empty_with_docstring  r   z7deprecate_method_override.<locals>.empty_with_docstring__code__Nco_codemethod)r   r   r   )r   ra   r3   rS   r5   r   r   r%   )	r   r0   r   rK   r   r   r   bound_child
bound_baser   r   r   deprecate_method_override  s.   
r   c                   c   sB    t   t dt d V  W d    d S 1 sw   Y  d S )Nignore)warningscatch_warningssimplefilterr   r   r   r   r   'suppress_matplotlib_deprecation_warning  s
   
"r   )r	   r	   r	   Fr	   r	   r(   )r   
contextlibr*   rU   r   r   DeprecationWarningr   r   r%   r]   r^   rq   rn   rs   r~   r   r   r   contextmanagerr   r   r   r   r   <module>   s8    1|
3

d0*