o
    ҷhX
                     @  s   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 d dlZer(d dl	m
Z
 ejdd
dZdddZej	ddddZdS )    )annotationsN)TYPE_CHECKING)	Generatorold_namestrnew_namereturnGenerator[None, None, None]c              
   c  sx    zdV  W dS  t y; } z(|js t|jd }|| |}|f}t|jdkr3||jdd  }||_ d}~ww )z.
    Rewrite the message of an exception.
    Nr      )	Exceptionargsr   replacelen)r   r   errmsgr    r   J/var/www/html/venv/lib/python3.10/site-packages/pandas/util/_exceptions.pyrewrite_exception   s   r   intc                  C  sp   ddl } tj| j}tj|d}t }d}|r6t|}|	|r1|	|s1|j
}|d7 }n	 |S |s|S )zb
    Find the first place in the stack that is not inside pandas
    (tests notwithstanding).
    r   Ntestsr
   )pandasospathdirname__file__joininspectcurrentframegetfile
startswithf_back)pdpkg_dirtest_dirframenfnamer   r   r   find_stack_level!   s   

r'   target_messagetarget_categorytype[Warning]new_messagenew_categorytype[Warning] | Nonec           	      c  s    |du r|}t jdd}dV  W d   n1 sw   Y  t|dkrUt| }|D ])}|j|u rBt|t|jrB|}|}n|j|j}}t j	|||j
|jd q-dS dS )a  
    Rewrite the message of a warning.

    Parameters
    ----------
    target_message : str
        Warning message to match.
    target_category : Warning
        Warning type to match.
    new_message : str
        New warning message to emit.
    new_category : Warning or None, default None
        New warning type to emit. When None, will be the same as target_category.
    NT)recordr   )messagecategoryfilenamelineno)warningscatch_warningsr   recompiler0   searchr   r/   warn_explicitr1   r2   )	r(   r)   r+   r,   r.   matchwarningr0   r/   r   r   r   rewrite_warning9   s.   

r;   )r   r   r   r   r   r	   )r   r   )N)
r(   r   r)   r*   r+   r   r,   r-   r   r	   )
__future__r   
contextlibr   r   r5   typingr   r3   collections.abcr   contextmanagerr   r'   r;   r   r   r   r   <module>   s    
