XjR"ddlmZddlZddlZddlZddlZddlmZddl m Z ddl Z ddl Z ddl mZddlmZmZddlmZddlmZmZmZdd lmZmZmZe ed fZGd d eZGd dZy)) annotationsN) parsedate)Union)get_route_path)URLHeaders) HTTPException) FileResponseRedirectResponseResponse)ReceiveScopeSendzos.PathLike[str]c$eZdZdZdfd ZxZS)NotModifiedResponse)z cache-controlzcontent-locationdateetagexpiresvaryc t|d|jDcic]\}}||jvs||c}}ycc}}w)Ni0) status_codeheaders)super__init__itemsNOT_MODIFIED_HEADERS)selfrnamevalue __class__s i/mnt/ssd/data/Dropbox/adrian/vault-secondbrain/venv/lib/python3.12/site-packages/starlette/staticfiles.pyrzNotModifiedResponse.__init__ sD 4;MMOi[T5ttOhOhGhT5[i  is A A )rr)__name__ __module__ __qualname__rr __classcell__)r s@r!rrs  rceZdZdddddd ddZ d ddZddZddZdd Zdd Z d dd Z dd Z dd Z y) StaticFilesNFT) directorypackageshtml check_dirfollow_symlinkc||_||_|j|||_||_d|_||_|r2|/tjj|std|dyyy)NF Directory 'z' does not exist) r)r*get_directoriesall_directoriesr+config_checkedr-ospathisdir RuntimeError)rr)r*r+r,r-s r!rzStaticFiles.__init__(su#  #33IxH #, .rww}}Y7OYK7GHI I8P.9r&cg}||j||xsgD]}t|tr|\}}nd}tjj |}| Jd|d|j Jd|dtjjtjj|j d|}tjj|sJd|d|d|j||S)z Given `directory` and `packages` arguments, return a list of all the directories that should be used for serving static files from. staticszPackage z could not be found.z..r/z ' in package ) append isinstancetuple importlibutil find_specoriginr3r4normpathjoinr5)rr)r* directoriespackage statics_dirspecpackage_directorys r!r0zStaticFiles.get_directories:s     y )~2 2G'5)'.$' >>++G4D# Ox{:N%O O#;;* VhwkAU,V V* " 0 0dkk4Q\1] ^ 77==!23 k_M'DXY 3   0 1 2r&cK|ddk(sJ|js|jd{d|_|j|}|j||d{}||||d{y7I77 w)z' The ASGI entry point. typehttpNT)r2 check_configget_path get_response)rscopereceivesendr4responses r!__call__zStaticFiles.__call__WsV}&&&""##% % %"&D }}U#**477ugt,,, &8,s3*A<A61A<A8A<0A:1A<8A<:A<ct|}tjjtjj|j dS)z Given the ASGI scope, return the `path` string to serve up, with OS specific path separators, and any '..', '.' components removed. /)rr3r4r@rAsplit)rrM route_paths r!rKzStaticFiles.get_pathes; $E* ww j.>.>s.C DEEr&cK|ddvr td tjj|j|d{\}}|r2tj|jr|j|||S|rtj|jr|jrt j"j%|d}tjj|j|d{\}}|}tj|jr^|d j'd s7t)| }|j+|j"d z }t-| S|j|||S|jrdtjj|jdd{\}}|r-tj|jrt/||dStd7#t $r tdt $r0}|jtjk(r td|d}~wt$r tdwxYw7j7w)z` Returns an HTTP response, given the incoming path, method and request headers. method)GETHEADi)rNiiz index.htmlr4rSrM)r4)urlz404.html) stat_resultr)r anyio to_threadrun_sync lookup_pathPermissionErrorOSErrorerrno ENAMETOOLONG ValueErrorstatS_ISREGst_mode file_responseS_ISDIRr+r3r4rAendswithrreplacer r )rr4rM full_pathr\exc index_pathr[s r!rLzStaticFiles.get_responsems ?/ 1C0 0 1+0??+C+CDDTDTVZ+[%[ "I{ 4<< (;(;<%%ieD D T\\+*=*=>499dL9J+0??+C+CDDTDTV`+a%a "I{&4<< 8K8K+LV}--c2E*C++388c>+:C+44)))[%HH 99+0??+C+CDDTDTV`+a%a "I{t||K,?,?@#I;TWXX,,G&\ 1C0 0 yyE...#44I 1C0 0 1&b&bs[I)-HG=H B.I):I$;B?I):I';AI)=HI!+II!!I)'I)cV|jdry|jD]}tjj ||}|j r?tjj |}tjj |}n>tjj|}tjj|}tjj||gt|k7r |tj|fcSy#ttf$rYwxYw)N)rS\)N) startswithr1r3r4rAr-abspathrealpath commonpathstrrfFileNotFoundErrorNotADirectoryError)rr4r) joined_pathrms r!r`zStaticFiles.lookup_paths ??; '-- I'',,y$7K""GGOOK8 GGOOI6 GG,,[9 GG,,Y7 ww!!9i"89S^K  "'')"444 &'9:  s:DD('D(ct|}t|||}|j|j|rt |jS|S)NrZ)rr\)rr is_not_modifiedrr)rrmr\rMrrequest_headersrPs r!rizStaticFiles.file_responsesI". {P[\    0 0/ B&x'7'78 8r&cK|jy tjjtj |jd{}t j|js9t j|jstd|jdyy7]#t $rtd|jdwxYww)z Perform a one-off configuration check that StaticFiles is actually pointed at a directory, so that we can raise loud errors rather than just returning 404 responses. NzStaticFiles directory 'z' does not exist.zStaticFiles path 'z' is not a directory.) r)r]r^r_r3rfrxr6rjrhS_ISLNK)rr\s r!rJzStaticFiles.check_configs >> !  \ % 8 8$.. QQK [001T\\+BUBU5V!3DNN3CCXYZ Z6W1R  \!88HHYZ[ [ \s/C;B, B* B,AC*B,,#CCc&|jdx}rC|d}||jdDcgc]!}|jjd#c}vS t |d}t |d}||||k\ryycc}w#t $rYywxYw) z Given the request and response headers, return `True` if an HTTP "Not Modified" response could be returned instead. z if-none-matchr,zW/zif-modified-sincez last-modifiedTF)getrTstrip removeprefixrKeyError)rresponse_headersr} if_none_matchrtagif_modified_since last_modifieds r!r|zStaticFiles.is_not_modifieds ,//@ @= @#F+DmFYFYZ]F^_sCIIK44T:__ _  )/:M*N O %&6&GHM ,1JO`dqOq`   s&A?%B BB) r)PathLike | Noner*"list[str | tuple[str, str]] | Noner+boolr,rr-rreturnNone)NN)r)rr*rrzlist[PathLike])rMrrNr rOrrr)rMrrrw)r4rwrMrrr )r4rwrz!tuple[str, os.stat_result | None])) rmPathLiker\zos.stat_resultrMrrintrr )rr)rrr}rrr) r"r#r$rr0rQrKrLr`rirJr|r&r!r(r('s&*7;$J#J5 J  J  JJ J(&*7;"5  : -F+-Z4  $      [ r&r() __future__rrcimportlib.utilr<r3rf email.utilsrtypingrr]anyio.to_threadstarlette._utilsrstarlette.datastructuresrrstarlette.exceptionsr starlette.responsesr r r starlette.typesr rrrwrrr(rr&r!rs]"  ! +1.HH00 (( ) ( "xxr&