o
    GÊÆ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   úd/var/www/html/HyperOracle/crypto_trader/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    
ü