
    o[weX
                        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
            ZddZej        	 ddd            ZdS )    )annotationsN)TYPE_CHECKING)	Generatorold_namestrnew_namereturnGenerator[None, None, None]c              #    K   	 dV  dS # t           $ rr}|j        s t          |j        d                   }|                    | |          }|f}t	          |j                  dk    r||j        dd         z   }||_         d}~ww xY w)z.
    Rewrite the message of an exception.
    Nr      )	Exceptionargsr   replacelen)r   r   errmsgr   s        7lib/python3.11/site-packages/pandas/util/_exceptions.pyrewrite_exceptionr      s      
 	 	 	x 	#(1+kk(H--!$sx==1#(122,&D	s   
 
BA-BBintc                 `   ddl } t          j                            | j                  }t          j                            |d          }t          j                    }d}|rNt          j        |          }|	                    |          r"|	                    |          s|j
        }|dz  }nn|N|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fnames         r   find_stack_levelr)   !   s     goobk**Gw||GW--H  ""E	A
 &&G$$ 	U-=-=h-G-G 	LEFAA   H    target_messagetarget_categorytype[Warning]new_messagenew_categorytype[Warning] | Nonec              #    K   ||}t          j        d          5 }dV  ddd           n# 1 swxY w Y   t          |          dk    r~t          j        |           }|D ]i}|j        |u r,t          j        |t          |j                            r|}|}n|j        |j        }}t          j	        |||j
        |j                   hd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compiler4   searchr   r3   warn_explicitr5   r6   )	r+   r,   r.   r/   r2   matchwarningr4   r3   s	            r   rewrite_warningr?   9   s:     * &		 	-	-	-               
6{{Q
>** 	 	G?22rys7?++8 82 ()4$+$4go'"! )~	     	 	s   -11)r   r   r   r   r	   r
   )r	   r   )N)
r+   r   r,   r-   r.   r   r/   r0   r	   r
   )
__future__r   
contextlibr   r   r9   typingr   r7   collections.abcr   contextmanagerr   r)   r?    r*   r   <module>rF      s    " " " " " "      				 				              *))))))    $   0 
 *.	' ' ' ' ' ' 'r*   