gL i< ddlmZddlZddlZddlZddlZddlmZddlZer ddl m Z ddl m Z ejd dZd dZej d d dZy) ) annotationsN) TYPE_CHECKING) Generator) FrameTypec#K dy#t$rq}|jst|jd}|j||}|f}t |jdkDr||jddz}||_d}~wwxYww)z. Rewrite the message of an exception. Nr) Exceptionargsstrreplacelen)old_namenew_nameerrmsgr s ]/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/pandas/util/_exceptions.pyrewrite_exceptionrs~   xx #((1+kk(H-!$ sxx=1 #((12,&D  s%B B BA,A>>BBcddl}tjj|j}tjj |d}t j} d}|rPt j|}|j|r#|j|s|j}|dz }n ~|S|rP~|S#~wxYw)zb Find the first place in the stack that is not inside pandas (tests notwithstanding). rNtestsr) pandasospathdirname__file__joininspect currentframegetfile startswithf_back)pdpkg_dirtest_dirframenfilenames rfind_stack_levelr'"s ggoobkk*Gww||GW-H&224E  u-H""7+H4G4G4Q Q  H  H s#A B:4B::B=c#K||}tjd5}ddddtdkDrtj|}|D]}|j |ur.tj |t|jr|}|}n|j |j}}tj|||j|jyy#1swYxYww)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)messagecategoryr&lineno) warningscatch_warningsr recompiler+searchr r* warn_explicitr&r,) target_messagetarget_category new_message new_categoryr)matchwarningr+r*s rrewrite_warningr9?s*&   -  6{Q >* G?2ryys7??+8()4$+$4$4goo'  " "! ))~~   sC#CB5C#C C#)rr rr returnGenerator[None, None, None])r:int)N) r3r r4z type[Warning]r5r r6ztype[Warning] | Noner:r;) __future__r contextlibrrr/typingrr-collections.abcrtypesrcontextmanagerrr'r9rrEs" ) $ :  *. ''"''' ' ! ''rD