
    2yi	                        d dl mZ d dlZd dlZd dlZd dlZd dlZd dlZd dl	m
Z
 d dlZddlmZ  ej                  de       ZddZedd		 	 	 	 	 	 	 	 	 dd
Zy)    )annotationsN)Callable   )__version__zmkdocs.c                    t         j                  j                  | ddt         i      }t         j                  j	                  |      5 }|j                         cd d d        S # 1 sw Y   y xY w)Nz
User-Agentzmkdocs-get-deps/)headers)urllibrequestRequestr   urlopenread)urlreqresps      W/var/www/html/content_weaver/venv/lib/python3.12/site-packages/mkdocs_get_deps/cache.py_download_urlr      s[    
..
 
 |?OP[}=].^
 
_C				$ yy{  s   
A$$A-s   # )downloadcommentc                  t         j                  j                  t        j                  d      d      }t        j                  | j                               j                         dd }t         j                  j                  ||t         j                  j                  |       d   z         }t        t        j                  j                  t        j                  j                        j                               }d|| j                         fz  }t         j                  j!                  |      r	 t#        |d      5 }	|	j%                         }
|
j'                  |      rj|
t)        |      d }
t        |
      }t        j*                  ||z
        |k  r5t,        j/                  d	| d
|  d       |	j1                         cddd       S ddd       t,        j/                  d|  d| d        ||       }t        j:                  |d       | dt=        j>                  d      dd}t#        |d      5 }	|	jA                  d||fz         |	jA                  |       ddd       t        jB                  ||       |S # 1 sw Y   xY w# t2        t4        f$ r7}t,        j/                  t7        |      j8                   d|        Y d}~d}~ww xY w# 1 sw Y   vxY w)a  Downloads a file from the URL, stores it under ~/.cache/, and returns its content.

    For tracking the age of the content, a prefix is inserted into the stored file, rather than relying on mtime.

    Args:
        url: URL to use.
        download: Callback that will accept the URL and actually perform the download.
        cache_duration: How long to consider the URL content cached.
        comment: The appropriate comment prefix for this file format.
    mkdocsmkdocs_url_cacheN    r   s   %s%s downloaded at timestamp rb)secondszUsing cached 'z' for ''z: zDownloading 'z' to 'T)exist_ok.l        08xz.partwbs   %s%d
)"ospathjoinplatformdirsuser_cache_dirhashlibsha256encode	hexdigestsplitextintdatetimenowtimezoneutc	timestampisfileopenreadline
startswithlen	timedeltalogdebugr   OSError
ValueErrortype__name__makedirsrandom	randrangewritereplace)r   cache_durationr   r   	directory	name_hashr!   r,   prefixfliner/   econtenttemp_filenames                  r   download_and_cache_urlrJ      sK   " \88BDVWIszz|,668"=I77<<	9rww/?/?/DQ/G#GHD
h##H$5$5$9$9:DDF
GC-#**,0GGF	ww~~d
	2dD! (Qzz|??6*F.D #D	I))3?DV		N4&uA"FG vvx( ( ( IIcU&a01smGKK	D)fAf..w7<EBM	mT	" a		VSM)*	 JJ}d#N)( ( $ 	2IIa))*"QC011	2 sC   .J :BI9<	J J 1(K9J>J K-KKK)r   strreturnbytes)
r   rK   rA   zdatetime.timedeltar   zCallable[[str], bytes]r   rM   rL   rM   )
__future__r   r+   r%   loggingr    r=   urllib.requestr	   typingr   r#    r   	getLoggerr;   r6   r   rJ        r   <module>rV      s|    "    	     g'(,- (5.	.&. %	.
 . .rU   