
    h                         S SK r S SKrS SKrS SKJrJr  S SKJr  S SKJ	r	J
r
JrJrJr  S SKrSSKJrJrJr  \(       a  SSKJrJr  \" S	5       " S
 S\5      5       r\" S5       " S S\5      5       rg)    N)PathPurePosixPath)TemporaryDirectory)AnyTupleTYPE_CHECKINGUnionOptional   )	CloudPathNoStatErrorregister_path_class   )
HttpClientHttpsClienthttpc            	       N  ^  \ rS rSr% SrS\S'   SS.S\\S 4   S\S\S   S	S4U 4S
 jjjr	\
S	\4S j5       rS\S	\4U 4S jjr\
S	\R                   R"                  4S j5       r\
S	\4S j5       r\
S	\4S j5       r\
S	\4S j5       rS'S\S	\4S jjrS'S\S	\4S jjr S(S\S\S\\   S	S4S jjrS)S\S\\   S	S4S jjrS'S\S	\R8                  4S jjrS*S\S\S	\4S jjr\
S	\4S j5       r \
S	\!S   4U 4S  jj5       r"S	\!\#RH                  RJ                  \&4   4S! jr'S	\!\#RH                  RJ                  \&4   4S" jr(S	\!\#RH                  RJ                  \&4   4S# jr)S	\!\#RH                  RJ                  \&4   4S$ jr*S	\!\#RH                  RJ                  \&4   4S% jr+S&r,U =r-$ )+HttpPath   zhttp://r   clientN)r   
cloud_pathpartsreturnc                  > [         TU ]  " U/UQ7SU06  U R                  R                  R	                  S5      (       a%  [        U R                  R                  5      U l        g [        SU R                  R                   35      U l        g )Nr   /)super__init___urlpath
startswithr   _path)selfr   r   r   	__class__s       T/home/james-whalen/.local/lib/python3.13/site-packages/cloudpathlib/http/httppath.pyr   HttpPath.__init__   sq     	;e;F; yy~~((-- $))..) 	
 499>>"234 	
    c                 z    U R                   R                  U R                  R                  R	                  S5      -  $ )z!Cached local version of the file.r   )r   _local_cache_dirr   r   lstripr"   s    r$   _localHttpPath._local#   s,     {{++diinn.C.CC.HHHr&   funcc                    > [         TU ]  " U/UQ70 UD6nUS:X  a?  [        US   5      R                  S5      (       a  U R	                  [        U5      S-   5      $ U$ )N__truediv__r   r   )r   _dispatch_to_pathstrendswith_new_cloudpath)r"   r-   argskwargssupr#   s        r$   r0   HttpPath._dispatch_to_path)   s^    g'>t>v> = Sa\%:%:3%?%?&&s3x#~66 Jr&   c                     U R                   $ N)r   r*   s    r$   
parsed_urlHttpPath.parsed_url4   s    yyr&   c                 .    U R                   R                  $ r9   )r   netlocr*   s    r$   driveHttpPath.drive8   s     yyr&   c                 b    U R                   R                   SU R                   R                   S3$ )Nz://r   )r   schemer=   r*   s    r$   anchorHttpPath.anchor=   s+    ))""#3tyy'7'7&8::r&   c                 L    U R                   [        U R                  5      S-
  S  $ )Nr   )_strlenrB   r*   s    r$   _no_prefix_no_driveHttpPath._no_prefix_no_driveA   s$     yyT[[)A-/00r&   follow_symlinksc                 v    U R                  5       (       d  gU R                  R                  [        U 5      5      $ NFexistsr   dir_matcherr1   r"   rI   s     r$   is_dirHttpPath.is_dirF   s+    {{}} {{&&s4y11r&   c                     U R                  5       (       d  gU R                  R                  [        U 5      5      (       + $ rK   rL   rO   s     r$   is_fileHttpPath.is_fileM   s,    {{}};;**3t9555r&   parentsexist_okmodec                     g r9    )r"   rU   rV   rW   s       r$   mkdirHttpPath.mkdirS   s     	r&   c                 :   U R                  5       (       a   U(       d  [        SU  35      e[        S5      e[        [	        5       R
                  5      S-  nUR                  R                  SSS9  UR                  S5        U R                  R                  X05        g )NzFile already exists: zTouch not implemented for existing HTTP files since we can't update the modified time; use `put()` or write to the file instead.zempty_file.txtT)rU   rV    )rM   FileExistsErrorNotImplementedErrorr   r   nameparentrZ   
write_textr   _upload_file)r"   rV   rW   
empty_files       r$   touchHttpPath.touchX   s    ;;==%(=dV&DEE%< 
 02778;KKJ##D4#@!!"%KK$$Z6r&   c                 J    U R                   R                  U 5      n[        R                  " S S U R
                  S S S UR                  SS5      S UR                  S[        R                  R                  S5      5      R                  5       S 4
5      $ !   [        SU  35      e= f)NzCould not get metadata for sizer   last_modified)
r   _get_metadatar   osstat_resultcloud_prefixgetdatetimefromtimestamp	timestamp)r"   rI   metas      r$   statHttpPath.statg   s    	D;;,,T2D ~~!!##X%6%6%D%DQ%G)+
 	
	D ;D6BCCs   B B"presignexpire_secondsc                 Z    U(       a  [        S5      eU R                  R                  5       $ )Nz'Presigning not supported for HTTP paths)r_   r   geturl)r"   ru   rv   s      r$   as_urlHttpPath.as_url~   s(    %&OPP II	
r&   c                 .    U R                   R                  $ r9   )r!   r`   r*   s    r$   r`   HttpPath.name   s    zzr&   )r   .c                 >   > [         TU ]  U R                  S5      4-   $ )Nr]   )r   rU   r3   )r"   r#   s    r$   rU   HttpPath.parents   s     w$"5"5b"9!;;;r&   c                 >    U R                   R                  " U S40 UD6$ )z1Issue a get request with `urllib.request.Request`GETr   requestr"   r5   s     r$   rn   HttpPath.get       {{""49&99r&   c                 >    U R                   R                  " U S40 UD6$ )z1Issue a put request with `urllib.request.Request`PUTr   r   s     r$   putHttpPath.put   r   r&   c                 >    U R                   R                  " U S40 UD6$ )z2Issue a post request with `urllib.request.Request`POSTr   r   s     r$   postHttpPath.post       {{""4:6::r&   c                 >    U R                   R                  " U S40 UD6$ )z4Issue a delete request with `urllib.request.Request`DELETEr   r   s     r$   deleteHttpPath.delete   s    {{""4<V<<r&   c                 >    U R                   R                  " U S40 UD6$ )z2Issue a head request with `urllib.request.Request`HEADr   r   s     r$   headHttpPath.head   r   r&   )r!   )T)FFN)TN)Fi  ).__name__
__module____qualname____firstlineno__rm   __annotations__r	   r1   r
   r   propertyr   r+   r   r0   urllibparseParseResultr:   r>   rB   rG   boolrP   rS   rZ   re   rk   rl   rs   intry   r`   r   rU   r   r   HTTPResponsebytesrn   r   r   r   r   __static_attributes____classcell__)r#   s   @r$   r   r      s}   L *.	
#z/*
 
 &	

 

 
 I I I
	c 	s 	 FLL44    s     ; ; ; 1S 1 12d 2d 26t 6t 6 TX/3CKC=	
7d 7# 7$ 7
D 
BNN 
.
d 
C 
c 
 c   </ < <:uT[[%=%=u%DE ::uT[[%=%=u%DE :;dkk&>&>&E F ;=%(@(@%(G"H =;dkk&>&>&E F ; ;r&   r   httpsc                   .    \ rS rSr% Sr\\S'   S\S'   Srg)	HttpsPath   zhttps://rm   r   r   rY   N)r   r   r   r   rm   r1   r   r   rY   r&   r$   r   r      s    "L#"r&   r   )ro   r   rk   pathlibr   r   tempfiler   typingr   r   r   r	   r
   r   	cloudpathr   r   r   
httpclientr   r   r   r   rY   r&   r$   <module>r      so      	 ' ' = =  C C 3 VO;y O; O;d W  r&   