
    Wh                    H   d dl mZ d dlmZ d dlZd dlm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Zd dlmZ d dlmZ edd            Zedd            Zedd d            Zed!d            Zed"d            Zed"d            Zed#d"d            Z G d d          ZdS )$    )annotations)contextmanagerN)Path)rmtree)IOAnyIterator)
set_option)
get_handlereturnIterator[IO[bytes]]c              #  t   K   t          | d|d          5 }|j        V  ddd           dS # 1 swxY w 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)compressionis_textN)r   handle)pathr   r   s      ^/var/www/html/movieo_spanner_bot/venv/lib/python3.11/site-packages/pandas/_testing/contexts.pydecompress_filer      s      " 
D$K	G	G	G 6m                 s   
-11tzstrIterator[None]c              #     K   ddl ddlfd}j                            d          } ||            	 dV   ||           dS #  ||           w xY 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'
    r   Nc                    | 	 j         d= d S # t          $ r Y d S w xY w| j         d<                                    d S )NTZ)environKeyErrortzset)r   ostimes    r   setTZzset_timezone.<locals>.setTZD   s^    :Jt$$$     "BJtJJLLLLLs    
r   )r   r    r   get)r   r!   orig_tzr   r    s      @@r   set_timezoner$   +   s      , IIIKKK      jnnT""G	E"IIIggs   A
 
AFreturn_filelikeboolkwargsr   c              +    K   t          t          j                              }| d} t          t	          j                              | z   } || z  }|                                 t          |          }|r#|                    dd           t          |fi |}	 |V  t          |t                    s|
                                 |                                r|                                 dS dS # t          |t                    s|
                                 |                                r|                                 w w xY 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 modezw+b)r   tempfile
gettempdirr   uuiduuid4touch
setdefaultopen
isinstancecloseis_fileunlink)filenamer%   r'   folderr   handle_or_strs         r   ensure_cleanr9   V   sD     ( (%''((F4:<<  8+HHDJJLLL!$iiM -&%(((T,,V,,--- 	"!!!<<>> 	KKMMMMM	 	 --- 	"!!!<<>> 	KKMMMM	s   C1 1AEIterator[str]c               #     K   t          j        d          } 	 | V  	 t          |            dS # t          $ r Y dS w xY w# 	 t          |            w # t          $ r Y w w xY wxY w)z{
    Get a temporary directory path and agrees to remove on close.

    Yields
    ------
    Temporary directory path
    r)   )suffixN)r+   mkdtempr   OSError)directory_names    r   ensure_clean_dirr@      s       %R000N	>""""" 	 	 	DD		>"""" 	 	 	D	s;   A  / 
== A"AA"
AA"AA"c               #  D  K   t          t          j                  } 	 dV  t          j                                         t          j                            |            dS # t          j                                         t          j                            |            w xY w)z
    Get a context manager to safely set environment variables

    All changes will be undone on close, hence environment variables set
    within this contextmanager will neither persist nor change global state.
    N)dictr   r   clearupdate)saved_environs    r   !ensure_safe_environment_variablesrF      s       $$M)



-((((( 	


-((((s   A   ?Bc              +     K   ddl }h d}| |v rt          d           |j        | fi | 	 dV  |                    |            dS # |                    |            w xY 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.
    r   N>   	excel-tabunixexcelz Cannot override builtin dialect.)csv
ValueErrorregister_dialectunregister_dialect)namer'   rK   _BUILTIN_DIALECTSs       r   with_csv_dialectrQ      s      ( JJJ666   ;<<<C(((((%t$$$$$t$$$$s   A Ac              #     K   ddl m} ||j        }|j        }|j        }t	          d|            ||_        	 d V  ||_        t	          d|           d S # ||_        t	          d|           w xY w)Nr   )expressionszcompute.use_numexpr)pandas.core.computationrS   _MIN_ELEMENTSUSE_NUMEXPRr
   )usemin_elementsexprolduseoldmins        r   use_numexprr\      s      ;;;;;;)FF$c***%D2#(&11111 $(&1111s   A A.c                  *    e Zd ZdZddZddZddZdS )	
RNGContexta,  
    Context manager to set the numpy random number generator speed. Returns
    to the original value upon exiting the context manager.

    Parameters
    ----------
    seed : int
        Seed for numpy.random.seed

    Examples
    --------
    with RNGContext(42):
        np.random.randn()
    r   Nonec                    || _         d S N)seed)selfrb   s     r   __init__zRNGContext.__init__   s    			    c                    t           j                                        | _        t           j                            | j                   d S ra   )nprandom	get_statestart_staterb   )rc   s    r   	__enter__zRNGContext.__enter__   s4    9..00
	ty!!!!!re   c                N    t           j                            | j                   d S ra   )rg   rh   	set_staterj   )rc   exc_type	exc_value	tracebacks       r   __exit__zRNGContext.__exit__   s!    
	D,-----re   N)r   r_   )__name__
__module____qualname____doc__rd   rk   rq    re   r   r^   r^      sZ            " " " "
. . . . . .re   r^   )r   r   )r   r   r   r   )NF)r%   r&   r'   r   )r   r:   )r   r   ra   )
__future__r   
contextlibr   r   pathlibr   shutilr   r+   typingr   r   r	   r-   numpyrg   pandasr
   pandas.io.commonr   r   r$   r9   r@   rF   rQ   r\   r^   rv   re   r   <module>r      s   " " " " " " % % % % % % 				                      
            ' ' ' ' ' '    ( ' ' ' 'T ' ' ' ' 'T    $ ) ) ) ) % % % %B 2 2 2 2 2". . . . . . . . . .re   