L iddlmZddlZddlmZmZmZddlmZddl m Z m Z ddl m Z ddlmZddlmZmZerdd lmZdd lmZdd lmZdd lmZGd dZ ddZy)) annotationsN) TYPE_CHECKINGAnyLiteral)util)context_dg_stackget_default_dg_stack_value)handle_uncaught_app_exception)FragmentHandledException)RerunException StopException)Callable) TracebackType) RerunData)ScriptRunContextc@eZdZdZddZddZd dZ d dZy) modified_sys_pathzA context for prepending a directory to sys.path for a second. Code inspired by IPython: Source: https://github.com/ipython/ipython/blob/master/IPython/utils/syspathcontext.py#L42 c ||_d|_yNF)_main_script_path _added_path)selfmain_script_paths n/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/streamlit/runtime/scriptrunner/exec_code.py__init__zmodified_sys_path.__init__/s!1 c,tj|S)N)rrepr_rs r__repr__zmodified_sys_path.__repr__3szz$rc|jtjvr2tjjd|jd|_yy)NrT)rsyspathinsertrrs r __enter__zmodified_sys_path.__enter__6s9  ! ! 1 HHOOAt55 6#D  2rc|jr+ tjj|jyy#t $rYywxYwr)rr"r#remover ValueError)rtypexctbs r__exit__zmodified_sys_path.__exit__;sF     6 67     s)9 AAN)rstrreturnNone)r.r-)r.r/)r)ztype[BaseException] | Noner*zBaseException | Noner+zTracebackType | Noner.zLiteral[False])__name__ __module__ __qualname____doc__rr r%r,rrrr(sA ! $  '" !   rrcbd}d}d}d}d} |}|||||fS#t$rO}|j}|jjt j t d}Yd}~Zd}~wt$rd}Yjt$rd}d}Yxt$r}d}d}t||}Yd}~d}~wwxYw)adExecute the passed function wrapped in a try/except block. This function is called by the script runner to execute the user's script or fragment reruns, but also for the execution of fragment code in context of a normal app run. This wrapper ensures that handle_uncaught_exception messages show up in the correct context. Parameters ---------- func : callable The function to execute wrapped in the try/except block. ctx : ScriptRunContext The context in which the script is being run. Returns ------- tuple A tuple containing: - The result of the passed function. - A boolean indicating whether the script ran without errors (RerunException and StopException don't count as errors). - The RerunData instance belonging to a RerunException if the script was interrupted by a RerunException. - A boolean indicating whether the script was stopped prematurely (False for RerunExceptions, True for all other exceptions). - The uncaught exception if one occurred, None otherwise TNF) r rerun_datacursorsclearrsetr r r Exceptionr ) funcctxrun_without_errorsrerun_exception_datapremature_stopresultuncaught_exceptioneexs rexec_func_with_error_handlingrDLsH.2!NF,0 B   ?  || 79:   #"  "%b)  s- B.AA--B.= B. B.B))B.)r;zCallable[[], Any]r<rr.zAtuple[Any | None, bool, RerunData | None, bool, Exception | None]) __future__rr"typingrrr streamlitr$streamlit.delta_generator_singletonsrr streamlit.error_utilr streamlit.errorsr /streamlit.runtime.scriptrunner_utils.exceptionsr r collections.abcrtypesr4streamlit.runtime.scriptrunner_utils.script_requestsr7streamlit.runtime.scriptrunner_utils.script_run_contextrrrDr4rrrPsg# ..?5 (#NX!!H[ ["2[[r