a
    !f                     @   s&   d Z ddlmZ G dd dejZdS )z*Dictionary storage for OAuth2 Credentials.    )clientc                       s:   e Zd ZdZd fdd	Zdd Zdd Zd	d
 Z  ZS )DictionaryStoragea  Store and retrieve credentials to and from a dictionary-like object.

    Args:
        dictionary: A dictionary or dictionary-like object.
        key: A string or other hashable. The credentials will be stored in
             ``dictionary[key]``.
        lock: An optional threading.Lock-like object. The lock will be
              acquired before anything is written or read from the
              dictionary.
    Nc                    s"   t t| j|d || _|| _dS )z'Construct a DictionaryStorage instance.)lockN)superr   __init___dictionary_key)self
dictionarykeyr   	__class__ h/var/www/html/python-backend/venv/lib/python3.9/site-packages/oauth2client/contrib/dictionary_storage.pyr       s    zDictionaryStorage.__init__c                 C   s4   | j | j}|du rdS tj|}||  |S )zRetrieve the credentials from the dictionary, if they exist.

        Returns: A :class:`oauth2client.client.OAuth2Credentials` instance.
        N)r   getr   r   ZOAuth2Credentials	from_jsonZ	set_store)r	   
serializedcredentialsr   r   r   
locked_get&   s    
zDictionaryStorage.locked_getc                 C   s   |  }|| j| j< dS )zSave the credentials to the dictionary.

        Args:
            credentials: A :class:`oauth2client.client.OAuth2Credentials`
                         instance.
        N)to_jsonr   r   )r	   r   r   r   r   r   
locked_put5   s    zDictionaryStorage.locked_putc                 C   s   | j | jd dS )z:Remove the credentials from the dictionary, if they exist.N)r   popr   )r	   r   r   r   locked_delete?   s    zDictionaryStorage.locked_delete)N)	__name__
__module____qualname____doc__r   r   r   r   __classcell__r   r   r   r   r      s
   
r   N)r   Zoauth2clientr   ZStorager   r   r   r   r   <module>   s   