
    ai                        d Z ddl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
 ddlmZmZmZmZmZ ddlZddlZddlmZmZmZmZmZ ddlmZmZmZmZmZ  ej>                         Z erddl!m"Z" d'd	ee#   d
dfdZ$ G d dejJ                  jL                        Z'de#d
ejP                  fdZ) G d de#e      Z*ee# ejV                  d      f   Z,ee* ejZ                  d      f   Z.eee#    ejZ                  d      f   Z/eee0    ejZ                  d      f   Z1eee#    ejZ                  d      f   Z2ee3 ejZ                  d      f   Z4eee#    ejZ                  d      f   Z5eee6e#       ejZ                  d      f   Z7eee#    ejZ                  d      f   Z8deeeef   d
e9e#e:f   fdZ;de6e#   fd Z<d!ed"   d
dfd#Z=d!ed"   d
dfd$Z>d
e#fd%Z?d
e#fd&Z@y)(z*Contains CLI utilities (styling, helpers).    N)Enum)Path)TYPE_CHECKING	AnnotatedLiteralOptionalUnion)DatasetInfo	ModelInfo	SpaceInfo__version__	constants)ANSIget_sessionhf_raise_for_statusinstallation_methodloggingHfApitokenreturnr   c                 ,    ddl m}  || dt              S )Nr   r   zhuggingface-cli)r   library_namelibrary_version)huggingface_hub.hf_apir   r   )r   r   s     h/home/obispo/Crisostomo_bridge/mision_env/lib/python3.12/site-packages/huggingface_hub/cli/_cli_utils.py
get_hf_apir   '   s    ,u+<kZZ    c                   :    e Zd ZdZdej
                  dee   fdZy)AlphabeticalMixedGroupzP
    Typer Group that lists commands and sub-apps mixed and alphabetically.
    ctxr   c                 H    t        | j                  j                               S N)sortedcommandskeys)selfr!   s     r   list_commandsz$AlphabeticalMixedGroup.list_commands6   s    dmm((*++r   N)	__name__
__module____qualname____doc__clickContextliststrr(    r   r   r    r    1   s"    , ,49 ,r   r    helpc           	      B    t        j                  | ddt        d d d      S )NTF)r2   add_completionno_args_is_helpclsrich_markup_moderich_help_panelpretty_exceptions_enable)typerTyperr    r2   s    r   typer_factoryr=   ;   s(    ;;"!&	 	r   c                       e Zd ZdZdZdZy)RepoTypemodeldatasetspaceN)r)   r*   r+   r@   rA   rB   r1   r   r   r?   r?   H   s    EGEr   r?   z/The ID of the repo (e.g. `username/repo-name`).r<   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.zLimit the number of results.z!Filter by author or organization.zHFilter by tags (e.g. 'text-classification'). Can be used multiple times.zSearch query.infoc           	          t        j                  |       j                         D ci c]4  \  }}|-|t        |t        j                        r|j                         n|6 c}}S c c}}w )z9Convert repo info dataclasses to json-serializable dicts.)dataclassesasdictitems
isinstancedatetime	isoformat)rC   kvs      r   repo_info_to_dictrM      s]      &&t,224Aq= 	
Jq(*;*;<1;;=!C  s   9A$valid_propertiesc                 V     dt         t           dt         t        t              f fd}|S )zJCreate a callback to parse and validate comma-separated expand properties.valuer   c           	          | y | j                  d      D cg c]  }|j                          }}|D ]0  }|vst        j                  d| ddj	                                |S c c}w )N,zInvalid expand property: 'z'. Valid values are: z, )splitstripr:   BadParameterjoin)rP   p
propertiesproprN   s       r   _parse_expand_propertiesz?make_expand_properties_parser.<locals>._parse_expand_properties   s    =).S)9:Aaggi:
: 	D++((06KDIIVfLgKhi 	
  ;s   A()r   r0   r/   )rN   rZ   s   ` r   make_expand_properties_parserr[      s+    	 	(49:M 	 $#r   library)huggingface_hubtransformersc                 h    	 t        |        y# t        $ r t        j                  dd       Y yw xY w)aB  
    Check whether a newer version of a library 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.

    Args:
        library: The library to check for updates. Currently supports "huggingface_hub" and "transformers".
    z$Error while checking for CLI update.T)exc_infoN)_check_cli_update	Exceptionloggerdebug)r\   s    r   check_cli_updatere      s2    L'" L;dKLs     11c                 b   t         j                  j                  |       t        fddD              ry t        j
                  j                  t        j                        rHt        j
                  j                  t        j                        }t        j                         |z
  dk  ry t        t        j                        j                  j                  dd       t        t        j                        j                          t               j!                  d|  dd	      }t#        |       |j%                         }|d
   d   }|k7  rc| dk(  rt'               }n
t)               }t+        j,                  t/        j0                  d|  d| d dt/        j2                  |       d	             y y )Nc              3   &   K   | ]  }|v  
 y wr#   r1   ).0tagcurrent_versions     r   	<genexpr>z$_check_cli_update.<locals>.<genexpr>   s     
;c3/!
;s   )rcdeviQ T)parentsexist_okzhttps://pypi.org/pypi/z/json   )timeoutrC   versionr]   zA new version of z (z&) is available! You are using version z.
To update, run: 
)	importlibmetadatarr   anyospathexistsr   CHECK_FOR_UPDATE_DONE_PATHgetmtimetimer   parentmkdirtouchr   getr   json#_get_huggingface_hub_update_command _get_transformers_update_commandr-   echor   yellowbold)r\   mtimeresponsedatalatest_versionupdate_commandrj   s         @r   ra   ra      sl   ((009O 
;]
;; 
ww~~i::;  !E!EFIIK%9, 		-	-.55;;DSW;X	-	-.446 }  #9'%!HRS TH!==?D&\),N .(''@BN=?N

KK#G9B~.> ?))8(9 :##'99^#<"=RA	
 )r   c                  b    t               } | dk(  ry| dk(  rt        j                  dk(  ry| dk(  ryy)z-Return the command to update huggingface_hub.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_hubr   rw   namemethods    r   r   r      s8     "F-	>	!bggo_	>	!A/r   c                  V    t               } | dk(  rt        j                  dk(  ry| dk(  ryy)z*Return the command to update transformers.r   r   z`powershell -NoProfile -Command "iwr -useb https://hf.co/cli/install.ps1 | iex" -WithTransformerszHcurl -LsSf https://hf.co/cli/install.sh | bash -s -- --with-transformerszpip install -U transformersr   r   s    r   r   r      s-     "FBGGtOq	>	!Y,r   r#   )Ar,   rE   rI   importlib.metadatart   rw   r|   enumr   pathlibr   typingr   r   r   r   r	   r-   r:   r]   r
   r   r   r   r   huggingface_hub.utilsr   r   r   r   r   
get_loggerrc   r   r   r0   r   core
TyperGroupr    r;   r=   r?   Argument	RepoIdArgOptionRepoTypeOptTokenOptbool
PrivateOptRevisionOptintLimitOpt	AuthorOptr/   	FilterOpt	SearchOptdictobjectrM   r[   re   ra   r   r   r1   r   r   <module>r      s   1    	    E E   U U f f 
			 ,[hsm [w [,UZZ22 ,
 
 
sD  ENN>	 ELLA SMELLY TNELLu
 SMELLS ELL457
 SMELL9:<	
 T#YELL`ac	
 SMELLo&(	E)[)"CD cSYkIZ $DI $(Lg&GH LT L($
w'HI $
d $
N
0S 
0-# -r   