
    QЦi8N                        S r SSKrSSKrSSKrSSKrSSKrSSKrSSKrSSK	J
r
  SSKJr  SSKJrJrJrJrJrJrJrJrJr  SSKrSSKrSSKJrJr  SSKJrJrJrJ r J!r!J"r"  \!RF                  " 5       r$Sr%\(       a  SS	K&J'r'  SRS
\\(   SS4S jjr)Sr*SRS\+\(   S\\(   S\(4S jjr,\\S   \(4   r-\\+\(   \.\(   /\\/   4   r0S\\(   S\Rb                  S\Rd                  SS4S jr3\Rh                  " S5      r5 " S S\Rl                  Rn                  5      r8S\0S\9\8   4S jr:SRS\-S\\+\(      S\9\Rl                  Rv                     4S jjr< " S S\Rz                  5      r> SSS \(S\\(   S!\\9\Rl                  Rn                        SS4S" jjr? " S# S$\(\
5      r@\\(\R                  " S%S&94   rB\\@\R                  " S'S(S)S&94   rD\\\(   \R                  " S*S&94   rE\\\F   \R                  " S+S&94   rG\\\(   \R                  " S,S&94   rH\\/\R                  " S-S&94   rI\\\(   \R                  " S.S&94   rJ\\\+\(      \R                  " S/S&94   rK\\\(   \R                  " S0S&94   rL " S1 S2\(\
5      rM\\M\R                  " S3S&94   rN\\F\R                  " S4S5S6S&94   rOS7\(S\(4S8 jrPS9\S\(4S: jrQ\%4S9\S;\/S\(4S< jjrR SRS=\\S\(\4      S>\+\(   S?\\S\(\4   /\+\(   4   S@\\S\(\(4      SS4
SA jjrT    STS=\\S\(\4      SB\MSC\FSD\(S>\\+\(      S?\\\S\(\4   /\+\(   4      S@\\S\(\(4      SS4SE jjrUSF\VS\V4SG jrWSH\S\S\(\4   4SI jrXSJ\+\(   4SK jrYSL\SM   SS4SN jrZSL\SM   SS4SO jr[S\(4SP jr\S\(4SQ jr]g)Uz*Contains CLI utilities (styling, helpers).    N)Enum)Path)	TYPE_CHECKING	AnnotatedAnyCallableLiteralOptionalSequenceUnioncast)__version__	constants)ANSIget_sessionhf_raise_for_statusinstallation_methodloggingtabulate#   HfApitokenreturnr   c                 &    SSK Jn  U" U S[        S9$ )Nr   r   zhuggingface-cli)r   library_namelibrary_version)huggingface_hub.hf_apir   r   )r   r   s     ]/var/www/html/ai-image-ml/venv/lib/python3.13/site-packages/huggingface_hub/cli/_cli_utils.py
get_hf_apir    +   s    ,u+<kZZ    z9https://huggingface.co/docs/huggingface_hub/en/guides/cliexamplesdocs_anchorc                 r    U(       a
  [          U 3O[         nSR                  S U  5       5      nSU SU S3$ )zGenerate an epilog with examples and a Learn More section.

Args:
    examples: List of example commands (without the `$ ` prefix).
    docs_anchor: Optional anchor for the docs URL (e.g., "#hf-download").

Returns:
    Formatted epilog string.

c              3   ,   #    U  H
  nS U 3v   M     g7f)z  $ N ).0exs     r   	<genexpr>"generate_epilog.<locals>.<genexpr>B   s     <8RtB4[8s   z	Examples
zk

Learn more
  Use `hf <command> --help` for more information about a command.
  Read the documentation at )CLI_REFERENCE_URLjoin)r"   r#   docs_urlexamples_strs       r   generate_epilogr0   7   sS     7B#$[M2GXH99<8<<L  &J ' r!   )mainhelpepilogctx	formatterc                     U (       a:  UR                  5         U R                  S5       H  nUR                  U5        M     gg)z%Write the epilog without indentation.r%   N)write_paragraphsplit
write_text)r3   r4   r5   lines       r   _format_epilog_no_indentr;   Q   s7    !!#LL&D  & ' r!   z\s*\|\s*c                   0  ^  \ rS rSrSrS\R                  S\S\\R                     4U 4S jjr
S\\\\   4   4S jrS\R                  S\R                  SS	4S
 jrS\R                  S\R                  SS	4S jrS\R                  S\\   4S jrSrU =r$ )HFCliTyperGroup\   z
Typer Group that:
- lists commands alphabetically within sections.
- separates commands by topic (main, help, etc.).
- formats epilog without extra indentation.
- supports aliases via pipe-separated names (e.g. ``name="list | ls"``).
r4   cmd_namer   c                    > [         TU ]  X5      nUb  U$ U R                  R                  5        H#  u  pE[        R                  U5      nX&;   d  M!  Us  $    g N)superget_commandcommandsitems_ALIAS_SPLITr8   )selfr4   r?   cmdregistered_nameregistered_cmdaliases	__class__s          r   rC   HFCliTyperGroup.get_commande   sZ    g!#0?J 04}}/B/B/D+O"((9G"%% 0E r!   c                 r    0 nU R                    H$  n[        R                  U5      nUS   nUSS X'   M&     U$ )zBBuild a mapping from primary command name to its aliases (if any).r      N)rD   rF   r8   )rG   resultrI   partsprimarys        r   
_alias_mapHFCliTyperGroup._alias_mapr   sB    ')#}}O &&7EAhG#ABiFO  - r!   r5   Nc                    0 nU R                  5       nU R                  U5       H  nU R                  X5      nUb  UR                  (       a  M*  UR	                  UR
                  S9nUR                  U/ 5      nU(       a  U SSR                  U5       S3n[        USS5      n	UR                  U	/ 5      R                  XW45        M     UR                  S5         UR                  US   5        S S S 5        [        UR                  5       5       HI  n	U	S:X  a  M  UR                  U	R                  5        S35         UR                  X9   5        S S S 5        MK     g ! , (       d  f       Nu= f! , (       d  f       Mn  = f)	N)limitz	 [alias: , ]topicr1   zMain commandsz	 commands)rS   list_commandsrC   hiddenget_short_help_strwidthgetr-   getattr
setdefaultappendsectionwrite_dlsortedkeys
capitalize)
rG   r4   r5   topics	alias_mapnamerH   	help_textrK   rY   s
             r   format_commandsHFCliTyperGroup.format_commands{   sI   "$OO%	&&s+D""3-C{cjj..Y__.EImmD"-G(k499W3E2FaH	C&1EeR(//0AB , /vf~. 0FKKM*E""e&6&6&8%9#CD""6=1 ED + 0/
 EDs   E>E0
E-0
E?	c                 h   / nU R                  U5       HT  nU R                  X5      nUb  UR                  (       a  M*  [        US/ 5      nU(       d  M@  UR	                  US   5        MV     U(       a  [        U5      n[        XqU5        g U R                  (       a  [        U R                  X5        g g )Nr"   r   )rZ   rC   r[   r_   ra   r0   r;   r3   )rG   r4   r5   all_examplesri   rH   cmd_examplesr3   s           r   format_epilogHFCliTyperGroup.format_epilog   s     #%&&s+D""3-C{cjj"3
B7L|##LO4 , $\2F$V)<[[$T[[#A r!   c                     / nU R                    H,  n[        R                  U5      S   nUR                  U5        M.     [	        U5      $ )Nr   )rD   rF   r8   ra   rd   )rG   r4   primary_namesri   rR   s        r   rZ   HFCliTyperGroup.list_commands   sE    #%MMD"((.q1G  ) " m$$r!   r'   )__name__
__module____qualname____firstlineno____doc__clickContextstrr
   CommandrC   dictlistrS   HelpFormatterrk   rp   rZ   __static_attributes____classcell__rL   s   @r   r=   r=   \   s    u}}  @W Dd3i0 25== 2U=P=P 2UY 2.B B5;N;N BSW B$% %49 % %r!   r=   fallback_handlerc                 ,   ^   " U 4S jS[         5      nU$ )zRReturn a Typer group class that runs a fallback handler before command resolution.c                   V   >^  \ rS rSrS\R
                  S\\   S\4U U4S jjr	Sr
U =r$ )8fallback_typer_group_factory.<locals>.FallbackTyperGroup   r4   argsr   c                    > T" U[        U R                  R                  5       5      5      nUb  [        U5      e[        TU ]  X5      $ rA   )setrD   re   
SystemExitrB   resolve_command)rG   r4   r   fallback_exit_coderL   r   s       r   r   Hfallback_typer_group_factory.<locals>.FallbackTyperGroup.resolve_command   sD    !1$DMM<N<N<P8Q!R!- !3447*355r!   r'   )ru   rv   rw   rx   rz   r{   r   r|   tupler   r   r   )rL   r   s   @r   FallbackTyperGroupr      s*    	6u}} 	6DI 	6% 	6 	6r!   r   )r=   )r   r   s   ` r   fallback_typer_group_factoryr      s    6_ 6 r!   rY   c                     S[         R                  S[         R                  S[         R                  SS 4S jn[	        SU R                  5        3[        R                  R                  4X=(       d    / US.5      $ )NrG   r4   r5   r   c                 0    [        U R                  X5        g rA   )r;   r3   )rG   r4   r5   s      r   rp   #HFCliCommand.<locals>.format_epilog   s     c=r!   TyperCommandrY   r"   rp   )	rz   r}   r{   r   typerf   typercorer   r   s      r   HFCliCommandr      sq    >EMM > >%J]J] >bf > 
u'')*+		 	 "^mT r!   c            "          ^  \ rS rSrSr SSSSSSSSSSSSSS.S	\\   S
\S\\\      S\\	\\
4      S\\   S\\   S\\   S\S\S\S\S\S\\   S\\S\
4   /\S\
4   4   4U 4S jjjjrSrU =r$ )HFCliApp   z&Custom Typer app for Hugging Face CLI.Nr1   z	[OPTIONS]TF)rY   r"   context_settingsr2   r3   
short_helpoptions_metavaradd_help_optionno_args_is_helpr[   
deprecatedrich_help_panelri   rY   r"   r   r2   r3   r   r   r   r   r[   r   r   r   .c                   >^ ^^^^^^^^^	^
^^^ Tc  T(       a  [        T5      mS[        S[        4   S[        S[        4   4UU	UUUUUUUU
UUU UU4S jjnU$ )Nfunc.r   c                 \   > [         [        T]  T	[        TT5      TTTTTTT
TTTS9" U 5      $ )N)clsr   r2   r3   r   r   r   r   r[   r   r   )rB   r   commandr   )r   rL   r   r   r   r3   r"   r2   r[   ri   r   r   r   rG   r   rY   s    r   _inner HFCliApp.command.<locals>._inner   sQ    40 1!1% / / /% / 1   r!   )r0   r   r   )rG   ri   rY   r"   r   r2   r3   r   r   r   r   r[   r   r   r   rL   s   `````````````` r   r   HFCliApp.command   sM    $ >h$X.F	#s(+ 	c0B 	 	 	  r!   r'   rA   )ru   rv   rw   rx   ry   r
   r|   TOPIC_Tr   r~   r   boolr   r   r   r   r   s   @r   r   r      s   0 #%  (,59" $$(* $ % )-%sm% 	%
 49%% #4S>2% sm% % SM% % % % % % "#%  
8CH%&c(::	;!% %r!   r   r2   r   c                 @    Uc  [         n[        U USSUSSSSSS/S.S9	$ )	a  Create a Typer app with consistent settings.

Args:
    help: Help text for the app.
    epilog: Optional epilog text (use `generate_epilog` to create one).
    cls: Optional Click group class to use (defaults to `HFCliTyperGroup`).

Returns:
    A configured Typer app.
NTFx   z-hz--help)max_content_widthhelp_option_names)	r2   r3   add_completionr   r   rich_markup_moder   pretty_exceptions_enabler   )r=   r   )r2   r3   r   s      r   typer_factoryr      sE     {!& "%"&!1
 r!   c                        \ rS rSrSrSrSrSrg)RepoTypei  modeldatasetspacer'   N)ru   rv   rw   rx   r   r   r   r   r'   r!   r   r   r     s    EGEr!   r   z/The ID of the repo (e.g. `username/repo-name`).)r2   z--typez--repo-typez2The 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.c                        \ rS rSrSrSrSrSrg)OutputFormatiS  z$Output format for CLI list commands.tablejsonr'   N)ru   rv   rw   rx   ry   r   r   r   r'   r!   r   r   r   S  s    .EDr!   r   zOutput format (table or json).z-qz--quietzPrint only IDs (one per line).ri   c                 R    [         R                  " SSU 5      nUR                  5       $ )z\Convert a camelCase or PascalCase string to SCREAMING_SNAKE_CASE to be used as table header.z([a-z])([A-Z])z\1_\2)resubupper)ri   ss     r   
_to_headerr   k  s!    
 (D1A779r!   valuec                    U (       d  g[        U [        5      (       a  U (       a  S$ S$ [        U [        R                  5      (       a  U R                  S5      $ [        U [        5      (       a!  [
        R                  " SU 5      (       a  U SS $ [        U [        5      (       a  SR                  S U  5       5      $ [        U [        5      (       a*  S	U ;   a  [	        U S	   5      $ [        R                  " U 5      $ [	        U 5      $ )
z/Convert a value to string for terminal display. u   ✔z%Y-%m-%dz^\d{4}-\d{2}-\d{2}TN
   rW   c              3   8   #    U  H  n[        U5      v   M     g 7frA   )_format_value)r(   vs     r   r*    _format_value.<locals>.<genexpr>|  s     95aq))5s   ri   )
isinstancer   datetimestrftimer|   r   matchr   r-   r~   r   dumps)r   s    r   r   r   q  s    %u%2%%**++~~j))%"((+A5"I"ISbz%yy95999	E4	 	 U?uV}%%zz%  u:r!   max_lenc                 P    [        U 5      n[        U5      U:  a  USUS-
   S-   nU$ )z/Format a value + truncate it for table display.N   z...)r   len)r   r   cells      r   _format_cellr     s2    D
4y7Mgk"U*Kr!   rE   headersrow_fn
alignmentsc           	         U (       d  [        S5        g[        [        [        [        [        [
        4         U  Vs/ s H
  oB" U5      PM     sn5      nU Vs/ s H  n[        U5      PM     nnU=(       d    0 R                  5        VV	s0 s H  u  p[        U5      U	_M     n
nn	[        [        XWU
S95        gs  snf s  snf s  sn	nf )aQ  Print items as a formatted table.

Args:
    items: Sequence of dictionaries representing the items to display.
    headers: List of column headers.
    row_fn: Function that takes an item dict and returns a list of string values for each column.
    alignments: Optional mapping of header name to "left" or "right". Defaults to "left".
zNo results found.N)r   r   )	printr   r   r   r|   intr   rE   r   )rE   r   r   r   itemrowshscreaming_headerskr   screaming_alignmentss              r   print_as_tabler     s     !"T%S/*+u-MutfTlu-MND0781A8:D:J9Q9Q9ST9SJqM1,9ST	(4?S
TU	 .N8Ts   B;
C Cformatquietid_keyc                   ^^	 U(       a  U  H  n[        Xs   5        M     gU[        R                  :X  a(  [        [        R                  " [	        U 5      SS95        gTcV  U (       a  [	        U S   R                  5       5      OU/nU V	^	s/ s H!  m	[        U	4S jU  5       5      (       d  M  T	PM#     sn	mUc(  S[        [        [        4   S[        [           4U4S jjn[        U TXVS	9  gs  sn	f )
a<  Print list command output in the specified format.

Args:
    items: Sequence of dictionaries representing the items to display.
    format: Output format (table or json).
    quiet: If True, print only IDs (one per line).
    id_key: Key to use for extracting IDs in quiet mode.
    headers: Optional list of column names for headers. If not provided, auto-detected from keys.
    row_fn: Optional function to extract row values. If not provided, uses _format_cell on each column.
    alignments: Optional mapping of header name to "left" or "right". Defaults to "left".
N   )indentr   c              3   X   >#    U  H  n[        UR                  T5      5      v   M!     g 7frA   r   r^   )r(   r   cols     r   r*   $print_list_output.<locals>.<genexpr>  s$     4c]bUY\$((3-5P5P]bs   '*r   r   c                 d   > T Vs/ s H  n[        U R                  U5      5      PM     sn$ s  snf rA   r   )r   r   r   s     r   r   !print_list_output.<locals>.row_fn  s(    ;BC7CL#/7CCCs   $-)r   r   r   )r   r   r   r   r   re   anyr~   r|   r   r   )
rE   r   r   r   r   r   r   r   all_columnsr   s
       `    `r   print_list_outputr     s    ( D$, """djjeQ/0/4d58==?+6("-d+34c]b4c1c3+d~	Dc3h 	DDI 	D 5'&P es   C--C-r   c                 n   [        U [        R                  5      (       a  U R                  5       $ [        U [        5      (       a4  U R	                  5        VVs0 s H  u  pUc  M
  U[        U5      _M     snn$ [        U [        5      (       a  U  Vs/ s H  n[        U5      PM     sn$ U $ s  snnf s  snf )z4Recursively serialize a value to be JSON-compatible.)r   r   	isoformatr~   rE   _serialize_valuer   )r   keyvalr   s       r   r   r     s    !X&&''{{}	At		;<779X9xs*%c**9XX	At		34514 &155H Y5s   	B,%B,B2infoc                     [         R                  " U 5      R                  5        VVs0 s H  u  pUc  M
  U[        U5      _M     snn$ s  snnf )z9Convert repo info dataclasses to json-serializable dicts.)dataclassesasdictrE   r   )r   r   r   s      r   api_object_to_dictr     sC    /:/A/A$/G/M/M/Oa/OtqST"A""/Oaaas
   	A	A	valid_propertiesc                 Z   ^  S[         [           S[         [        [              4U 4S jjnU$ )zJCreate a callback to parse and validate comma-separated expand properties.r   r   c           	         > U c  g U R                  S5       Vs/ s H  oR                  5       PM     nnU H4  nUT;  d  M  [        R                  " SU SSR	                  T5       35      e   U$ s  snf )N,zInvalid expand property: 'z'. Valid values are: rW   )r8   stripr   BadParameterr-   )r   p
propertiespropr   s       r   _parse_expand_properties?make_expand_properties_parser.<locals>._parse_expand_properties  s}    =).S)9:)9Aggi)9
:D++((06KDIIVfLgKhi  
  ;s   A0)r
   r|   r   )r   r	  s   ` r   make_expand_properties_parserr    s+    	 	(49:M 	 $#r!   library)huggingface_hubtransformersc                 d     [        U 5        g! [         a    [        R                  SSS9   gf = f)a"  
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_updater    s2    L'" L;dKLs    //c                 z  ^ [         R                  R                  U 5      m[        U4S jS 5       5      (       a  g [        R
                  R                  [        R                  5      (       aJ  [        R
                  R                  [        R                  5      n[        R                  " 5       U-
  S:  a  g [        [        R                  5      R                  R                  SSS9  [        [        R                  5      R                  5         [        5       R!                  SU  S3SS	9n[#        U5        UR%                  5       nUS
   S   nTU:w  ag  U S:X  a  ['        5       nO
[)        5       n[*        R,                  " [.        R0                  " SU  SU ST S[.        R2                  " U5       S3	5      5        g g )Nc              3   ,   >#    U  H	  oT;   v   M     g 7frA   r'   )r(   tagcurrent_versions     r   r*   $_check_cli_update.<locals>.<genexpr>
  s     
;]c/!]s   )rcdeviQ T)parentsexist_okzhttps://pypi.org/pypi/z/jsonr   )timeoutr   versionr  zA new version of z (z&) is available! You are using version z.
To update, run: r%   )	importlibmetadatar   r   ospathexistsr   CHECK_FOR_UPDATE_DONE_PATHgetmtimetimer   parentmkdirtouchr   r^   r   r   #_get_huggingface_hub_update_command _get_transformers_update_commandrz   echor   yellowbold)r  mtimeresponsedatalatest_versionupdate_commandr  s         @r   r  r    sr   ((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                  j    [        5       n U S:X  a  gU S:X  a  [        R                  S:X  a  gU S:X  a  gg)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   r#  ri   methods    r   r,  r,  -  s8     "F-	>	!bggo_	>	!A/r!   c                  \    [        5       n U S:X  a  [        R                  S:X  a  gU S:X  a  gg)z*Return the command to update transformers.r8  r9  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!   rA   )NN)idNNN)^ry   r   r   importlib.metadatar!  r   r#  r   r(  enumr   pathlibr   typingr   r   r   r   r	   r
   r   r   r   rz   r   r  r   r   huggingface_hub.utilsr   r   r   r   r   r   
get_loggerr  _MAX_CELL_LENGTHr   r   r|   r    r,   r   r0   r   r   r   FallbackHandlerTr{   r   r;   compilerF   r   
TyperGroupr=   r   r   r   r   Typerr   r   r   Argument	RepoIdArgOptionRepoTypeOptTokenOptr   
PrivateOptRevisionOptLimitOpt	AuthorOpt	FilterOpt	SearchOptr   	FormatOptQuietOptr   r   r   r~   r   r   objectr   r   r  r  r  r,  r-  r'   r!   r   <module>rX     s   1     	 	    d d d   2 p p 
			  ,[hsm [w [ P d3i hsm s , ',
-T#YC18C=@A 'Xc] ' 'SXSfSf 'ko ' zz+&N%ejj++ N%b
3C 
_H] 
 8DI+> $uzzOfOfJg (u{{ (X [_
}2:4

@U@U;V2WBsD  	NN>	 	LLA SM	LLY TN	LLu
 SM	LLS 	LL457
 SM	LL9:<	
 T#Y	LL`ac	
 SM	LLo&(	3  	LL-	 	LL-S S   ( -=  c   ,0	VDcN#V#YV d38n%tCy01V c3h(	V
 
V8 #'>B+/&QDcN#&Q&Q &Q 	&Q
 d3i &Q XtCH~.S	9:;&Q c3h(&Q 
&QR 6 bS bT#s(^ b
$DI $(Lg&GH LT L($
w'HI $
d $
N
0S 
0-# -r!   