U
    ”Ê¹j·	  ã                   @   sF   d Z ddlmZ ddlmZ ddlmZ ddlmZ G dd	„ d	ƒZ	d
S )zAContain helper class to retrieve/store token from/to local cache.é    )ÚPath)ÚOptionalé   )Ú	constantsé   ©Ú	get_tokenc                   @   sH   e Zd Zeeddœdd„ƒZeee dœdd„ƒZeddœdd	„ƒZdS )
ÚHfFolderN)ÚtokenÚreturnc                 C   s(   t tjƒ}|jjddd� | |¡ 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)r   r   ÚHF_TOKEN_PATHÚparentÚmkdirÚ
write_text)Úclsr
   Z
path_token© r   ú_/var/www/html/bwave/python/venv/lib/python3.8/site-packages/huggingface_hub/utils/_hf_folder.pyÚ
save_token   s    
zHfFolder.save_token)r   c                 C   s   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.
        r   ©r   r   r   r   r   -   s    zHfFolder.get_tokenc                 C   s,   zt tjƒ ¡  W n tk
r&   Y nX dS )zX
        Deletes the token from storage. Does not fail if token does not exist.
        N)r   r   r   ÚunlinkÚFileNotFoundErrorr   r   r   r   Údelete_token<   s    zHfFolder.delete_token)	Ú__name__Ú
__module__Ú__qualname__ÚclassmethodÚstrr   r   r   r   r   r   r   r   r	      s   r	   N)
Ú__doc__Úpathlibr   Útypingr   Ú r   Z_authr   r	   r   r   r   r   Ú<module>   s
   