Ë
    Q^(hô  ã            	       ó$  — d 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	m
Z
  ej                  dej                  ej                  z  ej                  z  ¬	«      Zdd
ee   dee   fd„Zddeded
ee   ddfd„Zdded
ee   ddfd„Zdedee   fd„Zy)z-Contains utilities to manage Git credentials.é    N)ÚListÚOptionalé   )ÚENDPOINTé   )Úrun_interactive_subprocessÚrun_subprocesszÈ
        ^\s* # start of line
        credential\.helper # credential.helper value
        \s*=\s* # separator
        (\w+) # the helper name (group 1)
        (\s|$) # whitespace or end of line
    )ÚflagsÚfolderÚreturnc                 ó¬   — 	 t        d| ¬«      j                  }t        |«      }|S # t        j                  $ r}t        |j                  «      ‚d}~ww xY w)a“  Return the list of git credential helpers configured.

    See https://git-scm.com/docs/gitcredentials.

    Credentials are saved in all configured helpers (store, cache, macOS keychain,...).
    Calls "`git credential approve`" internally. See https://git-scm.com/docs/git-credential.

    Args:
        folder (`str`, *optional*):
            The folder in which to check the configured helpers.
    zgit config --list©r   N)r	   ÚstdoutÚ_parse_credential_outputÚ
subprocessÚCalledProcessErrorÚEnvironmentErrorÚstderr)r   ÚoutputÚparsedÚexcs       úc/var/www/skyplay_api_hub/venv/lib/python3.12/site-packages/huggingface_hub/utils/_git_credential.pyÚlist_credential_helpersr   %   sN   € ð+ÜÐ 3¸FÔC×JÑJˆÜ)¨&Ó1ˆØˆøÜ×(Ñ(ò +Ü˜sŸz™zÓ*Ð*ûð+ús   ‚#& ¦A¹AÁAÚtokenÚusernamec           
      óÈ   — t        d|¬«      5 \  }}|j                  dt        › d|j                  «       › d| › d�«       |j	                  «        ddd«       y# 1 sw Y   yxY w)a«  Save a username/token pair in git credential for HF Hub registry.

    Credentials are saved in all configured helpers (store, cache, macOS keychain,...).
    Calls "`git credential approve`" internally. See https://git-scm.com/docs/git-credential.

    Args:
        username (`str`, defaults to `"hf_user"`):
            A git username. Defaults to `"hf_user"`, the default user used in the Hub.
        token (`str`, defaults to `"hf_user"`):
            A git password. In practice, the User Access Token for the Hub.
            See https://huggingface.co/settings/tokens.
        folder (`str`, *optional*):
            The folder in which to check the configured helpers.
    zgit credential approver   úurl=z

username=z

password=z

N)r   Úwriter   ÚlowerÚflush)r   r   r   ÚstdinÚ_s        r   Úset_git_credentialr#   9   sc   € ô 
$Ð$<ÀVÔ	Lð ñ QØØ	à�‰�dœ8˜* K°·±Ó0@Ð/AÀÈUÈGÐSWÐXÔYØ�‰Œ÷÷ ñ ús   ŽAAÁA!c                 óà   — t        d|¬«      5 \  }}dt        › d�}| �|d| j                  «       › d�z  }|dz  }|j                  |«       |j	                  «        ddd«       y# 1 sw Y   yxY w)aY  Erase credentials from git credential for HF Hub registry.

    Credentials are erased from the configured helpers (store, cache, macOS
    keychain,...), if any. If `username` is not provided, any credential configured for
    HF Hub endpoint is erased.
    Calls "`git credential erase`" internally. See https://git-scm.com/docs/git-credential.

    Args:
        username (`str`, defaults to `"hf_user"`):
            A git username. Defaults to `"hf_user"`, the default user used in the Hub.
        folder (`str`, *optional*):
            The folder in which to check the configured helpers.
    zgit credential rejectr   r   ú
Nz	username=)r   r   r   r   r    )r   r   r!   r"   Ústandard_inputs        r   Úunset_git_credentialr'   P   s~   € ô 
$Ð$;ÀFÔ	Kð 
ñ PØØ	à¤˜z¨Ð,ˆØÐØ 	¨(¯.©.Ó*:Ð);¸2Ð>Ñ>ˆNØ˜$Ñˆà�‰�NÔ#Ø�‰Œ÷
÷ 
ñ 
ús   ŽAA$Á$A-r   c                 ó^   — t        t        d„ t        j                  | «      D «       «      «      S )z›Parse the output of `git credential fill` to extract the password.

    Args:
        output (`str`):
            The output of `git credential fill`.
    c              3   ó&   K  — | ]	  }|d    –— Œ y­w)r   N© )Ú.0Úmatchs     r   ú	<genexpr>z+_parse_credential_output.<locals>.<genexpr>v   s   è ø€ ò 
ØˆE�!�Hñ
ùs   ‚)ÚsortedÚsetÚGIT_CREDENTIAL_REGEXÚfindall)r   s    r   r   r   k   s1   € ô Üñ 
Ü"6×">Ñ">¸vÓ"Fô
ó 	
óð ó    )N)Úhf_userN)Ú__doc__Úrer   Útypingr   r   Ú	constantsr   Ú_subprocessr   r	   ÚcompileÚ	MULTILINEÚ
IGNORECASEÚVERBOSEr0   Ústrr   r#   r'   r   r*   r2   r   ú<module>r>      sÃ   ðñ 4ã 	Û ß !å  ß Cð "�r—z‘zðð �,‰,˜Ÿ™Ñ
&¨¯©Ñ
3ô	Ð ñ+ H¨S¡Mð +¸TÀ#¹Yó +ñ(˜cð ¨Sð ÀhÈsÁmð Ð_có ñ. 3ð ¸HÀS¹Mð ÐUYó ð6 Sð ¨T°#©Yô r2   