
    ^jL                    r   d dl mZ d dlZd dlZd dlZd dlZd dlmZ d dlm	Z	m
Z
mZ  G d de      Z	 d	 	 	 	 	 	 	 	 	 	 	 ddZee_         ej                   d      d	k(  r ej"                  d
e       n ej"                  de       ddZd df	 	 	 	 	 	 	 	 	 	 	 ddZ ed      Z G d de
e         ZdddZy)    )annotationsN)Callable)AnyGenericTypeVarc                      e Zd ZdZy)SupervisionWarningszSupervision warning category.
    Set the deprecation warnings visibility for Supervision library.
    You can set the environment variable SUPERVISON_DEPRECATION_WARNING to '0' to
    disable the deprecation warnings.
    N)__name__
__module____qualname____doc__     e/var/www/ramen.bs-engineer-server.com/venv/lib/python3.12/site-packages/supervision/utils/internal.pyr	   r	      s     	r   r	   c                &    |j                    d|  dS )zw
    Format a warning the same way as the default formatter, but also include the
    category name in the output.
    z: 
)r
   )messagecategoryfilenamelinenolines        r   format_warningr      s      7)2..r   SUPERVISON_DEPRECATION_WARNING0ignorealwaysc                <    t        j                  | t        d       y)z
    Issue a warning that a function is deprecated.

    Args:
        message: The message to display when the function is called.
       )r   
stacklevelN)warningswarnr	   r   s    r   warn_deprecatedr#   +   s     MM'$7AFr   c                    | S Nr   )xs    r   <lambda>r'   8   s    1 r   z]Warning: '{old_parameter}' in '{function_name}' is deprecated: use '{new_parameter}' instead.c                $     d fd}|S )aD  
    A decorator to mark a function's parameter as deprecated and issue a warning when
    used.

    Args:
        old_parameter: The name of the deprecated parameter.
        new_parameter: The name of the parameter that should be used instead.
        map_function: A function used to map the value of the old
            parameter to the new parameter. Defaults to the identity function.
        warning_message: The warning message to be displayed when the
            deprecated parameter is used. Defaults to a generic warning message with
            placeholders for the old parameter, new parameter, and function name.
        **message_kwargs: Additional keyword arguments that can be used to customize
            the warning message.

    Returns:
        A decorator function that can be applied to mark a function's
            parameter as deprecated.

    Examples:
        ```pycon
        >>> from supervision.utils.internal import deprecated_parameter
        >>> import warnings
        >>> @deprecated_parameter(
        ...     old_parameter='old_name',
        ...     new_parameter='new_name'
        ... )
        ... def example_function(new_name=None):
        ...     return new_name
        >>> # Calling with new parameter works normally
        >>> example_function(new_name='value')
        'value'
        >>> # Calling with old parameter triggers warning but still works
        >>> with warnings.catch_warnings(record=True):
        ...     result = example_function(old_name='deprecated_value')
        ...     print(result)
        deprecated_value

        ```
    c                P     t        j                         d fd       }|S )Nc            	         |v r| r:t        | d   d      r+| d   j                  j                  }| dj                   }nj                  }t         	j                  d|d        |j                              |<    | i |S )Nr   	__class__.)function_nameold_parameternew_parameterr"   r   )hasattrr+   r
   r#   formatpop)
argskwargs
class_namer-   funcmap_functionmessage_kwargsr/   r.   warning_messages
       r   wrapperz8deprecated_parameter.<locals>.decorator.<locals>.wrapperg   s    &GDG[9!%a!2!2!;!;J'1l!DMM?$CM$(MMM2O22 &3&3&3 )	 )5VZZ5N(O}%(((r   )r3   r   r4   r   returnr   )	functoolswraps)r6   r:   r7   r8   r/   r.   r9   s   ` r   	decoratorz'deprecated_parameter.<locals>.decoratorf   s*    			) 	) 
	)* r   )r6   Callable[..., Any]r;   r?   r   )r.   r/   r7   r9   r8   r>   s   ````` r   deprecated_parameterr@   5   s    b 2 r   Tc                  "    e Zd ZdZddZdddZy)classpropertya  
    A decorator that combines @classmethod and @property.
    It allows a method to be accessed as a property of the class,
    rather than an instance, similar to a classmethod.

    Usage:
        @classproperty
        def my_method(cls):
            ...
    c                    || _         y)z^
        Args:
            The function that is called when the property is accessed.
        N)fget)selfrE   s     r   __init__zclassproperty.__init__   s    
 	r   Nc                R    | j                   t        d      | j                  |      S )a  
        Override the __get__ method to return the result of the function call.

        Args:
            owner_self: The instance through which the attribute was accessed, or None.
                Irrelevant for class properties.
            owner_cls: The class through which the attribute was accessed.

        Returns:
            The result of calling the function stored in 'fget' with 'owner_cls'.
        zunreadable attribute)rE   AttributeError)rF   
owner_self	owner_clss      r   __get__zclassproperty.__get__   s)     99 !788yy##r   )rE   zCallable[..., T]r%   )rJ   r   rK   ztype | Noner;   rA   )r
   r   r   r   rG   rL   r   r   r   rC   rC      s    	$r   rC   c                j   t        | t              rt        d      t        j                  |       D ch c]#  \  }}t        |      s|j                  d      s|% }}}|sFt        j                  | j                        D ch c]  \  }}t        |t              r| }}}||z  }|S c c}}w c c}}w )aN  
    Get the public variables of a class instance.

    Args:
        instance: The instance of a class
        include_properties: Whether to include properties in the result

    Usage:
        ```pycon
        >>> from supervision.utils.internal import get_instance_variables
        >>> import numpy as np
        >>> from supervision import Detections
        >>> detections = Detections(xyxy=np.array([[1, 2, 3, 4]]))
        >>> variables = get_instance_variables(detections)
        >>> 'xyxy' in variables
        True
        >>> 'data' in variables
        True

        ```
    z0Only class instances are supported, not classes._)	
isinstancetype
ValueErrorinspect
getmemberscallable
startswithr+   property)instanceinclude_propertiesnamevalfields
propertiess         r   get_instance_variablesr]      s    , (D!KLL !++H5D#}T__S%9 	F   %//0B0BC
c#x( 

 

 	*M
s   (B)B/r%   )r   zWarning | strr   ztype[Warning]r   strr   intr   z
str | Noner;   r^   )r   r^   r;   None)r.   r^   r/   r^   r7   Callable[[Any], Any]r9   r^   r8   r   r;   ra   )F)rW   r   rX   boolr;   zset[str])
__future__r   r<   rR   osr    collections.abcr   typingr   r   r   Warningr	   r   formatwarninggetenvsimplefilterr#   r@   rA   rC   r]   r   r   r   <module>rk      s%   "   	  $ ( (	' 	 /// / 	/
 / 	/ ( 299-.#5H($78H($78G *51	JJJ 'J 	J J JZ CL!$GAJ !$H'r   