
    bMh`                        d dl mZ d dlZd dlZd dlZd dlZd dlmZmZm	Z	 d dl
Z
d dlZd dlmZmZ d dlmZ d dlZd dlmZ erd dlmZmZ d dlmZmZ 	 dddZdddZdddZdddZdS )    )annotationsN)TYPE_CHECKINGAnyCallable)get_bz2_fileget_lzma_file)import_optional_dependency)ensure_clean)FilePathReadPickleBuffer)	DataFrameSeriesobjr   path"FilePath | ReadPickleBuffer | NonereturnDataFrame | Seriesc                    |}|dt          j                     d}t          |          5 }t          j        | |           t          j        |          cddd           S # 1 swxY w Y   dS )a  
    Pickle an object and then read it again.

    Parameters
    ----------
    obj : any object
        The object to pickle and then re-read.
    path : str, path object or file-like object, default None
        The path where the pickled object is written and then read.

    Returns
    -------
    pandas object
        The original object that was pickled and then re-read.
    N__z	__.pickle)uuiduuid4r
   pd	to_pickleread_pickle)r   r   _path	temp_paths       S/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/pandas/_testing/_io.pyround_trip_pickler   '   s    $ E},TZ\\,,,	e		 )	
S)$$$~i(() ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) )s   )A!!A%(A%
str | Nonec                    t           j        }|d}t          |          5 } |  ||                      | ||                    }ddd           n# 1 swxY w Y   |S )a  
    Write an object to file specified by a pathlib.Path and read it back

    Parameters
    ----------
    writer : callable bound to pandas object
        IO writing function (e.g. DataFrame.to_csv )
    reader : callable
        IO reading function (e.g. pd.read_csv )
    path : str, default None
        The path where the object is written and then read.

    Returns
    -------
    pandas object
        The original object that was serialized and then re-read.
    N___pathlib___)pathlibPathr
   )writerreaderr   r#   r   s        r   round_trip_pathlibr&   A   s    $ <D|	d		 !tttDzzfTT$ZZ  ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! Js   )AAAc                    ddl }|                    d          j        }|d}t          |          5 } |  ||                      | ||                    }ddd           n# 1 swxY w Y   |S )a  
    Write an object to file specified by a py.path LocalPath and read it back.

    Parameters
    ----------
    writer : callable bound to pandas object
        IO writing function (e.g. DataFrame.to_csv )
    reader : callable
        IO reading function (e.g. pd.read_csv )
    path : str, default None
        The path where the object is written and then read.

    Returns
    -------
    pandas object
        The original object that was serialized and then re-read.
    r   Nzpy.path___localpath___)pytestimportorskiplocalr
   )r$   r%   r   r)   	LocalPathr   s         r   round_trip_localpathr-   \   s    $ MMM##I..4I| 	d		 &tyyfYYt__%%& & & & & & & & & & & & & & & Js   )A''A+.A+testdeststrNonec                @   |f}d}d}| dk    rt           j        }d}||f}d}n| dk    rRt          j        }d}t          j        |          }t          j        |          }	t          |          |_        ||	f}d}nj| d	k    rt          j
        }nW| d
k    rt                      }nB| dk    rt          d          j        }n'| dk    rt                      }nt          d|             |||          5 }
 t!          |
|          |  ddd           dS # 1 swxY w Y   dS )a  
    Write data to a compressed file.

    Parameters
    ----------
    compression : {'gzip', 'bz2', 'zip', 'xz', 'zstd'}
        The compression type to use.
    path : str
        The file path to write the data.
    data : str
        The data to write.
    dest : str, default "test"
        The destination file (for ZIP only)

    Raises
    ------
    ValueError : An invalid compression value was passed in.
    wbwritezipwwritestrtar)nameaddfilegzipbz2zstd	zstandardxzzUnrecognized compression type: )modeN)zipfileZipFiletarfileTarFileTarInfoioBytesIOlensizer;   GzipFiler   r	   openr   
ValueErrorgetattr)compressionr   datar/   argsr@   methodcompress_methodfilebytesfs              r   write_to_compressedrV   y   s   & "GDDF e!/d|			!/D)))
4  II	e}			-			&..			4[AAF			'//H;HHIII	D	)	)	) "Q6D!!" " " " " " " " " " " " " " " " " "s   2DDD)N)r   r   r   r   r   r   )r   r   )r.   )r/   r0   r   r1   )
__future__r   r;   rF   r"   rC   typingr   r   r   r   rA   pandas.compatr   r   pandas.compat._optionalr	   pandasr   pandas._testing.contextsr
   pandas._typingr   r   r   r   r   r&   r-   rV        r   <module>r`      s   " " " " " "  				           
          ? > > > > >     1 1 1 1 1 1 	       
        :>) ) ) ) )4    6    :1" 1" 1" 1" 1" 1" 1"r_   