
    Owg<                        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
 d dlmZ ej                  d	d       Zd
dZej                  	 d	 	 	 	 	 	 	 	 	 dd       Zy)    )annotationsN)TYPE_CHECKING)	Generator)	FrameTypec              #    K   	 d y# t         $ rq}|j                  s t        |j                  d         }|j                  | |      }|f}t	        |j                        dkD  r||j                  dd z   }||_         d}~ww xY ww)z.
    Rewrite the message of an exception.
    Nr      )	Exceptionargsstrreplacelen)old_namenew_nameerrmsgr
   s        N/var/www/horilla/myenv/lib/python3.12/site-packages/pandas/util/_exceptions.pyrewrite_exceptionr      s~     
 	xx#((1+kk(H-!$sxx=1#((12,&D	s%   B	 B	BA,A>>BBc                    ddl } t        j                  j                  | j                        }t        j                  j                  |d      }t        j                         }	 d}|rPt        j                  |      }|j                  |      r#|j                  |      s|j                  }|dz  }n	 ~|S |rP~|S # ~w xY w)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filenames         r   find_stack_levelr'   "   s     ggoobkk*Gww||GW-H &224Eu-H""7+H4G4G4QQ H  H s   #AB: 4B: :B=c              #    K   ||}t        j                  d      5 }d ddd       t              dkD  rt        j                  |       }|D ]  }|j
                  |u r.t        j                  |t        |j                              r|}|}n|j
                  |j                  }}t        j                  |||j                  |j                          yy# 1 sw Y   xY ww)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categoryr&   lineno)warningscatch_warningsr   recompiler+   searchr   r*   warn_explicitr&   r,   )	target_messagetarget_categorynew_messagenew_categoryr)   matchwarningr+   r*   s	            r   rewrite_warningr9   ?   s     * &		 	 	- 
6{Q

>* 	G?2ryys7??+8 ()4$+$4$4goo'""! ))~~		  s   C#CB5C#C C#)r   r   r   r   returnGenerator[None, None, None])r:   int)N)
r3   r   r4   ztype[Warning]r5   r   r6   ztype[Warning] | Noner:   r;   )
__future__r   
contextlibr   r   r/   typingr   r-   collections.abcr   typesr   contextmanagerr   r'   r9        r   <module>rE      s    "   	 	   )  $: 
 *.	''"' ' '	'
 !' 'rD   