Ë
    ÂÓ^ja¡  ã                   ó  — U 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ZddlZddl	Z	ddl
mZmZ ddlmZ ddlmZ ddlmZmZmZmZmZmZ ddlZddlmZmZmZ ddlmZ dd	lm Z m!Z!m"Z"m#Z#m$Z$ dd
l%m&Z& ddl'm(Z(m)Z)m*Z*m+Z+ ddl,m-Z- ddl.m/Z/m0Z0  e#jb                  «       Z2dZ3erddl4m5Z5 d{de6dz  ddfd„Z7dZ8d{de9e6   de6dz  de6fd„Z:ed   e6z  Z;ee9e6   e<e6   ge=dz  f   Z> ede6¬«      Z?de6dz  dej€                  dej‚                  ddfd„ZB ej†                  d «      ZD G d!„ d"e*«      ZEg d#¢ZFe9eGe6e6f      eHd$<   dej‚                  ddfd%„ZId&ej”                  deKfd'„ZLd&ej”                  d(e9e6   ddfd)„ZMd(e9e6   deKfd*„ZNd(e9e6   d+eKd,eKddfd-„ZOd.e6dd/fd0„ZPd1ej¢                  d2e6d3e9eGe6e6f      ddfd4„ZR	 d{d5e>d6eg e9eGe6e6f      f   dz  deSeE   fd7„ZTd{d8e;de9e6   dz  deSe)   fd9„ZUd|d:e6de6dz  d;eSeE   dz  dd"fd<„ZV G d=„ d>ej®                  «      ZX G d?„ d@e6e«      ZYee6 e(dA¬B«      f   ZZeeY e+dCdDdE¬B«      f   Z[eeYdz   e+dCdDdEdF¬G«      f   Z\ee6dz   e+dH¬B«      f   Z]eeKdz   e+dI¬B«      f   Z^ee6dz   e+dJ¬B«      f   Z_ee= e+dK¬B«      f   Z`ee6dz   e+dL¬B«      f   Zaee9e6   dz   e+dM¬B«      f   Zbee6dz   e+dN¬B«      f   Zcee9e6   dz   e+dOdPdQ¬B«      f   Zdee9e6   dz   e+dRdSdT¬B«      f   Zeee6dz   e+dUdV¬B«      f   Zfee6dz   e+dW¬B«      f   Zgdehe6e6f   fdX„Zi	 	 d|dYe9e6   dz  dZe6dz  dehe6e6dz  f   fd[„Zjd\ehe6e6dz  f   de9ehe6e6f      dz  fd]„Zkee9e6   dz   e+d^d_d`¬B«      f   Zldae9e6   dz  ddbfdc„Zmddee?   fde„Zneedz   e+dfdgdh¬B«      f   ZoeeK e+didj¬B«      f   Zpdddkdlœdme6dne=dz  doedz  dpeKddf
dq„Zqdreds   ddfdt„Zrdreds   ddfdu„Zsdre6de6dz  fdv„Ztde6dz  fdw„Zude=fdx„Zvde9e6   dz  fdy„Zwde9e6   dz  fdz„Zxy)}z*Contains CLI utilities (styling, helpers).é    N)ÚCallableÚSequence)ÚEnum)ÚPath)ÚTYPE_CHECKINGÚ	AnnotatedÚAnyÚLiteralÚTypeVarÚcast)ÚVolumeÚ__version__Ú	constants)ÚCLIError)Úget_sessionÚhf_raise_for_statusÚinstallation_methodÚloggingÚparse_hf_mount)Úload_dotenvé   )ÚArgumentÚ	HfCommandÚHfGroupÚOption)ÚStyledContext)ÚOutputFormatÚouté   ©Ú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     úi/var/www/ramen.bs-engineer-server.com/venv/lib/python3.12/site-packages/huggingface_hub/cli/_cli_utils.pyÚ
get_hf_apir)   8   s   € å,á�uÐ+<ÌkÔZÐZó    z9https://huggingface.co/docs/huggingface_hub/en/guides/cliÚexamplesÚdocs_anchorc                 óh   — |r
t         › |› �nt         }dj                  d„ | D «       «      }d|› d|› d�S )a  Generate 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   ó&   K  — | ]	  }d |› �–— Œ y­w)z  $ N© )Ú.0Úexs     r(   ú	<genexpr>z"generate_epilog.<locals>.<genexpr>O   s   è ø€ Ò<¨R˜t B 4œ[Ñ<ùs   ‚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_epilogr8   D   sS   € ñ 7BÔ#Ð$ [ MÑ2ÔGX€HØ—9‘9Ñ<°8Ô<Ó<€Lðà€ð ð &˜Jð 'ðð r*   )ÚmainÚhelpÚExpandPropertyT)ÚboundÚepilogÚctxÚ	formatterc                 óx   — | r8|j                  «        | j                  d«      D ]  }|j                  |«       Œ yy)z%Write the epilog without indentation.r.   N)Úwrite_paragraphÚsplitÚ
write_text)r=   r>   r?   Úlines       r(   Ú_format_epilog_no_indentrE   _   s<   € áØ×!Ñ!Ô#Ø—L‘L Ó&ò 	'ˆDØ× Ñ  Õ&ñ	'ð r*   z\s*\|\s*c                   ó  ‡ — e Zd ZdZeZdej                  ddfˆ fd„Zdej                  de	e
   defˆ fd„Zedej                  de	e
   ddfd	„«       Zdej                  d
e
dej                  dz  fˆ fd„Zdee
e	e
   f   fd„Zdej                  dej&                  ddfd„Zdej                  dej&                  ddfd„Zdej                  de	e
   fd„Z	 dddddœde
dz  dede	e
   dz  de
dz  dedeedef   gedef   f   fˆ fd„Zˆ xZS )ÚHFCliTyperGroupaÇ  
    CLI 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"``).
    - consumes the global formatting flags (``--format``, ``--json``, ``-q`` / ``--quiet``, ``--no-truncate``)
      anywhere in the args of a leaf command and applies them to ``out``, so leaf
      commands don't need to declare these options themselves.
    - rewrites ``spaces/user/repo`` to ``user/repo --type space`` for commands that accept ``--type``.
    - enriches "No such option" / "No such command" errors with available options or commands.
    r>   r#   Nc                 óò  •— 	 t         ‰	| �  |«      S # t        j                  $ �rP}|j                  ��=|j                  j
                  ��&|j                  j
                  }t        |t        j                  «      rx|j                  |j                  «      D �cg c]@  }|j                  |j                  |«      x}� |j                  s||j                  d¬«      f‘ŒB nc c}w }}t        |d|«       ‚ |j                  |j                  «      D �cg c]G  }t        |t        j                  «      r+|j                  s|j                  |j                  «      x}r|‘ŒI nc c}w }}t        |d|«       ‚ d}~ww xY w)at  Enrich unknown-option errors with available options or subcommands.

        Catches `NoSuchOption` raised during subcommand `make_context()`
        (option parsing).  For leaf commands (e.g. `hf repos create --test`)
        we list the command's options; for groups (e.g. `hf cache --test`)
        we list subcommands since groups have no user-facing options.
        NéP   ©ÚlimitÚcommandsÚoptions)ÚsuperÚinvokeÚclickÚNoSuchOptionr>   ÚcommandÚ
isinstanceÚGroupÚlist_commandsÚget_commandÚhiddenÚget_short_help_strÚ_enrich_usage_errorÚ
get_paramsr   Úget_help_record)
Úselfr>   ÚeÚcmdÚnameÚsubÚitemsÚpÚrecordÚ	__class__s
            €r(   rO   zHFCliTyperGroup.invokez   sN  ø€ ð	Ü‘7‘> #Ó&Ð&øÜ×!Ñ!ó 	Ø�u‰uÑ  Q§U¡U§]¡]Ñ%>Ø—e‘e—m‘m�Ü˜c¤5§;¡;Ô/ð %(×$5Ñ$5°a·e±eÓ$<öà Ø#&§?¡?°1·5±5¸$Ó#?Ð?˜CÐLÐUX×U_ÒU_ð ˜s×5Ñ5¸BÐ5Ó?Ò@ñùò �Eð ô
 (¨¨:°uÔ=ð ð	 "%§¡°·±Ó!6öàÜ% a¬¯©Ô6¸q¿xºxÐWX×WhÑWhÐij×inÑinÓWoÐMoÈVÐMoò ñùò �Eð ô
 (¨¨9°eÔ<Øûð'	ús/   ƒ ’E6¦A1E1ÂACÃ3E1ÄAEÅE1Å1E6Úargsc           	      ó’  •— |r|d   j                  d«      s|d   nd }|r| j                  ||«      nd }|�| j                  ||«       	 t        ‰| �  ||«      \  }}}|�&t+        |t
        j,                  «      st/        ||«       |||fS # t
        j                  $ �r'}|�€|��| j                  j                  «       D �	�
�cg c]-  \  }	}
|
j                  st        j                  |	«      D ]  }|‘Œ Œ/ nc c}}
}	w }}
}	}t        j                  ||«      }|rDdj                  d„ |D «       «      }t        |d|j                   j#                  d«      › d|› d�«       | j%                  |«      D �cg c]6  }| j                  ||«      x}� |j                  s||j'                  d	¬
«      f‘Œ8 nc c}w }}t)        |d|«       ‚ d }~ww xY w)Nr   ú-ú, c              3   ó(   K  — | ]
  }d |› d �–— Œ y­w)ú'Nr0   ©r1   Úms     r(   r3   z2HFCliTyperGroup.resolve_command.<locals>.<genexpr>®   s   è ø€ Ò+F¸¨a°¨s°!¬HÑ+Fùs   ‚Úmessageú.z. Did you mean ú?rI   rJ   rL   )Ú
startswithrV   Ú_rewrite_repo_type_prefixrN   Úresolve_commandrP   Ú
UsageErrorrL   ra   rW   Ú_ALIAS_SPLITrB   ÚdifflibÚget_close_matchesr5   Úsetattrrm   ÚrstriprU   rX   rY   rS   rT   Ú_consume_format_flags_for_leaf)r\   r>   re   Úcmd_namer^   r_   Úresolved_cmdÚsub_argsr]   ÚkeyÚ
registeredÚaliasÚvisible_namesÚmatchesÚsuggestionsr`   ra   rd   s                    €r(   rr   zHFCliTyperGroup.resolve_command™   så  ø€ Ù"¨4°©7×+=Ñ+=¸cÔ+B�4˜’7ÈˆÙ19ˆd×Ñ˜s HÔ-¸tˆàˆ?Ø×*Ñ*¨3°Ô5ð	Ü+0©7Ñ+BÀ3ÈÓ+MÑ(ˆD�, ð4 Ð#¬J°|ÄUÇ[Á[Ô,QÜ*¨<¸ÔBà�\ 8Ð+Ð+øô9 ×Ñó 	à‰{˜xÑ3ð ,0¯=©=×+>Ñ+>Ó+@÷!ð !á'˜˜ZØ%×,Ò,Ü!-×!3Ñ!3°CÓ!8ò	!ð ò ð!Øñ!ùô !�ò !ô "×3Ñ3°H¸mÓL�ÙØ"&§)¡)Ñ+F¸gÔ+FÓ"F�KÜ˜A˜y¨Q¯Y©Y×-=Ñ-=¸cÓ-BÐ,CÀ?ÐS^ÐR_Ð_`Ð*aÔbð !%× 2Ñ 2°3Ó 7öàØ#×/Ñ/°°TÓ:Ð:˜ÐGÐPS×PZÒPZð ˜3×1Ñ1¸Ð1Ó;Ò<ñùò �ð ô
 $ A z°5Ô9Øûð)	ús1   Á
B ÂGÂ$GÃ2C6
Ã5A;GÅ0;F,Æ+GÇGr^   c                 ó¸  — t        d„ | j                  D «       «      }|syt        «       }d}| j                  D ]A  }t        |t        j
                  «      sŒ|j                  dv r|j                  |«       |dz  }ŒC |syt        «       }| j                  D ][  }t        |t        j                  «      sŒ|j                  rŒ+g |j                  ¢|j                  ¢­D ]  }|j                  |«       Œ Œ] d}g }	d}
|
t        |«      k  r^||
   }|dk(  rnS|j                  d«      rd|v s||vr|
dz  }
n%|
d	z  }
n||v r|	j                  |
«       |dz  }|
dz  }
|
t        |«      k  rŒ^|	syd}d}g }|	D ]˜  }||   j                  d
d	«      }t        |«      dk7  s|d   t         j"                  vrŒ<|d   }t         j"                  |   }|�!||k7  rt	        j$                  d|› d|› d�«      ‚|}|}|j                  ||d   › d
|d	   › �f«       Œš |syt        d„ |D «       «      rt	        j$                  d|› d�«      ‚|D ]
  \  }}|||<   Œ |j'                  d|g«       y)u„  Rewrite prefixed repo IDs (e.g. ``spaces/user/repo``) to ``user/repo --type space``.

        Only applies to commands that have a ``--type`` / ``--repo-type`` option and
        at least one repo-ID positional argument (any ``click.Argument`` whose name
        ends with ``_id``, e.g. ``repo_id``, ``from_id``, ``to_id``).  When the
        token that maps to such an argument matches ``{prefix}/org/repo`` (where
        *prefix* is one of ``spaces``, ``datasets``, or ``models``), the prefix is
        stripped and an implicit ``--type {type}`` is appended.  An error is raised
        if ``--type`` is also provided explicitly or if multiple prefixed arguments
        disagree on the repo type.

        Only repo-ID positional slots are inspected so that other positional
        arguments (filenames, local paths, patterns â€¦) are never misinterpreted as
        prefixed repo IDs.
        c              3   óp   K  — | ].  }t        |t        j                  «      xr d |j                  v –— Œ0 y­w)ú--typeN)rS   rP   r   Úopts)r1   Úparams     r(   r3   z<HFCliTyperGroup._rewrite_repo_type_prefix.<locals>.<genexpr>Ñ   s-   è ø€ ÒqÐ]bœj¨´·±Ó=ÒXÀ(ÈeÏjÉjÐBXÓXÑqùs   ‚46Nr   )Úrepo_idÚfrom_idÚto_idr   ú--rg   ú=é   ú/é   z!Conflicting repo type prefixes: 'z/' and 'z/'.c              3   ó€   K  — | ]6  }|d k(  xs+ |j                  d«      xs |dk(  xs |j                  d«      –— Œ8 y­w)r…   z--type=ú--repo-typez--repo-type=N©rp   ©r1   Úargs     r(   r3   z<HFCliTyperGroup._rewrite_repo_type_prefix.<locals>.<genexpr>  sI   è ø€ ò 
àð �8‰OÒr˜sŸ~™~¨iÓ8Òr¸CÀ=Ñ<PÒrÐTW×TbÑTbÐcqÓTrÓrñ
ùs   ‚<>z!Ambiguous repo type: got prefix 'z8/' in repo ID and explicit --type. Use one or the other.r…   )ÚanyÚparamsÚsetrS   rP   r   r_   Úaddr   Úis_flagr†   Úsecondary_optsÚlenrp   ÚappendrB   r   ÚREPO_TYPES_MAPPINGrs   Úextend)r^   re   Úhas_type_optionÚrepo_id_positionsÚarg_idxr‡   Úvalue_optionsÚoptÚpositional_countÚrepo_id_arg_indicesÚir”   Úinferred_typeÚfirst_prefixÚrewritesÚ	arg_indexÚpartsÚprefixÚmapped_typeÚ	new_values                       r(   rq   z)HFCliTyperGroup._rewrite_repo_type_prefixÀ   s¼  € ô" ÑqÐfi×fpÑfpÔqÓqˆÙØô '*£eÐØˆØ—Z‘Zò 	ˆEÜ˜%¤§¡Õ0Ø—:‘:Ð!@Ñ@Ø%×)Ñ)¨'Ô2Ø˜1‘‘ð		ñ !Øô #&£%ˆØ—Z‘Zò 	+ˆEÜ˜%¤§¡Õ.°u·}³}Ø?˜UŸZ™ZÐ?¨%×*>Ñ*>Ñ?ò +�CØ!×%Ñ% cÕ*ñ+ð	+ð ÐØ)+ÐØˆØ”#�d“)ŠmØ�q‘'ˆCØ�dŠ{ØØ�~‰~˜cÔ"Ø˜#‘: ¨MÑ!9Ø˜‘F‘Aà˜‘F‘Aà#Ð'8Ñ8Ø'×.Ñ.¨qÔ1Ø  AÑ%Ð Ø�Q‘�ð ”#�d“)‹mñ #Øð %)ˆØ#'ˆØ*,ˆà,ò 
	CˆIØ˜‘O×)Ñ)¨#¨qÓ1ˆEÜ�5‹z˜QŠ %¨¡(´)×2NÑ2NÑ"NØØ˜1‘XˆFÜ#×6Ñ6°vÑ>ˆKØÐ(¨[¸MÒ-IÜ×&Ñ&Ð)JÈ<È.ÐX`ÐagÐ`hÐhkÐ'lÓmÐmØ'ˆMØ!ˆLØ�O‰O˜Y¨5°©8¨*°A°e¸A±h°ZÐ(@ÐAÕBð
	Cñ Øô ñ 
àô
ô 
ô ×"Ñ"Ø3°L°>ÐAyÐzóð ð
 %-ò 	(Ñ ˆI�yØ'ˆD�ŠOð	(à�‰�X˜}Ð-Õ.r*   rz   c                 ó¬   •— t         ‰| �  ||«      }|�|S | j                  j                  «       D ]"  \  }}t        j                  |«      }||v sŒ |c S  y ©N)rN   rV   rL   ra   rt   rB   )r\   r>   rz   r^   Úregistered_nameÚregistered_cmdÚaliasesrd   s          €r(   rV   zHFCliTyperGroup.get_command!  sd   ø€ ä‰gÑ! # xÓ0ˆØˆ?ØˆJð 04¯}©}×/BÑ/BÓ/Dò 	&Ñ+ˆO˜^Ü"×(Ñ(¨Ó9ˆGØ˜7Ò"Ø%Ò%ð	&ð r*   c                 óp   — i }| j                   D ]$  }t        j                  |«      }|d   }|dd ||<   Œ& |S )zBBuild a mapping from primary command name to its aliases (if any).r   r   N)rL   rt   rB   )r\   Úresultr±   r«   Úprimarys        r(   Ú
_alias_mapzHFCliTyperGroup._alias_map.  sI   € à')ˆØ#Ÿ}™}ò 	(ˆOÜ ×&Ñ& Ó7ˆEØ˜A‘hˆGØ# A B˜iˆF�7ŠOð	(ð ˆr*   r?   c                 óÖ  — i }| j                  «       }| j                  |«      D ]š  }| j                  ||«      }|�|j                  rŒ$|j	                  |j
                  ¬«      }|j                  |g «      }|r|› ddj                  |«      › d�}t        |dd«      }	|j                  |	g «      j                  ||f«       Œœ |j                  d«      5  |j                  |d   «       d d d «       t        |j                  «       «      D ]G  }	|	dk(  rŒ	|j                  |	j                  «       › d�«      5  |j                  ||	   «       d d d «       ŒI y # 1 sw Y   ŒmxY w# 1 sw Y   Œ`xY w)	NrJ   z	 [alias: rh   ú]Útopicr9   zMain commandsz	 commands)r·   rU   rV   rW   rX   ÚwidthÚgetr5   ÚgetattrÚ
setdefaultrœ   ÚsectionÚwrite_dlÚsortedÚkeysÚ
capitalize)
r\   r>   r?   ÚtopicsÚ	alias_mapr_   r^   Ú	help_textr³   rº   s
             r(   Úformat_commandszHFCliTyperGroup.format_commands7  si  € Ø"$ˆØ—O‘OÓ%ˆ	à×&Ñ& sÓ+ò 		CˆDØ×"Ñ" 3¨Ó-ˆCØˆ{˜cŸjšjØØ×.Ñ.°Y·_±_Ð.ÓEˆIØ—m‘m D¨"Ó-ˆGÙØ(˜k¨°4·9±9¸WÓ3EÐ2FÀaÐH�	Ü˜C ¨&Ó1ˆEØ×Ñ˜e RÓ(×/Ñ/°°yÐ0AÕBð		Cð ×Ñ˜Ó/ñ 	/Ø×Ñ˜v f™~Ô.÷	/ä˜FŸK™K›MÓ*ò 	2ˆEØ˜ŠØØ×"Ñ" e×&6Ñ&6Ó&8Ð%9¸Ð#CÓDñ 2Ø×"Ñ" 6¨%¡=Ô1÷2ð 2ñ	2÷	/ð 	/ú÷
2ð 2ús   ÃEÄ3EÅEÅE(	c                 ó<  — g }| j                  |«      D ]G  }| j                  ||«      }|�|j                  rŒ$t        |dg «      }|sŒ4|j	                  |d   «       ŒI |rt        |«      }t        |||«       y | j                  rt        | j                  ||«       y y )Nr+   r   )rU   rV   rW   r½   rœ   r8   rE   r=   )r\   r>   r?   Úall_examplesr_   r^   Úcmd_examplesr=   s           r(   Úformat_epilogzHFCliTyperGroup.format_epilogN  s�   € ð #%ˆØ×&Ñ& sÓ+ò 	5ˆDØ×"Ñ" 3¨Ó-ˆCØˆ{˜cŸjšjØÜ" 3¨
°BÓ7ˆLÚØ×#Ñ# L°¡OÕ4ð	5ñ Ü$ \Ó2ˆFÜ$ V¨S°)Õ<Ø�[Š[Ü$ T§[¡[°#°yÕAð r*   c                 ó�   — g }| j                   D ]+  }t        j                  |«      d   }|j                  |«       Œ- t	        |«      S )Nr   )rL   rt   rB   rœ   rÁ   )r\   r>   Úprimary_namesr_   r¶   s        r(   rU   zHFCliTyperGroup.list_commands`  sJ   € à#%ˆØ—M‘Mò 	*ˆDÜ"×(Ñ(¨Ó.¨qÑ1ˆGØ× Ñ  Õ)ð	*ô �mÓ$Ð$r*   r9   )rº   r+   r=   r_   rº   r+   r=   Úkwargs.c                ó\   •— |€|rt        |«      }t        ‰| �  |ft        ||«      |dœ|¤ŽS )N)Úclsr=   )r8   rN   rR   ÚHFCliCommand)r\   r_   rº   r+   r=   rÎ   rd   s         €r(   rR   zHFCliTyperGroup.commandh  s9   ø€ ð ˆ>™hÜ$ XÓ.ˆFÜ‰w‰˜tÐ`¬°e¸XÓ)FÈvÑ`ÐY_Ñ`Ð`r*   r°   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   Úcontext_classrP   ÚContextrO   ÚlistÚstrÚtuplerr   ÚstaticmethodÚCommandrq   rV   Údictr·   ÚHelpFormatterrÇ   rË   rU   ÚTOPIC_Tr	   r   rR   Ú__classcell__©rd   s   @r(   rG   rG   j   s¼  ø„ ñð "€Mð˜%Ÿ-™-ð ¨Dõ ð>%, 5§=¡=ð %,¸¸S¹	ð %,Àeõ %,ðN ð^/ u§}¡}ð ^/¸DÀ¹Ið ^/È$ò ^/ó ð^/ð@˜uŸ}™}ð ¸ð ÀÇÁÐPTÑ@Tõ ð˜D  d¨3¡i Ñ0ó ð2 5§=¡=ð 2¸U×=PÑ=Pð 2ÐUYó 2ð.B §¡ð B¸5×;NÑ;Nð BÐSWó Bð$% §¡ð %°4¸±9ó %ð  ðað  Ø%)Ø!òaà�D‰jðað ð	að
 �s‘)˜dÑ"ðað �d‘
ðað ðað 
�8˜C ˜HÑ%Ð&¨°°c°Ñ(:Ð:Ñ	;÷añ ar*   rG   ))z&--format [auto|human|agent|json|quiet]zWOutput format. Defaults to 'auto' which picks 'agent' or 'human' based on the terminal.)ú--jsonz+JSON output. Equivalent to '--format json'.)z-q, --quietz?Quiet output (one ID per line). Equivalent to '--format quiet'.)ú--no-truncatezQDo not truncate scalar values in human tables (list/dict columns stay shortened).Ú _FORMATTING_OPTIONS_HELP_RECORDSc                 óz   — | j                  d«      5  | j                  t        «       d d d «       y # 1 sw Y   y xY w)NzFormatting options)r¿   rÀ   rä   )r?   s    r(   Ú"_format_formatting_options_sectionræ   ƒ  s5   € Ø	×	Ñ	Ð/Ó	0ñ =Ø×ÑÔ;Ô<÷=÷ =ñ =ús   ’1±:r^   c                 ó¶   — | j                   D ]J  }t        |t        j                  «      sŒg |j                  ¢|j
                  ¢­}d|v sd|v s	d|v sd|v sŒJ y y)a  Return True if the command defines its own --format, --json or --quiet / -q.

    Used to skip the global formatting flag pre-processor and the duplicated "Formatting options" help section for
    legacy commands like 'hf jobs ls' that have their own format/quiet options.
    ú--formatrâ   ú--quietú-qTF)r–   rS   rP   r   r†   rš   )r^   r‡   r†   s      r(   Ú_has_local_formatting_optionrë   ˆ  sf   € ð —‘ò ˆÜ˜%¤§¡Ô.ØØ3�—‘Ð3˜e×2Ñ2Ñ3ˆØ˜Ñ ¨TÑ!1°YÀ$Ñ5FÈ$ÐRVÊ,Ùðð r*   re   c                 óæ  ‡— | j                   j                  d«      ryt        |«      }t        j                  |«       d}d}d}| j
                  D ]O  }t        |t        j                  «      sŒg |j                  ¢|j                  ¢­}d|v rd}d|v sd|v rd}d|v sŒNd}ŒQ |rt        || | ¬	«       yt        j                  }dŠd
t        ddfˆfd„}	d}
|
t        |«      k  rø||
   }|dk(  rní|dk(  rJ |	d«       |
dz   t        |«      k\  rt        j                   d«      ‚t#        ||
dz      «      }dŠ||
|
dz   …= Œh|j%                  d«      r* |	d«       t#        |t        d«      d «      }dŠ||
|
dz   …= Œ£|dk(  r# |	d«       t        j&                  }dŠ||
|
dz   …= ŒË|dv r# |	|«       t        j(                  }|Š||
|
dz   …= Œò|
dz  }
|
t        |«      k  rŒøt        j*                  |«       y)uJ  Apply global formatting flags from 'args' to a leaf command.

    Two modes, depending on the command:

    * **Pass-through commands** (ignore_unknown_options=True, e.g. 'hf extensions exec'):
      args are forwarded verbatim to an external binary; we don't touch them.

    * **Legacy commands with a local --format option** (e.g. 'hf jobs ls' whose '--format' accepts Go templates):
      the global flags are rewritten in-place to the legacy form ('--json' â†’ '--format json', '--quiet'/'-q' â†’ '--format quiet'
      when the cmd has no own '--quiet') so click can parse them locally. This preserves backwards compatibility with the previous shorthand behavior.

    * **Modern commands** (no local format/quiet/json options): the flags '--format <value>' / '--json' / '--quiet' / '-q' are stripped from 'args' and applied to the singleton 'out'.

    '--no-truncate' is stripped for all non-pass-through commands; when present, human table cells are not truncated.

    Raises click.UsageError if multiple conflicting flags are supplied (e.g. '--json' together with '--format table').
    Úignore_unknown_optionsNFrè   Tré   rê   râ   )Úrewrite_jsonÚrewrite_quietÚnew_flagr#   c                 óB   •— ‰�t        j                  d‰› d| › d�«      ‚y )Nrj   z' and 'z' are mutually exclusive.)rP   rs   )rð   Úchosen_flags    €r(   Ú_check_conflictz7_consume_format_flags_for_leaf.<locals>._check_conflictÅ  s1   ø€ ð Ð"Ü×"Ñ" Q { m°7¸8¸*ÐD]Ð#^Ó_Ð_ð #r*   r   r‹   r   z#Option '--format' requires a value.r�   ú	--format=)rê   ré   )Úcontext_settingsr¼   Ú_consume_no_truncate_flagsr   Úset_no_truncater–   rS   rP   r   r†   rš   Ú_rewrite_legacy_shorthandsr   ÚautorÙ   r›   rs   Ú_parse_format_valuerp   ÚjsonÚquietÚset_mode)r^   re   Úno_truncateÚhas_local_formatÚhas_local_quietÚhas_local_jsonr‡   r†   Úchosen_moderó   r¦   r”   rò   s               @r(   ry   ry   —  s>  ø€ ð$ ×Ñ×ÑÐ 8Ô9Øä,¨TÓ2€KÜ×Ñ˜Ô$àÐØ€OØ€NØ—‘ò 	"ˆÜ˜%¤§¡Ô.ØØ3�—‘Ð3˜e×2Ñ2Ñ3ˆØ˜ÑØ#ÐØ˜Ñ ¨¡Ø"ˆOØ�tÒØ!‰Nð	"ñ Ü" 4¸.Ð6HÐ\kÐXkÕlØô !-× 1Ñ 1€KØ"€Kð`¤#ð `¨$õ `ð 	
€AØ
Œc�$‹iŠ-Ø�1‰gˆØ�$Š;ØØ�*ÒÙ˜JÔ'Ø�1‰uœ˜D›	Ò!Ü×&Ñ&Ð'LÓMÐMÜ-¨d°1°q±5©kÓ:ˆKØ$ˆKØ�Q˜˜Q™�Y�ØØ�>‰>˜+Ô&Ù˜JÔ'Ü-¨c´#°kÓ2BÐ2DÐ.EÓFˆKØ$ˆKØ�Q˜˜Q™�Y�ØØ�(Š?Ù˜HÔ%Ü&×+Ñ+ˆKØ"ˆKØ�Q˜˜Q™�Y�ØØÐ#Ñ#Ù˜CÔ Ü&×,Ñ,ˆKØˆKØ�Q˜˜Q™�Y�ØØ	ˆQ‰ˆð= Œc�$‹i‹-ô@ ‡L�L�Õr*   c                 óØ   — d}d}|t        | «      k  rW| |   }|dk(  r	 |S |dk(  rd}| ||dz   …= Œ+|j                  d«      rt        j                  d«      ‚|dz  }|t        | «      k  rŒW|S )	zSStrip all global --no-truncate flags from args and return whether any was provided.Fr   r‹   rã   Tr   z--no-truncate=z-Option '--no-truncate' does not take a value.)r›   rp   rP   rs   )re   rþ   r¦   r”   s       r(   rö   rö   ð  s�   € à€KØ	€AØ
Œc�$‹iŠ-Ø�1‰gˆØ�$Š;Øð Ðð �/Ò!ØˆKØ�Q˜˜Q™�Y�ØØ�>‰>Ð*Ô+Ü×"Ñ"Ð#RÓSÐSØ	ˆQ‰ˆð Œc�$‹i‹-ð Ðr*   rî   rï   c                ó0  — t        d„ | D «       «      }|r8d| v r4|rt        j                  d«      ‚| j                  d«      }ddg| ||dz    d}|rHd| v rdnd	| v rd	nd
}|�7|rt        j                  d|› d�«      ‚| j                  |«      }ddg| ||dz    y
y
y
)a  Rewrite --json / -q / --quiet to --format ... for legacy commands.

    Used for commands like 'hf jobs ls' that still own their '--format' option.
    The rewrite lets users keep using the global shorthand while click parses
    '--format <value>' locally.
    c              3   óL   K  — | ]  }|d k(  xs |j                  d«      –— Œ y­w)rè   rô   Nr’   r“   s     r(   r3   z-_rewrite_legacy_shorthands.<locals>.<genexpr>	  s'   è ø€ Ò^ÐRU˜S JÑ.ÒM°#·.±.ÀÓ2MÓMÑ^ùs   ‚"$râ   z/'--json' and '--format' are mutually exclusive.rè   rû   r   Trê   ré   Nrj   z(' and '--format' are mutually exclusive.rü   )r•   rP   rs   Úindex)re   rî   rï   Úhas_format_in_argsÚidxÚflags         r(   rø   rø     sÈ   € ô Ñ^ÐY]Ô^Ó^Ðá˜ DÑ(ÙÜ×"Ñ"Ð#TÓUÐUØ�j‰j˜Ó"ˆØ)¨6Ð2ˆˆS�3˜‘7ÐØ!ÐáØ˜t‘|‰t°yÀDÑ7H©)ÈdˆØÐÙ!Ü×&Ñ&¨¨4¨&Ð0XÐ'YÓZÐZØ—*‘*˜TÓ"ˆCØ#-¨wÐ"7ˆD��s˜Q‘wÑð	 ð r*   Úvaluer   c                 ó¦   — 	 t        | «      S # t        $ r: dj                  d„ t         D «       «      }t        j                  d| › d|› d�«      d ‚w xY w)Nrh   c              3   ó4   K  — | ]  }|j                   –— Œ y ­wr°   )r
  rk   s     r(   r3   z&_parse_format_value.<locals>.<genexpr>  s   è ø€ Ò8 a˜!Ÿ'�'Ñ8ùs   ‚zInvalid value for '--format': 'z'. Valid values: rn   )r   Ú
ValueErrorr5   rP   rs   )r
  Úvalids     r(   rú   rú     s`   € ðmÜ˜EÓ"Ð"øÜò mØ—	‘	Ñ8¬<Ô8Ó8ˆÜ×ÑÐ!@ÀÀÐGXÐY^ÐX_Ð_`ÐaÓbÐhlÐlðmús
   ‚
 �AAÚerrorÚlabelra   c                 ó  — |r| j                   �d|› d�| j                  v ry| j                   j                  }d|› d|› d�g}|D ]  \  }}|j                  d|d›d	|› �«       Œ |j                  d
|› d�«       t	        | t
        j                  «      rP| j                  rD|j                  ddj                  t        | j                  «      «      › d�«       t        | dg «       t        | d| j                  dj                  |«      z   «       y)zHAppend a list of available options or commands to a usage error message.Nz
Available z forz

Available z for 'z':z  Ú30sú z
Run 'z --help' for full details.z
Did you mean: rh   ro   Úpossibilitiesrm   r.   )r>   rm   Úcommand_pathrœ   rS   rP   rQ   r  r5   rÁ   rw   )r  r  ra   Úcmd_pathÚlinesr_   rÆ   s          r(   rY   rY   #  sü   € á�E—I‘IÐ%¨:°e°W¸DÐ)AÀUÇ]Á]Ñ)RØØ�y‰y×%Ñ%€HØ˜e˜W F¨8¨*°BÐ7Ð8€EØ ò 2‰ˆˆiØ�‰�r˜$˜s˜ 1 Y KÐ0Õ1ð2à	‡L�L�7˜8˜*Ð$>Ð?Ô@Ü�%œ×+Ñ+Ô,°×1DÒ1DØ�‰Ð'¨¯	©	´&¸×9LÑ9LÓ2MÓ(NÐ'OÈqÐQÔRÜ��¨Ô+ÜˆE�9˜eŸm™m¨d¯i©i¸Ó.>Ñ>Õ?r*   Úfallback_handlerÚextra_commands_providerc                 ó.   ‡ ‡—  G ˆˆ fd„dt         «      }|S )zRReturn a Typer group class that runs a fallback handler before command resolution.c                   óŒ   •‡ — e Zd Zdej                  dee   defˆ ˆfd„Zdej                  dej                  ddfˆ ˆfd„Z
ˆ xZS )ú8fallback_typer_group_factory.<locals>.FallbackTyperGroupr>   re   r#   c                 ó’   •—  ‰|t        | j                  j                  «       «      «      }|�t        |«      ‚t        ‰| �  ||«      S r°   )r—   rL   rÂ   Ú
SystemExitrN   rr   )r\   r>   re   Úfallback_exit_coderd   r  s       €€r(   rr   zHfallback_typer_group_factory.<locals>.FallbackTyperGroup.resolve_command9  sF   ø€ Ù!1°$¼¸D¿M¹M×<NÑ<NÓ<PÓ8QÓ!RÐØ!Ð-Ü Ð!3Ó4Ð4Ü‘7Ñ*¨3°Ó5Ð5r*   r?   Nc                 ó®   •— t         ‰| �  ||«       ‰�6 ‰«       }|r,|j                  d«      5  |j                  |«       d d d «       y y y # 1 sw Y   y xY w)NzExtension commands)rN   rÇ   r¿   rÀ   )r\   r>   r?   Úentriesrd   r  s       €€r(   rÇ   zHfallback_typer_group_factory.<locals>.FallbackTyperGroup.format_commands?  sd   ø€ Ü‰GÑ# C¨Ô3Ø&Ð2Ù1Ó3�ÙØ"×*Ñ*Ð+?Ó@ñ 4Ø!×*Ñ*¨7Ô3÷4ð 4ð ð 3÷4ð 4ús   ®AÁA)rÒ   rÓ   rÔ   rP   r×   rØ   rÙ   rÚ   rr   rÞ   rÇ   rà   )rd   r  r  s   @€€r(   ÚFallbackTyperGroupr  8  sO   ù„ ð	6 u§}¡}ð 	6¸DÀ¹Ið 	6È%ö 	6ð	4 u§}¡}ð 	4À×ATÑATð 	4ÐY]÷ 	4ò 	4r*   r"  ©rG   )r  r  r"  s   `` r(   Úfallback_typer_group_factoryr$  2  s   ù€ ÷4œ_ô 4ð Ðr*   rº   c                 ó¦  — dt         j                  dt         j                  dt         j                  dd fd„}dt        dt         j                  dt         j                  dd fd„}dt         j                  dt         j                  dt
        t           dt
        t           fd„}t        d	| j                  «       › �t        ft        | |xs g |||d
œ«      S )Nr\   r>   r?   r#   c                 ó2   — t        | j                  ||«       y r°   )rE   r=   ©r\   r>   r?   s      r(   rË   z#HFCliCommand.<locals>.format_epilogK  s   € Ü  §¡¨c°9Õ=r*   c                 ó˜   — t        j                  | ||«       t        | «      ry | j                  j	                  d«      ry t        |«       y )Nrí   )r   Úformat_optionsrë   rõ   r¼   ræ   r'  s      r(   r)  z$HFCliCommand.<locals>.format_optionsN  sA   € Ü× Ñ   s¨IÔ6ô (¨Ô-ØØ× Ñ ×$Ñ$Ð%=Ô>ØÜ*¨9Õ5r*   re   c                 ó  — |sg|j                   s[t        d„ | j                  D «       «      r?t        j                  |j                  «       |j                  ¬«       |j                  «        t        j                  | ||«      S )Nc              3   ól   K  — | ],  }t        |t        j                  «      xr |j                  –— Œ. y ­wr°   )rS   rP   r   Úrequired)r1   rb   s     r(   r3   z3HFCliCommand.<locals>.parse_args.<locals>.<genexpr>\  s'   è ø€ ÒUÀA”:˜a¤§¡Ó0Ò?°Q·Z±ZÓ?ÑUùs   ‚24)Úcolor)
Úresilient_parsingr•   r–   rP   ÚechoÚget_helpr-  Úexitr   Ú
parse_args)r\   r>   re   s      r(   r2  z HFCliCommand.<locals>.parse_argsX  sW   € ñ ˜C×1Ò1ÜÑUÈÏÉÔUÔUÜ—
‘
˜3Ÿ<™<›>°·±Õ;Ø—‘”
Ü×#Ñ# D¨#¨tÓ4Ð4r*   r   )rÖ   rº   r+   rË   r)  r2  )
rP   rÜ   r×   rÞ   r   rØ   rÙ   ÚtyperÃ   r   )rº   r+   rË   r)  r2  s        r(   rÑ   rÑ   J  sÕ   € ð>œEŸM™Mð >´·±ð >Ì%×J]ÑJ]ð >Ðbfó >ð6œYð 6¬U¯]©]ð 6Äu×GZÑGZð 6Ð_có 6ð5œŸ™ð 5¬U¯]©]ð 5Ä$ÄsÁ)ð 5ÔPTÔUXÑPYó 5ô Ø
�E×$Ñ$Ó&Ð'Ð(Ü	ˆä*ØØ š BØ*Ø,Ø$ñ	
óð r*   r:   rÐ   c                 ó4   — |€t         } || |ddddgdœ¬«      S )a	  Create a CLI command group with consistent settings.

    The returned group is the app: register commands with ``@group.command(...)``,
    subgroups with ``group.add_group(sub, name=...)``, and a group-level callback
    with ``@group.callback(...)``.

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

    Returns:
        A configured `HFCliTyperGroup` instance.
    Téx   z-hz--help)Úmax_content_widthÚhelp_option_names)r:   r=   Úno_args_is_helprõ   r#  )r:   r=   rÐ   s      r(   Útyper_factoryr9  o  s6   € ð €{ÜˆÙØØØð "%Ø"&¨Ð!1ñ
ô	ð 	r*   c                   óŽ   ‡ — e Zd ZdZdee   ee   z  ddfˆ fd„Zde	de
j                  dz  de
j                  dz  defˆ fd	„Zˆ xZS )
Ú
SoftChoiceaÇ  A click Choice that suggests choices for autocompletion/docs but accepts any string.

    Unlike `click.Choice`, unknown values are passed through as-is instead of raising an error.
    This makes CLI options future-compatible when new server-side values are added.

    Accepts either a sequence of strings or an Enum class:
    ```python
    SoftChoice(SpaceHardware)        # from an enum
    SoftChoice(["a", "b", "c"])      # from a list
    ```
    Úchoicesr#   Nc                 ó¼   •— t        |t        «      r*t        |t        «      r|D �cg c]  }|j                  ‘Œ c}n
t        |«      }t        ‰| �  |d¬«       y c c}w )NT)Úcase_sensitive)rS   r3  Ú
issubclassr   r
  rØ   rN   Ú__init__)r\   r<  rl   Úvaluesrd   s       €r(   r@  zSoftChoice.__init__™  sP   ø€ ä*4°W¼dÔ*CÌ
ÐSZÔ\`ÔHa˜gÖ&˜ˆQ�W‹WÓ&ÔgkÐlsÓgtð 	ô 	‰Ñ˜°ÐÕ5ùò 's   ¦Ar
  r‡   r>   c                 ó„   •— 	 t         ‰| �  |||«      S # t        j                  j                  $ r t        |«      cY S w xY wr°   )rN   ÚconvertrP   Ú
exceptionsÚBadParameterrÙ   )r\   r
  r‡   r>   rd   s       €r(   rC  zSoftChoice.convertŸ  s@   ø€ ð	Ü‘7‘? 5¨%°Ó5Ð5øÜ×Ñ×,Ñ,ò 	Ü�u“:Òð	ús   ƒ ”(?¾?)rÒ   rÓ   rÔ   rÕ   r   rÙ   r3  r   r@  r	   rP   Ú	Parameterr×   rC  rà   rá   s   @r(   r;  r;  Œ  sb   ø„ ñ
ð6 ¨¡°°T±
Ñ :ð 6¸tõ 6ð˜Sð ¨¯©¸4Ñ)?ð ÀeÇmÁmÐVZÑFZð Ð_b÷ ñ r*   r;  c                   ó   — e Zd ZdZdZdZy)ÚRepoTypeÚmodelÚdatasetÚspaceN)rÒ   rÓ   rÔ   rI  rJ  rK  r0   r*   r(   rH  rH  ¦  s   „ Ø€EØ€GØ�Er*   rH  zNThe ID of the repo (e.g. `username/repo-name` or `spaces/username/repo-name`).)r:   r…   r‘   z2The type of repository (model, dataset, or space).rI  )r:   Úshow_defaultzJA 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.z-ez--envz/Set environment variables. E.g. --env ENV=valuez-sz	--secretszvSet secret environment variables. E.g. --secrets SECRET=value or `--secrets HF_TOKEN` to pass your Hugging Face token.z
--env-filez(Read in a file of environment variables.z/Read in a file of secret environment variables.c                  ój   — ddl m}  t        j                  j	                  «       } | «       x}�||d<   |S )zQReturn a copy of ``os.environ`` with the user's HF token injected (if available).r   )Ú	get_tokenÚHF_TOKEN)Úhuggingface_hubrN  ÚosÚenvironÚcopy)rN  Úextended_environr"   s      r(   Ú_get_extended_environrU    s4   € å)ä—z‘z—‘Ó(ÐÙ“ÐˆÐ)Ø',Ð˜Ñ$ØÐr*   ÚenvÚenv_filec                 óÖ   — t        «       }i }|r3|j                  t        t        |«      j	                  «       |¬«      «       | xs g D ]  }|j                  t        ||¬«      «       Œ  |S )zìParse ``-e``/``--env``/``-s``/``--secrets`` and ``--env-file``/``--secrets-file`` CLI args into a dict.

    Uses an extended environment that includes the user's HF token so that
    bare ``--secrets HF_TOKEN`` resolves correctly.
    )rR  )rU  Úupdater   r   Ú	read_text)rV  rW  rT  Úenv_mapÚ	env_values        r(   Úparse_env_mapr]  &  sd   € ô -Ó.ÐØ%'€GÙØ�‰”{¤4¨£>×#;Ñ#;Ó#=ÐGWÔXÔYØ’Y˜Bò Iˆ	Ø�‰”{ 9Ð6FÔGÕHðIà€Nr*   r[  c                 óh   — | sy| j                  «       D ��cg c]  \  }}||xs ddœ‘Œ c}}S c c}}w )z_Convert an env/secrets dict to the ``[{"key": ..., "value": ...}]`` format used by the Hub API.NÚ )r}   r
  )ra   )r[  ÚkÚvs      r(   Úenv_map_to_key_value_listrb  8  s/   € áØØ5<·]±]³_×E©T¨Q°�A ¢ RÓ(ÓEÐEùÓEs   —.z-vz--volumeaV  Mount one or more volumes. Format: hf://[TYPE/]SOURCE:/MOUNT_PATH[:ro]. TYPE is one of: models, datasets, spaces, buckets. TYPE defaults to models if omitted. models, datasets and spaces are always mounted read-only. buckets are read+write by default. E.g. -v hf://org/m:/data or -v hf://datasets/org/ds:/data or -v hf://buckets/org/b:/mnt:roÚvolumeszlist[Volume] | Nonec                 óL  — | syg }| D ]™  }t        |«      }|j                  t        |j                  j                  |j                  j
                  |j                  |j                  |j                  j                  xs d|j                  j                  xs d¬«      «       Œ› |S )a_  Parse volume specs from CLI arguments.

    Format: hf://[TYPE/]SOURCE[/PATH]:/MOUNT_PATH[:ro|:rw]
    Where TYPE is one of: models, datasets, spaces, buckets (defaults to models if omitted).
    SOURCE is the repo/bucket identifier (e.g. 'username/my-model').
    PATH is an optional subfolder inside the repo/bucket.
    MOUNT_PATH starts with '/'.
    Optional ':ro' or ':rw' suffix for read-only or read-write.

    Examples:
        hf://my-org/my-model:/data                (model, implicit type)
        hf://models/my-org/my-model:/data         (model, explicit type)
        hf://datasets/my-org/my-dataset:/data:ro
        hf://buckets/my-org/my-bucket:/mnt
        hf://spaces/my-org/my-space:/app
        hf://datasets/org/ds/train:/data          (with path inside repo)
        hf://buckets/org/b/sub/dir:/mnt           (with path inside bucket)
    N)r3  ÚsourceÚ
mount_pathÚ	read_onlyÚpathÚrevision)
r   rœ   r   re  r3  Úidrf  rg  Úpath_in_repori  )rc  rµ   Úraw_specÚmounts       r(   Úparse_volumesrn  M  s�   € ñ& Øà€FØò 
ˆÜ˜xÓ(ˆØ�‰ÜØ—\‘\×&Ñ&Ø—|‘|—‘Ø ×+Ñ+ØŸ/™/Ø—\‘\×.Ñ.Ò6°$ØŸ™×.Ñ.Ò6°$ôõ		
ð
ð €Mr*   Úvalid_propertiesc                 óF   ‡ — dt         dz  dt        t           dz  fˆ fd„}|S )zJCreate a callback to parse and validate comma-separated expand properties.r
  Nr#   c           	      ó  •— | €y | j                  d«      D �cg c]  }|j                  «       ‘Œ }}|D ]0  }|‰vsŒt        j                  d|› ddj	                  ‰«      › �«      ‚ |D �cg c]  }t        t        |«      ‘Œ c}S c c}w c c}w )Nú,zInvalid expand property: 'z'. Valid values are: rh   )rB   ÚstriprP   rE  r5   r   r;   )r
  rb   Ú
propertiesÚpropro  s       €r(   Ú_parse_expand_propertiesz?make_expand_properties_parser.<locals>._parse_expand_propertiesv  sš   ø€ Øˆ=ØØ).¯©°SÓ)9Ö: A�a—g‘g•iÐ:ˆ
Ð:Øò 	ˆDØÐ+Ò+Ü×(Ñ(Ø0°°Ð6KÈDÏIÉIÐVfÓLgÐKhÐióð ð	ð
 9CÖC°””_ dÕ+ÒCÐCùò ;ùò Ds   ˜BÁ*B	)rÙ   rØ   r;   )ro  rv  s   ` r(   Úmake_expand_properties_parserrw  s  s/   ø€ ð	D¬¨d©
ð 	D´t¼OÑ7LÈtÑ7Sõ 	Dð $Ð#r*   ú-iz--identity-filez6Path to the SSH identity file (forwarded to `ssh -i`).z	--dry-runz,Print the SSH command instead of running it.F)ÚportÚidentity_fileÚdry_runÚdestinationry  rz  r{  c                óž  — dg}|�|dt        |«      gz  }|�|dt        |«      gz  }|j                  | «       |r)t        j                  t	        j
                  |«      «       yt        j                  dt	        j
                  |«      › d�«       t        j                  |«      }t        j                  j                  |j                  ¬«      ‚)z¡Run an interactive `ssh` command to `destination` (`user@host`) and exit with its return code.

    With `dry_run`, print the command instead of running it.
    ÚsshNrx  z-pz	Running `ú`)Úcode)rÙ   rœ   r   ÚtextÚshlexr5   Ú
subprocessÚrunrP   rD  ÚExitÚ
returncode)r|  ry  rz  r{  r^   rµ   s         r(   Úexec_sshr‡  ’  s°   € ð ˆ'€CØÐ Ø�”c˜-Ó(Ð)Ñ)ˆØÐØ�”c˜$“iÐ Ñ ˆØ‡J�Jˆ{ÔÙÜ�‰”—‘˜C“Ô!ØÜ‡H�HˆyœŸ™ C›Ð)¨Ð+Ô,Ü�^‰^˜CÓ €FÜ
×
Ñ
×
Ñ
 V×%6Ñ%6Ð
Ó
7Ð7r*   Úlibrary)rP  Útransformersc                 óh   — 	 t        | «       y# t        $ r t        j                  dd¬«       Y yw xY w)a�  
    Check whether a newer version of a library is available on PyPI.

    If a newer version is found, print a hint pointing at `hf update`.

    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.
    If `HF_HUB_DISABLE_UPDATE_CHECK` is set, the check is skipped entirely.

    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   ‚ Ž 1°1c                 óP  ‡— t         j                  ry 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                  «        | dk(  rt!        «       dk(  rt#        «       }nt%        | «      }|�‰|k(  ry | dk(  rt'        «       }n
t)        «       }d| › d	|› d
‰› d�}|�#| dk(  r|dz  }n	 |ddj+                  |«      › �z  }t-        j.                  |«       y )Nc              3   ó&   •K  — | ]  }|‰v –— Œ
 y ­wr°   r0   )r1   ÚtagÚcurrent_versions     €r(   r3   z$_check_cli_update.<locals>.<genexpr>Ç  s   øè ø€ Ò
; cˆ3�/Ô!Ñ
;ùs   ƒ)ÚrcÚdevi€Q T)ÚparentsÚexist_okrP  ÚbrewzA new version of z (z&) is available! You are using version rn   z
To update, run: hf updatez
To update, run: r  )r   ÚHF_HUB_DISABLE_UPDATE_CHECKÚ	importlibÚmetadataÚversionr•   rQ  rh  ÚexistsÚCHECK_FOR_UPDATE_DONE_PATHÚgetmtimeÚtimer   ÚparentÚmkdirÚtouchr   Ú_fetch_latest_brew_versionÚ_fetch_latest_pypi_versionÚ#_get_huggingface_hub_update_commandÚ _get_transformers_update_commandr5   r   Úhint)rˆ  ÚmtimeÚlatest_versionÚupdate_commandrm   r•  s        @r(   r�  r�  À  sp  ø€ Ü×,Ò,Øä×(Ñ(×0Ñ0°Ó9€Oô Ó
;¨]Ô
;Ô;Øô 
‡w�w‡~�~”i×:Ñ:Ô;Ü—‘× Ñ ¤×!EÑ!EÓFˆÜ�I‰I‹K˜%Ñ 9Ò,Øô 	Œ×	-Ñ	-Ó.×5Ñ5×;Ñ;ÀDÐSWÐ;ÔXÜŒ×	-Ñ	-Ó.×4Ñ4Ô6ð Ð#Ò#Ô(;Ó(=ÀÒ(GÜ3Ó5‰ä3°GÓ<ˆØÐ °NÒ!BØàÐ#Ò#Ü<Ó>‰ä9Ó;ˆà! ' ¨"¨^Ð,<Ð<bÐcrÐbsÐstÐu€GØÐ!ØÛ"ØÐ8Ñ8‘ØØÐ/°·±¸Ó0HÐ/IÐJÑJ�Ü‡H�HˆWÕr*   c                 óÐ   — 	 t        «       j                  d| › d�d¬«      }t        |«       |j                  «       d   d   S # t        $ r t
        j                  dd¬	«       Y y
w xY w)zSFetch the latest version of a library from PyPI. Returns None if the request fails.zhttps://pypi.org/pypi/z/jsonr�   ©ÚtimeoutÚinforž  z.Error while fetching latest version from PyPI.Tr‹  N©r   r¼   r   rû   rŽ  r�  r�  )rˆ  Úresponses     r(   r§  r§  ë  sk   € ðÜ“=×$Ñ$Ð'=¸g¸YÀeÐ%LÐVWÐ$ÓXˆÜ˜HÔ%Ø�}‰}‹˜vÑ& yÑ1Ð1øÜò Ü�‰ÐEÐPTˆÔUÙðús   ‚?A Á A%Á$A%c                  óÈ   — 	 t        «       j                  dd¬«      } t        | «       | j                  «       d   d   S # t        $ r t
        j                  dd¬«       Y y	w xY w)
zkFetch the latest version of the `hf` formula from the Homebrew registry. Returns None if the request fails.z,https://formulae.brew.sh/api/formula/hf.jsonr�   r¯  ÚversionsÚstablez2Error while fetching latest version from Homebrew.Tr‹  Nr²  )r³  s    r(   r¦  r¦  ö  sb   € ðÜ“=×$Ñ$Ð%SÐ]^Ð$Ó_ˆÜ˜HÔ%Ø�}‰}‹˜zÑ*¨8Ñ4Ð4øÜò Ü�‰ÐIÐTXˆÔYÙðús   ‚;> ¾ A!Á A!c                  óZ   — t        «       } | €t        d«      ‚t        j                  | «      S )zÛRun the install-method-appropriate update command for the `hf` CLI.

    Raises CLIError if the installation method can't be determined.
    Returns the subprocess exit code on success/failure of the update itself.
    zeCannot determine how to update huggingface_hub (unknown installation method). Please update manually.)r¨  r   rƒ  Úcall)r^   s    r(   Ú
run_updater¹    s2   € ô .Ó
/€CØ
€{ÜØsó
ð 	
ô �?‰?˜3ÓÐr*   c                  ó®   — t        «       xdk(  r g d¢S xdk(  rt        j                  dk(  r g d¢S xdk(  r g d¢S dk(  rt        j                  ddd	d
dgS 	 y)zlReturn the command to update huggingface_hub as an argv list, or None if the installation method is unknown.rš  )rš  ÚupgradeÚhfÚhf_installerÚnt)Ú
powershellú
-NoProfileú-Commandz-iwr -useb https://hf.co/cli/install.ps1 | iex)Úbashú-cz0curl -LsSf https://hf.co/cli/install.sh | bash -Úpipú-mÚinstallú-UrP  N©r   rQ  r_   ÚsysÚ
executabler0   r*   r(   r¨  r¨    sP   € ä
Ó
ÝÚ,Ð,ÜœrŸw™w¨$šˆ^ÚlÐlÝÚUÐUÛÜ—N‘N D¨%°¸DÐBSÐTÐTØØr*   c                  óš   — t        «       xdk(  rt        j                  dk(  r g d¢S xdk(  r g d¢S dk(  rt        j                  ddddd	gS 	 y
)ziReturn the command to update transformers as an argv list, or None if the installation method is unknown.r½  r¾  )r¿  rÀ  rÁ  z?iwr -useb https://hf.co/cli/install.ps1 | iex -WithTransformers)rÂ  rÃ  zHcurl -LsSf https://hf.co/cli/install.sh | bash -s -- --with-transformersrÄ  rÅ  rÆ  rÇ  r‰  NrÈ  r0   r*   r(   r©  r©    sL   € ä
Ó
ÜœrŸw™w¨$šˆ^òð õ ÚmÐmÛÜ—N‘N D¨%°¸DÀ.ÐQÐQØØr*   r°   )NN)yrÕ   ru   Úimportlib.metadatarœ  rQ  Úrer‚  rƒ  rÉ  r¢  Úcollections.abcr   r   Úenumr   Úpathlibr   Útypingr   r   r	   r
   r   r   rP   rP  r   r   r   Úhuggingface_hub.errorsr   Úhuggingface_hub.utilsr   r   r   r   r   Úhuggingface_hub.utils._dotenvr   Ú
_frameworkr   r   r   r   Ú_help_formatterr   Ú_outputr   r   Ú
get_loggerr�  ÚREPO_LIST_DEFAULT_LIMITr'   r!   rÙ   r)   r4   rØ   r8   rß   r—   ÚintÚFallbackHandlerTr;   r×   rÞ   rE   Úcompilert   rG   rä   rÚ   Ú__annotations__ræ   rÜ   Úboolrë   ry   rö   rø   rú   rs   rY   r3  r$  rÑ   r9  ÚChoicer;  rH  Ú	RepoIdArgÚRepoTypeOptÚRepoTypeOptionalOptÚTokenOptÚ
PrivateOptÚRevisionOptÚLimitOptÚ	AuthorOptÚ	FilterOptÚ	SearchOptÚEnvOptÚ
SecretsOptÚ
EnvFileOptÚSecretsFileOptrÝ   rU  r]  rb  Ú
VolumesOptrn  rw  ÚSshIdentityFileOptÚSshDryRunOptr‡  r‘  r�  r§  r¦  r¹  r¨  r©  r0   r*   r(   ú<module>rñ     s  ðò 1ã Û Û 	Û 	Û Û Û 
Û ß .Ý Ý ß H× Hã ç :Ñ :Ý +÷õ õ 6ç <Ó <Ý *ß &ð 
ˆ×	Ñ	Ó	€ð Ð áÝ,ñ[�c˜D‘jð [¨Gó [ð PÐ ñ˜d 3™ið °c¸D±jð ÈCó ð, �.Ñ
! CÑ
'€Ø˜T #™Y¨¨C©Ð1°3¸±:Ð=Ñ>Ð ÙÐ+°3Ô7€ð' S¨4¡Zð '°e·m±mð 'ÐPU×PcÑPcð 'Ðhló 'ð ˆr�z‰z˜+Ó&€ôKa�gô Kaò\;Ð   $ u¨S°#¨X¡Ñ"7ó ð=°%×2EÑ2Eð =È$ó =ð
 e§m¡mð ¸ó ðV¨¯©ð V¸TÀ#¹Yð VÈ4ó Vðr T¨#¡Yð °4ó ð$8 T¨#¡Yð 8Àð 8ÐVZð 8Ð_có 8ð2m˜sð m ~ó mð@˜u×/Ñ/ð @¸ð @ÀDÈÈsÐTWÈxÉÑDYð @Ð^bó @ð" KOñØ&ðà% b¨$¨u°S¸#°X©Ñ*?Ð&?Ñ@À4ÑGðð 
ˆ/Ñóñ0"˜ð "¨4°©9°tÑ+;ð "ÀtÈIÁó "ñJ˜ð  S¨4¡Zð ¸TÀ/Ñ=RÐUYÑ=Yð Ðevó ô:�—‘ô ô4ˆs�Dô ð ØÙØ]ôðñ€	ð ØÙ
ØØØAôðñ€ð  Øˆt�OÙ
ØØØAØô	ðñÐ ð Øˆ$�JÙ
ØYôðñ€ð Øˆ4�KÙ
Øuôðñ€
ð Øˆ$�JÙ
ØSôðñ€ð ØÙ
Ð.Ô/ð1ñ€ð
 Øˆ$�JÙ
Ð3Ô4ð6ñ€	ð
 Øˆ�I�ÑÙ
ÐZÔ[ð]ñ€	ð
 Øˆ$�JÙ
�Ô ð"ñ€	ð 
Øˆ�I�ÑÙ
ØØØ>ôðñ
€ð Øˆ�I�ÑÙ
ØØðHô	ðñ
€
ð Øˆ$�JÙ
ØØ7ôðñ€
ð Øˆ$�JÙ
Ø>ôðñ€ð˜t C¨ H™~ó ð !ØñØ	ˆc‰�TÑ	ðà�D‰jðð 
ˆ#ˆs�T‰zˆ/Ñóð$F t¨C°°t±¨OÑ'<ð FÀÀdÈ3ÐPSÈ8ÁnÑAUÐX\ÑA\ó Fð Øˆ�I�ÑÙ
ØØðeôð	ñ€
ð#˜4 ™9 tÑ+ð #Ð0Eó #ðL$°H¸_Ñ4Mó $ð( Øˆ4�KÙ
ˆ4Ð"Ð)aÔbðdñÐ ð
 ØÙ
ˆ;ÐKÔLðNñ€ð -1ÈtÐejò8Øð8Ø" T™zð8ØAEÈÁð8Ø^bð8à	ó8ð0L˜gÐ&GÑHð LÈTó Lð,(˜wÐ'HÑIð (Èdó (ðV¨ð °°d±
ó ð C¨$¡Jó ð �Có  ð¨T°#©Y¸Ñ-=ó ð¨$¨s©)°dÑ*:ô r*   