
    $gl              
       Z    d dl Z d dlZd dlZddZd	dZd	dZd Zd	dZeeeeeeeeed	Zy)
    Nc                     |t        j                  |       }t        | d      5 }t        |j	                         ||      cddd       S # 1 sw Y   yxY w)a  
    Convert a file into the format expected by the Download component.
    :param path: path to the file to be sent
    :param filename: name of the file, if not provided the original filename is used
    :param type: type of the file (optional, passed to Blob in the javascript layer)
    :return: dict of file content (base64 encoded) and meta data used by the Download component
    Nrb)ntpathbasenameopen
send_bytesread)pathfilenametypefs       M/var/www/dash_apps/app1/venv/lib/python3.12/site-packages/dash/dcc/express.py	send_filer      sK     ??4(	dD	 4Q!&&(Hd34 4 4s   A		Ac                     t        | t              r| nt        t        j                         | fi |}t        t        j                  |      j                         ||d      S )a  
    Convert data written to BytesIO into the format expected by the Download component.
    :param src: array of bytes or a writer that can write to BytesIO
    :param filename: the name of the file
    :param type: type of the file (optional, passed to Blob in the javascript layer)
    :return: dict of data frame content (base64 encoded) and meta data used by the Download component
    Tcontentr   r   base64)	
isinstancebytes
_io_to_strioBytesIOdictr   	b64encodedecodesrcr   r   kwargsr   s        r   r   r      sT      U+cBJJL#1XQW1XG  )002	     c                     t        | t              r| nt        t        j                         | fi |}t        |||d      S )a  
    Convert data written to StringIO into the format expected by the Download component.
    :param src: a string or a writer that can write to StringIO
    :param filename: the name of the file
    :param type: type of the file (optional, passed to Blob in the javascript layer)
    :return: dict of data frame content (NOT base64 encoded) and meta data used by the Download component
    Fr   )r   strr   r   StringIOr   r   s        r   send_stringr#   )   s8      S)cz"++-/WPV/WG(eLLr   c                 n    | j                   }d | _          || fi | | j                         } |        |S )Nc                       y N r'   r   r   <lambda>z_io_to_str.<locals>.<lambda>8   s    r   )closegetvalue)data_iowriterr   data_io_close
data_values        r   r   r   5   s8    MMM GM
7f!!#JOr   c                     | j                   }|t        j                         vrt        dj	                  |            t        |   | ||fi |S )a  
    Convert data frame into the format expected by the Download component.
    :param writer: a data frame writer
    :param filename: the name of the file
    :param type: type of the file (optional, passed to Blob in the javascript layer)
    :return: dict of data frame content (base64 encoded) and meta data used by the Download component

    Examples
    --------

    >>> df = pd.DataFrame({'a': [1, 2, 3, 4], 'b': [2, 1, 5, 6], 'c': ['x', 'x', 'y', 'y']})
    ...
    >>> send_data_frame(df.to_csv, "mydf.csv")  # download as csv
    >>> send_data_frame(df.to_json, "mydf.json")  # download as json
    >>> send_data_frame(df.to_excel, "mydf.xls", index=False) # download as excel
    >>> send_data_frame(df.to_pickle, "mydf.pkl") # download as pickle

    zZThe provided writer ({}) is not supported, try calling send_string or send_bytes directly.)__name___data_frame_senderskeys
ValueErrorformat)r,   r   r   r   names        r   send_data_framer6   @   sU    & ??D&++-->>DfTl
 	

 t$VXtFvFFr   )	to_csvto_jsonto_htmlto_excel
to_feather
to_parquet
to_msgpackto_stata	to_pickle)NNr&   )	r   r   r   r   r   r#   r   r6   r1   r'   r   r   <module>r@      sN    	  
4 "	MG> 
 r   