a
    d                     @  s  d dl mZ d dlmZ d dlZd dlmZ d dlZd dlm	Z	m
Z
mZ d dlZd dlmZ d dlmZ d dlmZ d d	lmZ e
rd d
lmZ d dlmZmZmZ eddddddZedddddZe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&Z dS )*    )annotations)contextmanagerN)Path)IOTYPE_CHECKINGAny)PYPY)ChainedAssignmentError)
set_option)
get_handle)	Generator)
BaseBufferCompressionOptionsFilePathzFilePath | BaseBufferr   z Generator[IO[bytes], None, None])pathcompressionreturnc                 c  s<   t | d|dd}|jV  W d   n1 s.0    Y  dS )a&  
    Open a compressed file and return a file object.

    Parameters
    ----------
    path : str
        The path where the file is read from.

    compression : {'gzip', 'bz2', 'zip', 'xz', 'zstd', None}
        Name of the decompression to use

    Returns
    -------
    file object
    rbF)r   Zis_textN)r   handle)r   r   r    r   a/var/www/html/stable-diffusion-webui/venv/lib/python3.9/site-packages/pandas/_testing/contexts.pydecompress_file   s    r   strzGenerator[None, None, None])tzr   c                 #  sP   ddl  dd fdd}tjd}||  zdV  W || n
|| 0 dS )a  
    Context manager for temporarily setting a timezone.

    Parameters
    ----------
    tz : str
        A string representing a valid timezone.

    Examples
    --------
    >>> from datetime import datetime
    >>> from dateutil.tz import tzlocal
    >>> tzlocal().tzname(datetime(2021, 1, 1))  # doctest: +SKIP
    'IST'

    >>> with set_timezone('US/Eastern'):
    ...     tzlocal().tzname(datetime(2021, 1, 1))
    ...
    'EST'
    r   NNoner   c                   s@   | d u r*zt jd= W q< ty&   Y q<0 n| t jd<    d S )NTZ)osenvironKeyErrortzset)r   timer   r   setTZN   s    
zset_timezone.<locals>.setTZr   )r"   r   r   get)r   r#   Zorig_tzr   r!   r   set_timezone6   s    
r%   Fboolr   zGenerator[Any, None, None])return_filelikekwargsr   c              	   k  s   t t }| du rd} tt |  } ||  }|  t|}|dd}|r|dd |du rtd|d vrtd}t	|fd|i|}z,|V  W t
|ts|  | r|  n$t
|ts|  | r|  0 dS )az  
    Gets a temporary path and agrees to remove on close.

    This implementation does not use tempfile.mkstemp to avoid having a file handle.
    If the code using the returned path wants to delete the file itself, windows
    requires that no program has a file handle to it.

    Parameters
    ----------
    filename : str (optional)
        suffix of the created file.
    return_filelike : bool (default False)
        if True, returns a file-like which is *always* cleaned. Necessary for
        savefig and other functions which want to append extensions.
    **kwargs
        Additional keywords are passed to open().

    N encodingmodezw+bbzutf-8)r   tempfile
gettempdirr   uuiduuid4touchpop
setdefaultopen
isinstancecloseis_fileunlink)filenamer'   r(   folderr   Zhandle_or_strr*   r   r   r   ensure_clean`   s.    


r;   )namer   c              	   k  sX   ddl }h d}| |v r td|j| fi | zdV  W ||  n||  0 dS )au  
    Context manager to temporarily register a CSV dialect for parsing CSV.

    Parameters
    ----------
    name : str
        The name of the dialect.
    kwargs : mapping
        The parameters for the dialect.

    Raises
    ------
    ValueError : the name of the dialect conflicts with a builtin one.

    See Also
    --------
    csv : Python's CSV library.
    r   N>   z	excel-tabunixexcelz Cannot override builtin dialect.)csv
ValueErrorregister_dialectunregister_dialect)r<   r(   r?   Z_BUILTIN_DIALECTSr   r   r   with_csv_dialect   s    rC   r   c              	   c  sh   ddl m} |d u r|j}|j}|j}td|  ||_zd V  W ||_td| n||_td| 0 d S )Nr   )expressionszcompute.use_numexpr)Zpandas.core.computationrD   Z_MIN_ELEMENTSZUSE_NUMEXPRr
   )ZuseZmin_elementsexprZolduseZoldminr   r   r   use_numexpr   s    
rF   r   c                 C  sj   ddl m} tr&| s&ddlm} | S tr@| r@|| d|dS d}|tg| R d|g|R dS d S )Nr   )assert_produces_warning)nullcontext|)matchzYA value is trying to be set on a copy of a DataFrame or Series through chained assignment)Zpandas._testingrG   r   
contextlibrH   joinr	   )Zextra_warningsZextra_matchrG   rH   rJ   r   r   r   raises_chained_assignment_error   s    
rM   )NF)N)r   r   )!
__future__r   rK   r   r   pathlibr   r-   typingr   r   r   r/   Zpandas.compatr   Zpandas.errorsr	   Zpandasr
   Zpandas.io.commonr   collections.abcr   Zpandas._typingr   r   r   r   r%   r;   rC   rF   rM   r   r   r   r   <module>   s2   ) /!