
    Mfl              
       \    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dS )
    Nc                     |t          j        |           }t          | d          5 }t          |                                ||          cddd           S # 1 swxY w Y   dS )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       O/var/www/surfInsights/venv3-11/lib/python3.11/site-packages/dash/dcc/express.py	send_filer      s     ?4((	dD		 4Q!&&((Hd334 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4s   #AAAc                     t          | t                    r| nt          t          j                    | fi |}t          t          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      so      U++XccBJLL#1X1XQW1X1XG ))002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#   )   sL      S))Wccz"+--/W/WPV/W/WG(eLLLLr   c                 r    | j         }d | _          || fi | |                                 } |             |S )Nc                      d S N r'   r   r   <lambda>z_io_to_str.<locals>.<lambda>8   s    D r   )closegetvalue)data_iowriterr   data_io_close
data_values        r   r   r   5   sL    MM LGM
F7f!!##JMOOOr   c                     | j         }|t                                          vr"t          d                    |                    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   @   sf    & ?D&++---->>DfTll
 
 	

 t$VXtFFvF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@      s    				  
4 4 4 4    "	M 	M 	M 	M  G G G G> 
 
   r   