o
    i                     @   sr  d Z ddlZddlZddlZddlmZ ddlmZ ddl	m
Z
mZmZ ddlZddlZddlmZmZ ddlmZmZmZmZmZ e Ze
rNddlmZ dd	ee d
dfddZG dd dejjZ ded
ej!fddZ"G dd deeZ#eeej$ddf Z%ee#ej&ddf Z'eee ej&ddf Z(ee)ej&ddf Z*eee ej&ddf Z+d ddZ,d ddZ-dS )!z*Contains CLI utilities (styling, helpers).    N)Enum)Path)TYPE_CHECKING	AnnotatedOptional)__version__	constants)ANSIget_sessionhf_raise_for_statusinstallation_methodloggingHfApitokenreturnr   c                 C   s   ddl m} || dtdS )Nr   r   zhuggingface-cli)r   library_namelibrary_version)huggingface_hub.hf_apir   r   )r   r    r   d/var/www/html/karishye-ai-python/venv/lib/python3.10/site-packages/huggingface_hub/cli/_cli_utils.py
get_hf_api%   s   r   c                   @   s(   e Zd ZdZdejdee fddZdS )AlphabeticalMixedGroupzP
    Typer Group that lists commands and sub-apps mixed and alphabetically.
    ctxr   c                 C   s   t | j S N)sortedcommandskeys)selfr   r   r   r   list_commands4   s   z$AlphabeticalMixedGroup.list_commandsN)	__name__
__module____qualname____doc__clickContextliststrr   r   r   r   r   r   /   s    r   helpc              	   C   s   t j| ddtd d ddS )NTF)r(   add_completionno_args_is_helpclsrich_markup_moderich_help_panelpretty_exceptions_enable)typerTyperr   r(   r   r   r   typer_factory9   s   r2   c                   @   s   e Zd ZdZdZdZdS )RepoTypemodeldatasetspaceN)r    r!   r"   r4   r5   r6   r   r   r   r   r3   F   s    r3   z/The ID of the repo (e.g. `username/repo-name`).r1   z2The type of repository (model, dataset, or space).zJA User Access Token generated from https://huggingface.co/settings/tokens.zfWhether to create a private repo if repo doesn't exist on the Hub. Ignored if the repo already exists.zDGit revision id which can be a branch name, a tag, or a commit hash.c                   C   s0   zt   W dS  ty   tjddd Y dS w )a  
    Check whether a newer version of `huggingface_hub` is available on PyPI.

    If a newer version is found, notify the user and suggest updating.
    If current version is a pre-release (e.g. `1.0.0.rc1`), or a dev version (e.g. `1.0.0.dev1`), no check is performed.

    This function is called at the entry point of the CLI. It only performs the check once every 24 hours, and any error
    during the check is caught and logged, to avoid breaking the CLI.
    z$Error while checking for CLI update.T)exc_infoN)_check_cli_update	Exceptionloggerdebugr   r   r   r   check_cli_updatet   s
   
r<   c                     s  t jd t fdddD rd S tjtjr+tj	tj} t

 |  dk r+d S ttj  t jddd}t| | }|d	 d
 } |krt }|dkrVd}n|dkrbtjdkrbd}n	|dkrid}nd}ttd| d  dt| d d S d S )Nhuggingface_hubc                 3   s    | ]}| v V  qd S r   r   ).0tagcurrent_versionr   r   	<genexpr>   s    z$_check_cli_update.<locals>.<genexpr>)rcdeviQ z*https://pypi.org/pypi/huggingface_hub/json   )timeoutinfoversionbrewzbrew upgrade huggingface-clihf_installerntzNpowershell -NoProfile -Command "iwr -useb https://hf.co/cli/install.ps1 | iex"z0curl -LsSf https://hf.co/cli/install.sh | bash -zpip install -U huggingface_hubz"A new version of huggingface_hub (z&) is available! You are using version z.
To update, run: 
)	importlibmetadatarH   anyospathexistsr   CHECK_FOR_UPDATE_DONE_PATHgetmtimetimer   touchr
   getr   jsonr   namer$   echor	   yellowbold)mtimeresponsedatalatest_versionmethodupdate_commandr   r@   r   r8      s>   r8   r   )r   N).r#   importlib.metadatarM   rP   rU   enumr   pathlibr   typingr   r   r   r$   r/   r=   r   r   huggingface_hub.utilsr	   r
   r   r   r   
get_loggerr:   r   r   r'   r   core
TyperGroupr   r0   r2   r3   Argument	RepoIdArgOptionRepoTypeOptTokenOptbool
PrivateOptRevisionOptr<   r8   r   r   r   r   <module>   sn   


