Sindbad~EG File Manager

Current Path : /usr/local/lib/python3.12/site-packages/pandas/_testing/__pycache__/
Upload File :
Current File : //usr/local/lib/python3.12/site-packages/pandas/_testing/__pycache__/contexts.cpython-312.pyc

�

Mٜg���:�ddlmZddlmZddlZddlmZddlZddlm	Z	m
Z
mZddlZddl
mZddlmZddlmZdd	lmZdd
lmZe
rddlmZddlmZmZmZe						dd
��Zedd��Ze	d					dd��Zedd��Z eddd��Z!dd�Z"dd�Z#y)�)�annotations)�contextmanagerN)�Path)�IO�
TYPE_CHECKING�Any)�using_copy_on_write)�PYPY)�ChainedAssignmentError)�
set_option)�
get_handle)�	Generator)�
BaseBuffer�CompressionOptions�FilePathc#�pK�t|d|d��5}|j��ddd�y#1swYyxYw�w)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)�compression�is_textN)r
�handle)�pathrrs   �C/usr/local/lib/python3.12/site-packages/pandas/_testing/contexts.py�decompress_filer!s.����&
�D�$�K��	G�6��m�m��
H�	G�	G�s�6�*�	6�3�6c#��K�ddl�d�fd�}tjjd�}||�	d��||�y#||�wxYw�w)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'
    rNc���|�	tjd=y|tjd<�j�y#t$rYywxYw)N�TZ)�os�environ�KeyError�tzset)�tz�times �r�setTZzset_timezone.<locals>.setTZPsF���
�:�
��J�J�t�$� "�B�J�J�t���J�J�L��	�
��
�s�;�	A�Ar)�return�None)r"rr�get)r!r#�orig_tzr"s   @r�set_timezoner(8sB�����,���j�j�n�n�T�"�G�	�"�I��
�
�g����g��s�2A�A�	A�
A
�
Ac+�dK�ttj��}|�d}tt	j
��|z}||z}|j
�t|�}|jdd�}|r+|jdd�|�	d|dvrd}t|fd|i|��}	|��t|t�s|j�|j�r|j�yy#t|t�s|j�|j�r|j�wwxYw�w)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�modezw+b�bzutf-8)r�tempfile�
gettempdir�str�uuid�uuid4�touch�pop�
setdefault�open�
isinstance�close�is_file�unlink)�filename�return_filelike�kwargs�folderr�
handle_or_strr+s       r�ensure_cleanr@bs����,�(�%�%�'�
(�F������4�:�:�<� �8�+�H��H��D��J�J�L�!�$�i�M��z�z�*�d�+�H�����&�%�(����6�&�>� 9��H��T�?�H�?��?�
�����-��-����!��<�<�>��K�K�M����-��-����!��<�<�>��K�K�M��s �B!D0�$C*�(AD0�*AD-�-D0c+�K�ddl}hd�}||vrtd��|j|fi|��	d��|j|�y#|j|�wxYw�w)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.
    rN>�	excel-tab�unix�excelz Cannot override builtin dialect.)�csv�
ValueError�register_dialect�unregister_dialect)�namer=rE�_BUILTIN_DIALECTSs    r�with_csv_dialectrK�s_����(�6��� � ��;�<�<��C����(��(�%�
����t�$�����t�$�s�+A�A�A�A�Ac#��K�ddlm}|�|j}|j}|j}t	d|�||_	d��||_t	d|�y#||_t	d|�wxYw�w)Nr)�expressionszcompute.use_numexpr)�pandas.core.computationrM�
_MIN_ELEMENTS�USE_NUMEXPRr)�use�min_elements�expr�olduse�oldmins     r�use_numexprrV�st����;����)�)��
�
�
�F�
�
�
�F��$�c�*�%�D��2�
�#����(�&�1��$����(�&�1�s�AA3�A�A3�A0�0A3c��ddlm}|s
ddlm}|�Str|s
ddlm}|�Str|r||dj|���St
�r	t}d}nt}d}|r|g|��}||dj|g|�����S)Nr��assert_produces_warning��nullcontext�|)�matchzYA value is trying to be set on a copy of a DataFrame or Series through chained assignmentr)	�pandas._testingrY�
contextlibr[r
�joinr	r�
FutureWarning)�warn�extra_warnings�extra_matchrYr[�warningr]s       r�raises_chained_assignment_errorrf�s���7��*��}���N�*��}��	
�.�&���(�(�;�'�
�	
�
� �,�G�-�
�
$�G�,�E���0��0�G�&���(�(�E�0�K�0�1�
�	
�c�R�ddlm}|s
ddlm}|�S|sd}|tfd|i|��S)aq
    Assert that a warning is raised in the CoW warning mode.

    Parameters
    ----------
    warn : bool, default True
        By default, check that a warning is raised. Can be turned off by passing False.
    match : str
        The warning message to match against, if different from the default.
    kwargs
        Passed through to assert_produces_warning
    rrXrZzSetting a value on a viewr])r^rYr_r[ra)rbr]r=rYr[s     r�assert_cow_warningri�s2��8��*��}���+��"�=�H��H��H�Hrg)rzFilePath | BaseBufferrrr$z Generator[IO[bytes], None, None])r!r0r$�Generator[None, None, None])NF)r<�boolr=rr$zGenerator[Any, None, None])rIr0r$rj)N)r$rj)T�rl)TN)$�
__future__rr_rr�pathlibrr.�typingrrrr1�pandas._configr	�
pandas.compatr
�
pandas.errorsr�pandasr�pandas.io.commonr
�collections.abcr�pandas._typingrrrrr(r@rKrVrfrirlrgr�<module>rws���"�%�	�����
�.��0��'��)�����
��.@��%����,�&��&�R�+0�,�$(�,�<?�,��,��,�^�%��%�B�2��2�"!
�HIrg

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists