U
    -e\                     @   sv  d Z ddlZddlZddlmZmZmZmZmZmZm	Z	m
Z
 ddlmZ ddlmZ ejejej
ejejdZej
Zdd Zed	d
dZejd	ddZdd	ddZdd	ddZd1ee ejdddZed	ddZeddddZdd Zdd Zdd Zd d! Z dd	d"d#Z!dd	d$d%Z"e  G d&d' d'Z#d(a$G d)d* d*Z%e% Ze&d	d+d,Z'd-d. Z(d/d0 Z)dS )2z Logging utilities.     N)CRITICALDEBUGERRORFATALINFONOTSETWARNWARNING)Optional)auto)debuginfowarningerrorcriticalc               	   C   sH   t dd} | rD| tkr t|  S t d|  ddt   tS )z
    If DATASETS_VERBOSITY env var is set to one of the valid choices return that as the new default level.
    If it is not - fall back to ``_default_log_level``
    ZDATASETS_VERBOSITYNz"Unknown option DATASETS_VERBOSITY=z, has to be one of: z, )	osgetenv
log_levelslogging	getLoggerr   joinkeys_default_log_level)Zenv_level_str r   W/var/www/html/Darija-Ai-Train/env/lib/python3.8/site-packages/datasets/utils/logging.py_get_default_logging_level,   s    r   )returnc                   C   s   t dd S )N.r   )__name__splitr   r   r   r   _get_library_name=   s    r    c                   C   s   t t S N)r   r   r    r   r   r   r   _get_library_root_loggerA   s    r"   c                  C   s$   t  } | t  | t  d S r!   )r"   
addHandlerr   StreamHandlersetLevelr   Zlibrary_root_loggerr   r   r   _configure_library_root_loggerE   s    r'   c                  C   s   t  } | tj d S r!   )r"   r%   r   r   r&   r   r   r   _reset_library_root_loggerL   s    r(   )namer   c                 C   s   | dkrt  } t| S )z_Return a logger with the specified name.
    This function can be used in dataset scripts.
    N)r    r   r   )r)   r   r   r   
get_loggerQ   s    r*   c                   C   s
   t   S )a  Return the current level for the HuggingFace datasets library's root logger.
    Returns:
        Logging level, e.g., `datasets.logging.DEBUG` and `datasets.logging.INFO`.

    <Tip>

        HuggingFace datasets library has following logging levels:
        - `datasets.logging.CRITICAL`, `datasets.logging.FATAL`
        - `datasets.logging.ERROR`
        - `datasets.logging.WARNING`, `datasets.logging.WARN`
        - `datasets.logging.INFO`
        - `datasets.logging.DEBUG`

    </Tip>
    )r"   getEffectiveLevelr   r   r   r   get_verbosityZ   s    r,   )	verbosityr   c                 C   s   t  |  dS )zSet the level for the Hugging Face Datasets library's root logger.
    Args:
        verbosity:
            Logging level, e.g., `datasets.logging.DEBUG` and `datasets.logging.INFO`.
    N)r"   r%   )r-   r   r   r   set_verbositym   s    r.   c                   C   s   t tS )zSet the level for the Hugging Face datasets library's root logger to `INFO`.

    This will display most of the logging information and tqdm bars.

    Shortcut to `datasets.logging.set_verbosity(datasets.logging.INFO)`.
    )r.   r   r   r   r   r   set_verbosity_infov   s    r/   c                   C   s   t tS )zSet the level for the Hugging Face datasets library's root logger to `WARNING`.

    This will display only the warning and errors logging information and tqdm bars.

    Shortcut to `datasets.logging.set_verbosity(datasets.logging.WARNING)`.
    )r.   r	   r   r   r   r   set_verbosity_warning   s    r0   c                   C   s   t tS )zSet the level for the Hugging Face datasets library's root logger to `DEBUG`.

    This will display all the logging information and tqdm bars.

    Shortcut to `datasets.logging.set_verbosity(datasets.logging.DEBUG)`.
    )r.   r   r   r   r   r   set_verbosity_debug   s    r1   c                   C   s   t tS )zSet the level for the Hugging Face datasets library's root logger to `ERROR`.

    This will display only the errors logging information and tqdm bars.

    Shortcut to `datasets.logging.set_verbosity(datasets.logging.ERROR)`.
    )r.   r   r   r   r   r   set_verbosity_error   s    r2   c                   C   s   dt  _dS )zjDisable propagation of the library log outputs.
    Note that log propagation is disabled by default.
    FNr"   	propagater   r   r   r   disable_propagation   s    r5   c                   C   s   dt  _dS )zEnable propagation of the library log outputs.
    Please disable the Hugging Face datasets library's default handler to prevent double logging if the root logger has
    been configured.
    TNr3   r   r   r   r   enable_propagation   s    r6   c                   @   s8   e Zd ZdZdd Zdd Zdd Zdd	 Zd
d ZdS )	EmptyTqdmz%Dummy tqdm which doesn't do anything.c                 O   s   |r|d nd | _ d S )Nr   )	_iteratorselfargskwargsr   r   r   __init__   s    zEmptyTqdm.__init__c                 C   s
   t | jS r!   )iterr8   r:   r   r   r   __iter__   s    zEmptyTqdm.__iter__c                 C   s   dd }|S )zReturn empty function.c                  _   s   d S r!   r   )r;   r<   r   r   r   empty_fn   s    z'EmptyTqdm.__getattr__.<locals>.empty_fnr   )r:   _rA   r   r   r   __getattr__   s    zEmptyTqdm.__getattr__c                 C   s   | S r!   r   r?   r   r   r   	__enter__   s    zEmptyTqdm.__enter__c                 C   s   d S r!   r   )r:   type_value	tracebackr   r   r   __exit__   s    zEmptyTqdm.__exit__N)	r   
__module____qualname____doc__r=   r@   rC   rD   rH   r   r   r   r   r7      s   r7   Tc                   @   s2   e Zd ZddddZdd Zdd Zd	d
 ZdS )	_tqdm_clsF)disablec                O   s"   t r|stj||S t||S d S r!   )_tqdm_activetqdm_libtqdmr7   )r:   rM   r;   r<   r   r   r   __call__   s    z_tqdm_cls.__call__c                 O   s   d | _ trtjj||S d S r!   )_lockrN   rO   rP   set_lockr9   r   r   r   rS      s    z_tqdm_cls.set_lockc                 C   s   t rtj S d S r!   )rN   rO   rP   get_lockr?   r   r   r   rT      s    z_tqdm_cls.get_lockc                 C   s6   z| j |= W n$ tk
r0   |dkr,t|Y nX dS )z;fix for https://github.com/huggingface/datasets/issues/6066rR   N)__dict__KeyErrorAttributeError)r:   attrr   r   r   __delattr__   s
    z_tqdm_cls.__delattr__N)r   rI   rJ   rQ   rS   rT   rY   r   r   r   r   rL      s   rL   c                   C   s   t tS )zCReturn a boolean indicating whether tqdm progress bars are enabled.)boolrN   r   r   r   r   is_progress_bar_enabled   s    r[   c                   C   s   da dS )zEnable tqdm progress bar.TNrN   r   r   r   r   enable_progress_bar   s    r]   c                   C   s   da dS )zDisable tqdm progress bar.FNr\   r   r   r   r   disable_progress_bar   s    r^   )N)*rK   r   r   r   r   r   r   r   r   r   r	   typingr
   rP   r   rO   r   r   r   strr    Loggerr"   r'   r(   r*   intr,   r.   r/   r0   r1   r2   r5   r6   r7   rN   rL   rZ   r[   r]   r^   r   r   r   r   <module>   sD   (
		



	