
    
                     Z    S r SSKrSSKrSSKJr  SSKJr   " S S\R                  5      rg)zYUtilities for OAuth.

Utilities for making it easier to work with OAuth 2.0
credentials.
    N)_helpers)clientc                   D   ^  \ rS rSrSrU 4S jrS rS rS rS r	Sr
U =r$ )	Storage   z:Store and retrieve a single credential to and from a file.c                 Z   > [         [        U ]  [        R                  " 5       S9  Xl        g )N)lock)superr   __init__	threadingLock	_filename)selffilename	__class__s     0platform/bq/third_party/oauth2client_4_0/file.pyr   Storage.__init__    s!    gt%9>>+;%<!    c                 `   Sn[         R                  " U R                  5         [        U R                  S5      nUR	                  5       nUR                  5          [        R                  R                  U5      nUR                  U 5        U$ ! [         a    Us $ f = f! [         a     U$ f = f)zRetrieve Credential from file.

Returns:
    oauth2client_4_0.client.Credentials

Raises:
    IOError if the file is a symbolic link.
Nrb)r   validate_filer   openreadcloseIOErrorr   Credentialsnew_from_json	set_store
ValueError)r   credentialsfcontents       r   
locked_getStorage.locked_get$   s     t~~.	T^^T*AffhGGGI	 ,,::7CK!!$'   		  		s#   6B 0B BB
B-,B-c                 :   [         R                  R                  U R                  5      (       dR  [         R                  " S5      n [        U R                  S5      R                  5         [         R                  " U5        gg! [         R                  " U5        f = f)zCreate an empty file if necessary.

This method will not initialize the file. Instead it implements a
simple version of "touch" to ensure the file has been created.
   za+bN)ospathexistsr   umaskr   r   )r   	old_umasks     r   _create_file_if_neededStorage._create_file_if_needed>   se     ww~~dnn--I$T^^U+113# .
 #s   $B Bc                     U R                  5         [        R                  " U R                  5        [	        U R                  S5      nUR                  UR                  5       5        UR                  5         g)zWrite Credentials to file.

Args:
    credentials: Credentials, the credentials to store.

Raises:
    IOError if the file is a symbolic link.
wN)r,   r   r   r   r   writeto_jsonr   )r   r    r!   s      r   
locked_putStorage.locked_putK   sP     	##%t~~.%	##%&		r   c                 D    [         R                  " U R                  5        g)zXDelete Credentials file.

Args:
    credentials: Credentials, the credentials to store.
N)r'   unlinkr   )r   s    r   locked_deleteStorage.locked_deleteZ   s     			$..!r   )r   )__name__
__module____qualname____firstlineno____doc__r   r#   r,   r2   r6   __static_attributes____classcell__)r   s   @r   r   r      s$    D"4$" "r   r   )r<   r'   r   oauth2client_4_0r   r   r    r   r   <module>rA      s*     
  % #C"fnn C"r   