ó
    Ú°›j`  ã                   ó    • S r SSKrSSKrSSKJr  SSKrSSKr\R                  R                  S5      r
SS\S\SS4S jjrSS\4S	 jjrSS
 jrg)z�
runpod | cli | config.py

A collection of functions to set and validate configurations.
Configurations are TOML files located under ~/.runpod/
é    N)ÚPathz~/.runpod/config.tomlÚapi_keyÚprofileÚreturnc                 ó€  • [         R                  R                  [        5      n[         R                  " USS9  [        [        5      R                  SS9  [        [        SSS9 n UR                  5       nUR                  5       (       a  [        R                  " U5      O[        R                  " 5       n SSS5        U(       d  UW;   a  [        S5      eS	U 0WU'   [         R"                  " US
S9u  p‰ [         R$                  " USSS9 n
[        R&                  " Xj5        SSS5        [         R(                  " U	[        5        g! [        R                  R                   a  n[        S5      UeSnAff = f! , (       d  f       NÈ= f! , (       d  f       Nm= f! [*         a    [         R,                  " U	5        e f = f)a  
Sets the user's credentials in ~/.runpod/config.toml
If profile already exists user must pass overwrite=True.

Args:
    api_key (str): The user's API key.
    profile (str): The profile to set the credentials for.

--- File Structure ---

[default]
api_key = "RUNPOD_API_KEY"
T)Úexist_okÚrzUTF-8)Úencodingú/~/.runpod/config.toml is not a valid TOML file.NzFProfile already exists. Use set_credentials(overwrite=True) to update.r   z.toml)ÚdirÚsuffixÚw)ÚosÚpathÚdirnameÚCREDENTIAL_FILEÚmakedirsr   ÚtouchÚopenÚreadÚstripÚtomlkitÚparseÚdocumentÚ
exceptionsÚ
ParseErrorÚ
ValueErrorÚtempfileÚmkstempÚfdopenÚdumpÚreplaceÚBaseExceptionÚunlink)r   r   Ú	overwriteÚcred_dirÚ	cred_fileÚcontentÚconfigÚexcÚfdÚtmp_pathÚtmp_files              Ú_/home/mande/repo/quber/.venv/lib/python3.13/site-packages/runpod/cli/groups/config/functions.pyÚset_credentialsr/      sb  € ô �w‰w�‰œÓ/€HÜ‡K‚K� 4Ò(ÜŒÓ×Ñ¨ÐÑ.ä	Œo˜s¨WÒ	5¸ð	YØ—n‘nÓ&ˆGð —=‘=—?‘?ô —’˜gÔ&ä×%Ò%Ó'ñ ÷ 
6ö Ø�fÓÜØXóð ð ! 'Ð*€Fˆ7�Oä×#Ò#¨¸ÑA�L€BðÜ�YŠY�r˜3¨Ò1°XÜ�LŠL˜Ô*÷ 2ä
�
Š
�8œ_Õ-øô ×!Ñ!×,Ñ,ó 	YÜÐNÓOÐUXÐXûð	Yú÷ 
6Õ	5ú÷* 2Õ1ûô ó Ü
�	Š	�(ÔØðúsO   Á$E9Á&AEÃ6F ÄF
Ä##F ÅE6Å%E1Å1E6Å6E9Å9
FÆ

FÆF Æ"F=c                 óB  • [         R                  R                  [        5      (       d  g [	        [        S5       n[
        R                  " U5      nSSS5        U W;  a  SSU  S34$ SX    ;  a  SSU  S34$  g
! , (       d  f       N.= f! [        [        4 a     g	f = f)z5
Checks if the credentials file exists and is valid.
)Fz%~/.runpod/config.toml does not exist.ÚrbNFz!~/.runpod/config.toml is missing z	 profile.r   z-~/.runpod/config.toml is missing api_key for )Fr   )TN©	r   r   Úexistsr   r   ÚtomlÚloadÚ	TypeErrorr   )r   r'   r)   s      r.   Úcheck_credentialsr7   A   s®   € ô �7‰7�>‰>œ/×*Ñ*Ø=ðHÜ”/ 4Ô(¨IÜ—Y’Y˜yÓ)ˆF÷ )ð ˜&Ó ØÐ=¸g¸YÀiÐPÐPÐPà˜F™OÓ+àØ?À¸yÈ	ÐRðð ð ,ð ÷ )Õ(ûô ”zÐ"ó HÙGðHús.   «B »A:ÁB Á(B Á:
BÂB ÂBÂBc                 ó  • [         R                  R                  [        5      (       d  g [	        [        S5       n[
        R                  " U5      nSSS5        U W;  a  gX    $ ! , (       d  f       N= f! [        [        4 a     gf = f)z¶
Returns the credentials for the specified profile from ~/.runpod/config.toml

Returns None if the file does not exist, is not valid TOML, or does not
contain the requested profile.
Nr1   r2   )r   r'   Úcredentialss      r.   Úget_credentialsr:   \   ss   € ô �7‰7�>‰>œ/×*Ñ*ØðÜ”/ 4Ô(¨IÜŸ)š) IÓ.ˆK÷ )ð
 �kÓ!ØàÑÐ÷ )Õ(ûä”zÐ"ó Ùðús.   «A6 »A%ÁA6 Á%
A3Á/A6 Á3A6 Á6B	ÂB	)ÚdefaultF)r;   )Ú__doc__r   r   Úpathlibr   Útomlir4   r   r   Ú
expanduserr   Ústrr/   r7   r:   © ó    r.   Ú<module>rC      s]   ðñó 
Û Ý ã Û à—'‘'×$Ñ$Ð%<Ó=€ñ,˜Sð ,¨3ð ,ÐPTõ ,ñ^˜sõ õ6 rB   