o
    2j                     @   s|  U d Z ddlZddlmZ ddlmZmZmZmZm	Z	m
Z
mZmZmZmZmZmZmZmZ dedefddZde	defd	d
ZdedefddZdedefddZdedefddZdedefddZdedefddZdedefddZedd e	eeeeeeeedd edd eeeeedd e
dd edd edd eeeeiZeee  edef f e!d < de dedB fd!d"Z"dS )#zCLI error handling utilities.    N)Callable)BucketNotFoundErrorCLIErrorCLIExtensionInstallErrorEntryNotFoundErrorGatedRepoErrorHfHubHTTPError
HfUriErrorLocalEntryNotFoundErrorLocalTokenNotFoundErrorOfflineModeIsEnabled	OIDCErrorRemoteEntryNotFoundErrorRepositoryNotFoundErrorRevisionNotFoundErrorerrorreturnc                 C   sD   | j r| j  nd}| jr| d| j d}n| d}|d7 }|S )N
Repository 'z' not found.z not found.ze If the repo is private, make sure you are authenticated and your token has the required permissions.)	repo_type
capitalizerepo_id)r   labelmsg r   V/var/www/html/whisper/venv/lib/python3.10/site-packages/huggingface_hub/cli/_errors.py_format_repo_not_found%   s   
r   c                 C   s:   | j r| j nd}| jrd|  d| j dS d| dS )N
repositoryzAccess denied. r   z' requires approval.zAccess denied. This z requires approval.)r   r   r   r   r   r   r   r   _format_gated_repo/   s   r   c                 C   s   | j r
d| j  dS dS )NzBucket 'zs' not found. If the bucket is private, make sure you are authenticated and your token has the required permissions.zBucket not found. Check the bucket id (namespace/name). If the bucket is private, make sure you are authenticated and your token has the required permissions.)	bucket_idr   r   r   r   _format_bucket_not_found6   s   r"   c                 C   sd   | j r| j nd}| jrt| jjnd }| jr!d| d| j d}nd| d}|r0|d| 7 }|S )Nr   zFile not found in r   '..z
URL: )r   responsestrurlr   )r   r   r'   r   r   r   r   _format_entry_not_found<   s   r(   c                 C   s"   | j }|d urd| S d|  S )NzLocal entry not found. )	__cause__)r   causer   r   r   _format_local_entry_not_foundH   s   

r+   c                 C   s6   | j r| j nd}| jrd| d| j dS d| dS )Nr   zRevision not found in r   r#   z. Check the revision parameter.)r   r   r   r   r   r   _format_revision_not_foundO   s   r,   c                 C      t | S )z%No traceback, just the error message.r&   r!   r   r   r   _format_cli_errorV   s   r/   c                 C   s<   | j durdtt| j | j | j jnd}| d|  S )a0  Format a CLI extension installation error.

    The error is likely to be a tricky subprocess error to investigate. In this specific case we want to format the
    traceback of the root cause while keeping the "nicely formatted" error message of the CLIExtensionInstallError
    as a 1-line message.
    N 
)r)   join	tracebackformat_exceptiontype__traceback__)r   cause_tbr   r   r   #_format_cli_extension_install_error[   s
   
	 r8   c                 C   r-   Nr.   r!   r   r   r   <lambda>k       r:   c                 C   s   dS )Nz)Not logged in. Run 'hf auth login' first.r   )_r   r   r   r:   q   s    c                 C   
   d|  S )NzOIDC Exchange failed. r   r!   r   r   r   r:   r      
 c                 C   r-   r9   r.   r!   r   r   r   r:   u   r;   c                 C   r-   r9   r.   r!   r   r   r   r:   v   r;   c                 C   s   d| j  d| j S )NzInvalid HF URI: z. )urir   r!   r   r   r   r:   w   s    c                 C   r=   )NzInvalid value. r   r!   r   r   r   r:   x   r>   .CLI_ERROR_MAPPINGSc                 C   s,   t  D ]\}}t| |r||   S qd S r9   )r@   items
isinstance)r   exc_type	formatterr   r   r   format_known_exception~   s
   
rE   )#__doc__r3   collections.abcr   huggingface_hub.errorsr   r   r   r   r   r   r	   r
   r   r   r   r   r   r   r&   r   r   r"   r(   r+   r,   r/   r8   
ValueErrorr@   dictr5   	Exception__annotations__rE   r   r   r   r   <module>   s:   @
 