U
    	fK                     @  sT  d dl mZ d dlZd dlZd dlZd dlmZ d dlmZ d dl	Z	ddl
mZmZmZmZmZmZ ddlmZmZmZ dd	d
ddZddddddddZedddddZedddddZdddddZddddd Zd!d"dd#d$Zedddd%d&Zedddd'd&Zdddd(d&Zdddd)d*Zd!d"dd+d,ZdS )-    )annotationsN)overload)	TypeGuard   )	FileTypesFileContentRequestFilesHttpxFileTypesHttpxFileContentHttpxRequestFiles)
is_tuple_tis_mapping_tis_sequence_tobjectzTypeGuard[FileContent])objreturnc                 C  s,   t | tp*t | tp*t | tjp*t | tjS N)
isinstancebytestupleioIOBaseosPathLike)r    r   N/var/www/html/apigroqsegura/apigroq/lib/python3.8/site-packages/groq/_files.pyis_file_content   s    *r   )keyz
str | NoneNone)r   r   r   c                C  sF   t | sB|d k	rd| dn
d| d}t| dt|  dd d S )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   prefixr   r   r   assert_is_file_content   s     r#   )filesr   c                 C  s   d S r   r   r$   r   r   r   to_httpx_files$   s    r&   r   r   c                 C  s   d S r   r   r%   r   r   r   r&   )   s    zRequestFiles | NonezHttpxRequestFiles | Nonec                 C  sX   | d krd S t | r(dd |  D } n,t| r@dd | D } ntdt|  d| S )Nc                 S  s   i | ]\}}|t |qS r   _transform_file.0r   filer   r   r   
<dictcomp>3   s      z"to_httpx_files.<locals>.<dictcomp>c                 S  s   g | ]\}}|t |fqS r   r'   r)   r   r   r   
<listcomp>5   s     z"to_httpx_files.<locals>.<listcomp>zUnexpected file type input z, expected mapping or sequence)r   itemsr   	TypeErrorr!   r%   r   r   r   r&   .   s    r   r	   )r+   r   c                 C  sd   t | r0t| tjr,t| }|j| fS | S t| rX| d t	| d f| dd  S t
dd S 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_contentr/   r+   pathr   r   r   r(   <   s    
 r(   r   r
   c                 C  s   t | tjrt|  S | S r   )r   r   r   r2   r3   r5   r+   r   r   r   r6   J   s    r6   c                   s   d S r   r   r%   r   r   r   async_to_httpx_filesP   s    r:   c                   s   d S r   r   r%   r   r   r   r:   U   s    c                   sX   | d krd S t | r.dd |  D I d H } n&t| rLdd | D I d H } ntd| S )Nc                   s    i | ]\}}|t |I d H qS r   _async_transform_filer)   r   r   r   r,   _   s      z(async_to_httpx_files.<locals>.<dictcomp>c                   s"   g | ]\}}|t |I d H fqS r   r;   r)   r   r   r   r-   a   s     z(async_to_httpx_files.<locals>.<listcomp>zFUnexpected file type input {type(files)}, expected mapping or sequence)r   r.   r   r/   r%   r   r   r   r:   Z   s    c                   sp   t | r6t| tjr2t| }|j| I d H fS | S t| rd| d t	| d I d H f| dd  S t
dd S r0   )r   r   r   r   anyior3   r4   r5   r   _async_read_file_contentr/   r7   r   r   r   r<   h   s    
&r<   c                   s$   t | tjr t|  I d H S | S r   )r   r   r   r=   r3   r5   r9   r   r   r   r>   v   s    r>   )
__future__r   r   r   r2   typingr   typing_extensionsr   r=   _typesr   r   r   r	   r
   r   _utilsr   r   r   r   r#   r&   r(   r6   r:   r<   r>   r   r   r   r   <module>   s0    