
    g                     \    d Z ddlZddlmZ ddlmZ ddlmZ ddlm	Z	  G d	 d
          Z
dS )zAContain helper class to retrieve/store token from/to local cache.    N)Path)Optional   )	constants   )	get_tokenc                       e Zd Z eej                  Z eej                  Ze	de
ddfd            Ze	dee
         fd            Ze	dd            Ze	d             ZdS )	HfFoldertokenreturnNc                 |    | j         j                            dd           | j                             |           dS )a  
        Save token, creating folder as needed.

        Token is saved in the huggingface home folder. You can configure it by setting
        the `HF_HOME` environment variable.

        Args:
            token (`str`):
                The token to save to the [`HfFolder`]
        T)parentsexist_okN)
path_tokenparentmkdir
write_text)clsr   s     \/var/www/html/ai-engine/env/lib/python3.11/site-packages/huggingface_hub/utils/_hf_folder.py
save_tokenzHfFolder.save_token    s>     	##D4#@@@!!%(((((    c                 j    	 |                                   n# t          $ r Y nw xY wt                      S )aB  
        Get token or None if not existent.

        This method is deprecated in favor of [`huggingface_hub.get_token`] but is kept for backward compatibility.
        Its behavior is the same as [`huggingface_hub.get_token`].

        Returns:
            `str` or `None`: The token, `None` if it doesn't exist.
        )_copy_to_new_path_and_warn	Exceptionr   r   s    r   r   zHfFolder.get_token1   sH    	**,,,, 	 	 	D	 {{s    
$$c                     	 | j                                          n# t          $ r Y nw xY w	 | j                                         dS # t          $ r Y dS w xY w)zX
        Deletes the token from storage. Does not fail if token does not exist.
        N)r   unlinkFileNotFoundError_old_path_tokenr   s    r   delete_tokenzHfFolder.delete_tokenF   s    
	N!!####  	 	 	D		&&(((((  	 	 	DD	s    
))A 
AAc                    | j                                         rl| j                                        sU|                     | j                                                    t          j        d| j          d| j         d           d S d S d S )NzA token has been found in `zG`. This is the old path where tokens were stored. The new location is `z` which is configurable using `HF_HOME` environment variable. Your token has been copied to this new location. You can now safely delete the old token file manually or use `huggingface-cli logout`.)r   existsr   r   	read_textwarningswarnr   s    r   r   z#HfFolder._copy_to_new_path_and_warnU   s    %%'' 		0E0E0G0G 		NN3.88::;;;M-c.A - -^- - -    		 		 		 		r   )r   N)__name__
__module____qualname__r   r   HF_TOKEN_PATHr   _OLD_HF_TOKEN_PATHr   classmethodstrr   r   r   r    r    r   r   r
   r
      s        i-..Jd9788O )s )t ) ) ) [)  (3-    [(    [ 
 
 [
 
 
r   r
   )__doc__r$   pathlibr   typingr    r   _authr   r
   r-   r   r   <module>r3      s    H G                         G G G G G G G G G Gr   