
    (ph                     >   S r SSKJr  SSKrSSKrSSKrSSKrSSKr SSKJ	r	  SSKJr  SS	KJr  \R                   " \5      rS
r\R                  " SSS5      rS rS r " S S\R.                  5      r\" \S9rg! \
 a     SSKJ	r	   Ne! \
 a	    \
" S5      ef = ff = f)a  File based cache for the discovery document.

The cache is stored in a single file so that multiple processes can
share the same cache. It locks the file whenever accessing to the
file. When the cache content is corrupted, it will be initialized with
an empty cache.
    )divisionN)
LockedFilezIfile_cache is unavailable when using oauth2client >= 4.0.0 or google-auth   )base   )DISCOVERY_DOC_MAX_AGEz,google-api-python-client-discovery-doc.cachei  c                      U [         -
  R                  5       $ ! [         a>    U [         -
  nUR                  UR                  UR
                  S-  S-  -   S-  -   S-  s $ f = f)N   i  i@B )EPOCHtotal_secondsAttributeErrormicrosecondssecondsdays)datedeltas     ]/var/www/html/venv/lib/python3.13/site-packages/googleapiclient/discovery_cache/file_cache.py_to_timestampr   4   sj    u++--  u%--%**r/D2H"HE!QQ 		s    AA! A!c                 x   U R                  5       R                  S5         [        R                  " U R                  5       5      nU$ ! [         ah    0 nU R                  5       R                  S5        U R                  5       R                  S5        [        R                  " XR                  5       5         U$ f = fNr   )file_handleseekjsonload	Exceptiontruncatedump)fcaches     r   _read_or_initialize_cacher    @   s    MMO*		!--/* L  * 	  #	Q		%)L*s   $A A.B98B9c                   *    \ rS rSrSrS rS rS rSrg)CacheN   z/A file based cache for the discovery documents.c                    Xl         [        R                  R                  [        R
                  " 5       [        5      U l        [        U R                  SS5      n UR                  5         UR                  5       (       a  [        U5        UR                  5         g! [         a  n[        R                  USS9   SnAN4SnAff = f! UR                  5         f = f)z<Constructor.

Args:
  max_age: Cache expiration in seconds.
za+rTexc_infoN)_max_ageospathjointempfile
gettempdirFILENAME_filer   open_and_lock	is_lockedr    r   LOGGERwarningunlock_and_close)selfmax_ager   es       r   __init__Cache.__init__Q   s      WW\\("5"5"7B
tzz4-		!OO{{}})!,    	-NN1tN,	-  s*   0B 
C&B?:C ?CC Cc                 l   [        U R                  SS5      n UR                  5         UR                  5       (       a  [	        U5      nX;   a]  UR                  US5      u  pE[        [        R                  R                  5       5      XPR                  -   :  a  UUR                  5         $  UR                  5         g [        R                  S5         UR                  5         g ! [         a  n[        R                  USS9   S nAOS nAff = f UR                  5         g ! UR                  5         f = f)Nr+r%   r   +Could not obtain a lock for the cache file.Tr&   )r   r/   r0   r1   r    getr   datetimenowr(   r4   r2   debugr   r3   )r5   urlr   r   contenttr7   s          r   r=   	Cache.gete   s    tzz4-	!OO{{}}1!4<!&3	!:JG$X%6%6%:%:%<=MM@QQ&      JK    	-NN1tN,	-, A s0   BC$ =C$ $
D.DD! DD! !D3c                 <   [        U R                  SS5      n UR                  5         UR                  5       (       a  [	        U5      nU[        [        R                  R                  5       5      4XA'   [        UR                  5       5       HC  u  nu  pg[        [        R                  R                  5       5      XpR                  -   :  d  MA  XE	 ME     UR                  5       R                  S5        UR                  5       R                  S5        [        R                  " XCR                  5       5        O[         R#                  S5         UR)                  5         g ! [$         a  n[         R'                  USS9   S nAN4S nAff = f! UR)                  5         f = f)Nr;   r%   r   r<   Tr&   )r   r/   r0   r1   r    r   r>   r?   listitemsr(   r   r   r   r   r   r2   r@   r   r3   r4   )	r5   rA   rB   r   r   k_	timestampr7   s	            r   set	Cache.setx   s)   tzz4-	!OO{{}}1!4%}X5F5F5J5J5L'MN
)-ekkm)<%A~%h&7&7&;&;&=>$}}45 "H *= ((+$$Q'		%1JK    	-NN1tN,	-  sC   B1E A(E 6F	 7E F	 
F(F<F	 FF	 	F)r/   r(   N)	__name__
__module____qualname____firstlineno____doc__r8   r=   rK   __static_attributes__     r   r"   r"   N   s    9!(!&!rT   r"   )r6   )rQ   
__future__r   r>   r   loggingr)   r,    oauth2client.contrib.locked_filer   ImportErroroauth2client.locked_file r   discovery_cacher   	getLoggerrM   r2   r.   r   r   r    r"   r   rS   rT   r   <module>r]      s         	 

;  3			8	$9$1%	@!DJJ @!F 	+,a  

7 
W
 	

	
s   A: :BB		BB