L i"ddlmZddlZddlmZddlmZddlmZm Z ddl Z ddl m Z mZddlmZmZddlmZdd lmZdd lmZmZmZed dd Z dd Zeddd ddZedddZy)) annotationsN) dropwhile)Path)LiteralNoReturn)NoSessionContextStreamlitAPIException)get_main_script_directorynormalize_path_join) StreamlitPage)gather_metrics) RerunDataScriptRunContextget_script_run_ctxstopct}|r<|jr/|jjtjyyy)aStops execution immediately. Streamlit will not run any statements after `st.stop()`. We recommend rendering a message to explain why the script has stopped. Example ------- >>> import streamlit as st >>> >>> name = st.text_input("Name") >>> if not name: >>> st.warning('Please input a name.') >>> st.stop() >>> st.success("Thank you for inputting a name.") N)rscript_requests request_stopstempty)ctxs j/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/streamlit/commands/execution_control.pyrr"s9$  C s"" ((*  #sc|dk(rgSj}|s tdttfd|}|s t d|S)Nappzfscope="fragment" can only be specified from `@st.fragment`-decorated functions during fragment reruns.c"|jk7S)N)current_fragment_id)xrs rz(_new_fragment_id_queue..]sc.E.E)ErzRCould not find current_fragment_id in fragment_id_queue. This should never happen.)fragment_ids_this_runr listr RuntimeError)rscope curr_queue new_queues` r_new_fragment_id_queuer&<sd ~ **J& # 0  YEzRSI  `   rrerunr)r#c P|dvrtd|dt}|r|jrz|j}|j}|j }|jj t||t|||dk(||jtjyyy)aRerun the script immediately. When ``st.rerun()`` is called, Streamlit halts the current script run and executes no further statements. Streamlit immediately queues the script to rerun. When using ``st.rerun`` in a fragment, you can scope the rerun to the fragment. However, if a fragment is running as part of a full-app rerun, a fragment-scoped rerun is not allowed. Parameters ---------- scope : "app" or "fragment" Specifies what part of the app should rerun. If ``scope`` is ``"app"`` (default), the full app reruns. If ``scope`` is ``"fragment"``, Streamlit only reruns the fragment from which this command is called. Setting ``scope="fragment"`` is only valid inside a fragment during a fragment rerun. If ``st.rerun(scope="fragment")`` is called during a full-app rerun or outside of a fragment, Streamlit will raise a ``StreamlitAPIException``. )rfragment'zC'is not a valid rerun scope. Valid scopes are 'app' and 'fragment'.r)) query_stringpage_script_hashfragment_id_queueis_fragment_scoped_reruncached_message_hashes context_infoN) r rrr+r,r/ request_rerunrr&r0rr)r#rr+r,r/s rr'r'fs: ''#wY Z    C s""'' // # 9 9 )) )!1"8e"D).*)<&; --     !#sr switch_pagec~t}|r |js td}t|tr |j }nt|t r t|}t|j}tjjt||}|jjj!}|Dcgc] }|d|k(s |}}t#|dk(r/t%d|dtjj'|d|dd}|j(j+5}|j-ddd|jj/t1|j2||j4|j6 t9j:ycc}w#1swYixYw) uProgrammatically switch the current page in a multipage app. When ``st.switch_page`` is called, the current page execution stops and the specified page runs as if the user clicked on it in the sidebar navigation. The specified page must be recognized by Streamlit's multipage architecture (your main Python file or a Python file in a ``pages/`` folder). Arbitrary Python scripts cannot be passed to ``st.switch_page``. Parameters ---------- page: str, Path, or st.Page The file path (relative to the main script) or an st.Page indicating the page to switch to. Example ------- Consider the following example given this file structure: >>> your-repository/ >>> ├── pages/ >>> │ ├── page_1.py >>> │ └── page_2.py >>> └── your_app.py >>> import streamlit as st >>> >>> if st.button("Home"): >>> st.switch_page("your_app.py") >>> if st.button("Page 1"): >>> st.switch_page("pages/page_1.py") >>> if st.button("Page 2"): >>> st.switch_page("pages/page_2.py") .. output :: https://doc-switch-page.streamlit.app/ height: 350px script_pathrzCould not find page: `zK`. Must be the file path relative to the main script, from the directory: `zL`. Only the main app file and files in the `pages/` directory are supported.r,N)r+r,r/r0)rrr isinstancer _script_hashrstrr main_script_pathospathrealpathr pages_manager get_pagesvalueslenr basename session_state query_paramsclearr1rr+r/r0rr) pagerr,main_script_directoryrequested_page all_app_pagesp matched_pagesqps rr2r2sT  C c))  $ &,, dD !t9D 9#:N:N O))  5t < ))335<<> $1XqQ}5E5WX X }  "'(/((*(8(89N(O'PQEE  )+,>?   ' ' )R  %%))-"%";";))  HHJ1Ys F.F.:F33F<)returnr)rrr#Literal['app', 'fragment']rLz list[str])r#rMrLr)rEzstr | Path | StreamlitPagerLr) __future__rr: itertoolsrpathlibrtypingrr streamlitrstreamlit.errorsrr streamlit.file_utilr r streamlit.navigation.pager streamlit.runtime.metrics_utilr streamlit.runtime.scriptrunnerrrrrr&r'r2rrrYs# $DN392' ' %''T).3 %333l UUr