o
    TZh|                     @   s   d dl Z d dlZd dlZd dlmZ d dlmZmZ ddlm	Z	 e
 ae	eZddee fddZG d	d
 d
e jZG dd de jedZdS )    N)wraps)CallableOptional   )
get_loggerhelp_messagec                    s   dt f fdd}|S )zDecorator to mark a class or a function as deprecated.

    Args:
        help_message (:obj:`str`, optional): An optional message to guide the user on how to
            switch to non-deprecated usage of the library.
    deprecated_class_or_functionc                    s   t | r| j | j}n|   j}|dkr|n jdd }r+| dd  ndt  fdd}d	|_t | rE|| _| S |S )
N__init__.zI is deprecated and will be removed in the next major version of datasets.  c                     s8   t  }|tvrtjtdd t|  | i |S )N   )category
stacklevel)hash_emitted_deprecation_warningswarningswarnFutureWarningadd)argskwargsZ	func_hashZdeprecated_functionZwarning_msg W/var/www/html/lang_env/lib/python3.10/site-packages/datasets/utils/deprecation_utils.pywrapper(   s
   
z.deprecated.<locals>.decorator.<locals>.wrapper
deprecated)inspectisclassr	   __name____qualname__splitr   Z_decorator_name_)r   namer   r   r   r   	decorator   s"   

zdeprecated.<locals>.decorator)r   )r   r%   r   r$   r   r      s   "r   c                       sF   e Zd ZdZ fddZ fddZdddddd fd	d
Z  ZS )OnAccessz\
    Enum metaclass that calls a user-specified function whenever a member is accessed.
    c                    s*   t  |}t|tjr|jr|  |S N)super__getattribute__
isinstanceenumEnum
_on_access)clsr#   obj	__class__r   r   r)   @   s   zOnAccess.__getattribute__c                    s   t  |}|jr|  |S r'   )r(   __getitem__r-   )r.   r#   memberr0   r   r   r2   F   s   zOnAccess.__getitem__Nr   modulequalnametypestartc                   s6   t  j||||||d}t|tjr|jr|  |S )Nr4   )r(   __call__r*   r+   r,   r-   )r.   valuenamesr5   r6   r7   r8   r/   r0   r   r   r9   L   s   zOnAccess.__call__r'   )r    
__module__r!   __doc__r)   r2   r9   __classcell__r   r   r0   r   r&   ;   s
    "r&   c                   @   s,   e Zd ZdZdd Zedd Zdd ZdS )	DeprecatedEnumzQ
    Enum class that calls `deprecate` method whenever a member is accessed.
    c                 C   s   t | }||_|j|_|S r'   )object__new___value_	deprecater-   )r.   r:   r3   r   r   r   rA   X   s   
zDeprecatedEnum.__new__c                 C   s   dS )Nr   r   )selfr   r   r   r   ^   s   zDeprecatedEnum.help_messagec                 C   s:   | j r	d| j  nd}tjd| jj d| tdd d S )Nr   r   'zJ' is deprecated and will be removed in the next major version of datasets.   )r   )r   r   r   __objclass__r    r   )rD   r   r   r   r   rC   b   s   
zDeprecatedEnum.deprecateN)r    r<   r!   r=   rA   propertyr   rC   r   r   r   r   r?   S   s    
r?   )	metaclassr'   )r+   r   r   	functoolsr   typingr   r   loggingr   setr   r    loggerstrr   EnumMetar&   r,   r?   r   r   r   r   <module>   s    -