
    _jL                    j   S SK Jr  S SKrS SKrS SKrS SKJrJrJr  S SK	J
r
Jr  S SKrSSKJrJrJrJrJrJrJr  SSKJrJrJrJrJr  \
" S5      rSS	 jrSS
 jrSS.SS jjr\SS j5       r\SS j5       rSS jrSS jr S S jr!\SS j5       r"\SS j5       r"SS jr"SS jr#S S jr$S!S jr%S"S jr&g)#    )annotationsN)Sequencecastoverload)TypeVar	TypeGuard   )	FileTypesFileContentRequestFilesHttpxFileTypesBase64FileInputHttpxFileContentHttpxRequestFiles)is_list
is_mapping
is_tuple_tis_mapping_tis_sequence_t_Tc                x    [        U [        R                  5      =(       d    [        U [        R                  5      $ N)
isinstanceioIOBaseosPathLikeobjs    D/home/rurouni/.local/lib/python3.13/site-packages/parallel/_files.pyis_base64_file_inputr!      s#    c299%EC)EE    c                    [        U [        5      =(       dR    [        U [        5      =(       d;    [        U [        R                  5      =(       d    [        U [
        R                  5      $ r   )r   bytestupler   r   r   r   r   s    r    is_file_contentr&      sB    3v*S%"8vJsBII<VvZdehjljujuZvr"   )keyc               z    [        U 5      (       d+  Ub  SU S3OSU < S3n[        U S[        U 5       S35      S eg )NzExpected entry at ``zExpected file input `zF to be bytes, an io.IOBase instance, PathLike or a tuple but received z	 instead.)r&   RuntimeErrortype)r   r'   prefixs      r    assert_is_file_contentr-   #   s^    314&se1-H]^a]ddeFfh\]abe]f\ggpq
	  r"   c                    g r    filess    r    to_httpx_filesr2   +   s    ),r"   c                    g r   r/   r0   s    r    r2   r2   /   s    >Ar"   c                8   U c  g [        U 5      (       a0  U R                  5        VVs0 s H  u  pU[        U5      _M     n nnU $ [        U 5      (       a#  U  VVs/ s H  u  pU[        U5      4PM     n nnU $ [	        S[        U 5       S35      es  snnf s  snnf )NzUnexpected file type input z, expected mapping or sequence)r   items_transform_filer   	TypeErrorr+   r1   r'   files      r    r2   r2   3   s    }E=B[[]K]	od++]K L 
u		?DEu)##t,-uE L 5d5k]B`abb	 LEs   BBc                0   [        U 5      (       aS  [        U [        R                  5      (       a2  [        R
                  " U 5      nUR                  UR                  5       4$ U $ [        U 5      (       a  U S   [        U S   5      /U SS  Q7$ [        S5      eNr   r	      zCExpected file types input to be a FileContent type or to be a tuple)r&   r   r   r   pathlibPathname
read_bytesr   read_file_contentr7   r9   paths     r    r6   r6   A   s    tdBKK((<<%DIIt011$Q*473?d12h??
Y
[[r"   c                    [        U [        R                  5      (       a$  [        R                  " U 5      R                  5       $ U $ r   )r   r   r   r=   r>   r@   r9   s    r    rA   rA   O   s0    $$$||D!,,..Kr"   c                   #    g 7fr   r/   r0   s    r    async_to_httpx_filesrG   U   s     58   c                   #    g 7fr   r/   r0   s    r    rG   rG   Y   s     JMrH   c                N  #    U c  g [        U 5      (       a8  U R                  5        VVs0 s H  u  pU[        U5      I S h  vN _M     n nnU $ [        U 5      (       a+  U  VVs/ s H  u  pU[        U5      I S h  vN 4PM     n nnU $ [	        S5      e NSs  snnf  N!s  snnf 7f)NzFUnexpected file type input {type(files)}, expected mapping or sequence)r   r5   _async_transform_filer   r7   r8   s      r    rG   rG   ]   s     }EINWIC1$777W L 
u		KPQ5ic#248895Q L `aa	 8W8QsL   (B%BBB
B%$B;B<	BB%BB%BB%c                `  #    [        U 5      (       a[  [        U [        R                  5      (       a:  [        R
                  " U 5      nUR                  UR                  5       I S h  vN 4$ U $ [        U 5      (       a!  U S   [        U S   5      I S h  vN /U SS  Q7$ [        S5      e NC N7fr;   )r&   r   r   r   anyior>   r?   r@   r   async_read_file_contentr7   rB   s     r    rK   rK   k   s     tdBKK((::d#DIIT__%6677$Q6tAw??K$qr(KK
Y
[[  7
 @s$   A$B.&B*',B.B,B.,B.c                   #    [        U [        R                  5      (       a,  [        R                  " U 5      R                  5       I S h  vN $ U $  N7fr   )r   r   r   rM   r>   r@   rE   s    r    rN   rN   y   s;     $$$ZZ%00222K 3s   AA	A
Ac                    [        XS5      $ )a  Copy only the containers along the given paths.

Used to guard against mutation by extract_files without copying the entire structure.
Only dicts and lists that lie on a path are copied; everything else
is returned by reference.

For example, given paths=[["foo", "files", "file"]] and the structure:
    {
        "foo": {
            "bar": {"baz": {}},
            "files": {"file": <content>}
        }
    }
The root dict, "foo", and "files" are copied (they lie on the path).
"bar" and "baz" are returned by reference (off the path).
r   )_deepcopy_with_paths)itempathss     r    deepcopy_with_pathsrT      s    "  Q//r"   c                z   U(       d  U $ [        U 5      (       a  0 nU H7  nU[        U5      :  d  M  UR                  XB   / 5      R                  U5        M9     U(       d  U $ [	        U 5      nUR                  5        H  u  pgXe;   d  M  [        XV   XrS-   5      XV'   M!     [        [        U5      $ [        U 5      (       aq  U Vs/ s H  oB[        U5      :  d  M  XB   S:X  d  M  UPM!     nnU(       d  [        [        U 5      $ [        [        U  V	s/ s H  n	[        XUS-   5      PM     sn	5      $ U $ s  snf s  sn	f )Nr	   z<array>)
r   len
setdefaultappenddictr5   rQ   r   r   r   )
rR   rS   indexkey_to_pathsrC   resultr'   subpathsarray_pathsentrys
             r    rQ   rQ      s   $79Ds4y ''R8??E 
 Kd)//1MC}26;RS)T 2 Bt}}(-`T1Btt{V_G_t` D>!BZ^_Z^QV-e%!)LZ^_``K a
 `s   D3D3$D3D8
)r   objectreturnzTypeGuard[Base64FileInput])r   r`   ra   zTypeGuard[FileContent])r   r`   r'   z
str | Nonera   None)r1   rb   ra   rb   )r1   r   ra   r   )r1   zRequestFiles | Nonera   zHttpxRequestFiles | None)r9   r
   ra   r   )r9   r   ra   r   )rR   r   rS   Sequence[Sequence[str]]ra   r   )rR   r   rS   rc   rZ   intra   r   )'
__future__r   r   r   r=   typingr   r   r   typing_extensionsr   r   rM   _typesr
   r   r   r   r   r   r   _utilsr   r   r   r   r   r   r!   r&   r-   r2   r6   rA   rG   rK   rN   rT   rQ   r/   r"   r    <module>rj      s    " 	 	  + + 0    Q PT]F >B  
 , 
 , 
 A 
 A\ 
 8 
 8 
 M 
 M\0(r"   