
    i                     X    d dl Z d dlmZ ddlmZ ddlmZmZmZm	Z	m
Z
mZ  G d d      Zy)    N)Any   )PineconeApiValueError)ModelNormalModelSimpleModelComposeddatedatetimemodel_to_dictc                   P    e Zd Zedej
                  defd       Zede	fd       Z
y)
Serializerfile_instancereturnc                 F    | j                         }| j                          |S )N)readclose)r   	file_datas     u/var/www/catia.catastroantioquia-mas.com/valormas/lib/python3.12/site-packages/pinecone/openapi_support/serializer.pyget_file_data_and_close_filez'Serializer.get_file_data_and_close_file   s"    !&&(	    c                 X   t        |t        t        f      r>t        |d      j	                         D ci c]  \  }}|| j                  |       c}}S t        |t        j                        r| j                  |      S t        |t        t        t        t        f      s||S t        |t        t        f      r|j                         S t        |t               r| j                  |j"                        S t        |t$        t&        f      r|D cg c]  }| j                  |       c}S t        |t(              r3|j	                         D ci c]  \  }}|| j                  |       c}}S t+        dj-                  |j.                  j0                              c c}}w c c}w c c}}w )a?  Prepares data for transmission before it is sent with the rest client
        If obj is None, return None.
        If obj is str, int, long, float, bool, return directly.
        If obj is datetime.datetime, datetime.date
            convert to string in iso8601 format.
        If obj is list, sanitize each element in the list.
        If obj is dict, return the dict.
        If obj is OpenAPI model, return the properties dict.
        If obj is io.IOBase, return the bytes
        :param obj: The data to serialize.
        :return: The serialized form of data.
        T)	serializez+Unable to prepare type {} for serialization)
isinstancer   r   r   itemssanitize_for_serializationioIOBaser   strintfloatboolr
   r	   	isoformatr   valuelisttupledictr   format	__class____name__)clsobjkeyvalitems        r   r   z%Serializer.sanitize_for_serialization   s]    cK78 !.cT B H H JC S33C88  RYY'33C88c3t45Jh-.==?"[)11#))<<dE]+EHITC2248IIc4 MPYY[YcC77<<YY#9@@AWAWX
 	
! JYs   FF!F&N)r)   
__module____qualname__staticmethodr   r   bytesr   classmethodr   r    r   r   r   r   
   sA    BII %  
  
  
  
r   r   )r   typingr   
exceptionsr   model_utilsr   r   r   r	   r
   r   r   r4   r   r   <module>r8      s     	  . _ _(
 (
r   