o
    ,&]i(7                     @  s  U d Z ddlmZ ddlZddlZddlmZ ddlmZ ddl	m
Z
mZmZmZ ddlZddlmZ ddlmZ dd	lmZmZ dd
lmZ ddlmZ e
rUddlmZ dZded< dZded< duddZ dvddZ!ededef dZ"dwdd Z#dxd%d&Z$ej%d'd(id)ej&d*d+e'ed,ej(d-d.dydzd1d2Z)e)*d3d{d4d3Z+e)*d5d{d6d7Z,e)*d8d{d9d:Z-e)*d;e#d|d>d?Z.e)*d@e#ej/dAdBdCdDej/dEdFdGd}d~dIdJZ0ddLdMZ1ddOdPZ2		dddTdUZ3e)%dVd{dWdVZ4e4*dXd{dYdZZ5e)%d[d{d\d[Ze*d]e#d|d^d_Z6e)j%d`d+daej7dddd`Z8e8*ded{dfdgZ9e)j%dhd+did{djdhZ:e:*dkd{dldmZ;e)*dnej/dodpdqd}ddrdsZ<e=dtkrke)  dS dS )z=A script which is run when the Streamlit package is executed.    )annotationsN)CallablePath)TYPE_CHECKINGAnyFinalTypeVar)config)caching)Credentialscheck_credentials)	bootstrap)$create_default_cache_storage_manager)ConfigOption)pypy3r   ACCEPTED_FILE_EXTENSIONS)errorwarninginfodebug
LOG_LEVELSconfig_optionr   returndict[str, Any]c                 C  sb   d| j  }| j dd}| j}| jr%|du rd}|d| j d| j 7 }||| j|| j| jdS )	z>Composes given config option options as options for click lib.z--._N z
 z - )paramdescriptiontypeoptionenvvarmultiple)	keyreplacer    
deprecateddeprecation_textexpiration_dater!   env_varr$   )r   r"   r   r     r+   O/var/www/html/IGF-ODF-V3/venv/lib/python3.10/site-packages/streamlit/web/cli.py&_convert_config_option_to_click_option,   s    r-   5Callable[[click.Context, click.Parameter, Any], None]c                   s   d fd	d
}|S )N_ctxclick.Context_paramclick.Parameter	cli_valuer   r   Nonec                   s$   |d u rd S t d jd j)NzSetting zn option using the CLI flag is not allowed. Set this option in the configuration file or environment variable: )
SystemExitr%   r*   )r/   r1   r3   r   r+   r,   callbackG   s   
z1_make_sensitive_option_callback.<locals>.callback)r/   r0   r1   r2   r3   r   r   r4   r+   )r   r7   r+   r6   r,   _make_sensitive_option_callbackD   s   	r8   F.)boundfuncc                 C  s   t tj D ]8\}}t|}|jrdddt|d}nd|d d}tj|d |d f|d |d	 |d
 d|}|| } q| S )z;Decorator that adds config param keys to click dynamically.FT)expose_valuehiddenis_eagerr7   r#   )show_envvarr#   r"   r   r    r!   r$   )helpr!   r$   )	reversed_config_config_options_templateitemsr-   	sensitiver8   clickr"   )r;   r   valueparsed_parameterclick_option_kwargsr   r+   r+   r,   configurator_optionsV   s.   
rJ   main_script_pathstrurl_pathr4   c                 C  s   ddl }ddlm} t| d4}z|j|dd}|  ||j W n |y: } zt	d| d| d}~ww W d   dS 1 sFw   Y  dS )	z2Fetch remote file at url_path to main_script_path.r   N)RequestExceptionwb   )timeoutzUnable to fetch z.
)
requestsrequests.exceptionsrN   opengetraise_for_statuswritecontentrF   BadParameter)rK   rM   rR   rN   fpresper+   r+   r,   _download_remotet   s   "r]   auto_envvar_prefix	STREAMLIT)context_settingsz--log_levelT)show_defaultr!   	Streamlit	prog_namer   	log_levelc                 C  s*   | rddl m} |t}|d dS dS )zTry out a demo with:

        $ streamlit hello

    Or use the line below to run your own script:

        $ streamlit run your_script.py
    r   )
get_loggerzSetting the log level using the --log_level flag is unsupported.
Use the --logger.level flag (after your streamlit command) instead.N)streamlit.loggerrf   __name__r   )re   rf   loggerr+   r+   r,   main   s   rj   r@   c                   C  s   t   dtjd< tdd dS )zPrint this help message.z--help   	streamlitrc   N)_get_command_line_as_stringsysargvrj   r+   r+   r+   r,   r@      s   
versionc                  C  s"   ddl } t  d| jd< t  dS )z!Print Streamlit's version number.r   Nz	--versionrk   )rn   rm   ro   rj   )rn   r+   r+   r,   main_version   s   

rq   docsc                  C  s$   t d ddlm}  | d dS )zShow help in browser.zShowing help page in browser...r   cli_utilzhttps://docs.streamlit.ioN)rF   echorl   rt   open_browserrs   r+   r+   r,   	main_docs   s   
rw   hellokwargsr   c                  K  s"   ddl m} |j}t|| d dS )zRuns the Hello World script.r   )streamlit_appflag_optionsN)streamlit.hellorz   __file__	_main_run)ry   rz   filenamer+   r+   r,   
main_hello   s   r   runtargetstreamlit_app.pySTREAMLIT_RUN_TARGET)defaultr#   args)nargslist[str] | Nonec                 K  s   ddl m} || rWddlm} | 9}ddlm} || j}t| t	j
||dddd }|| }	t||	 t|||d W d	   d	S 1 sPw   Y  d	S t| }
|
 rc|
d
 }
t|
}t| |
 swtd|
 t|||d d	S )u  Run a Python script, piping stderr to Streamlit.

    If omitted, the target script will be assumed to be "streamlit_app.py".

    Otherwise, the target script should be one of the following:
    - The path to a local Python file.
    - The path to a local folder where "streamlit_app.py" can be found.
    - A URL pointing to a Python file. In this case Streamlit will download the
      file to a temporary file and run it.

    To pass command-line arguments to the script, add " -- " before them. For example:

        $ streamlit run my_app.py -- --my_arg1=123 my_arg2
                                   ↑
                                   Your CLI args start after this.
    r   )url_util)TemporaryDirectory)urlparse/rk   r   r{   Nr   zFile does not exist: )rl   r   is_urlstreamlit.temporary_directoryr   urllib.parser   path_check_extension_or_raiseosjoinstriprsplitprocess_gitblob_urlr]   r   r   is_dirrL   existsrF   rY   )r   r   ry   r   r   temp_dirr   url_subpathrK   urlr   path_strr+   r+   r,   main_run   s,   



"r   r   c                 C  sP   t j| \}}|dd  tvr&|dd  dkrtdtd| dd S )Nrk   r   zStreamlit requires raw Python (.py) files, but the provided file has no extension.
For more information, please see https://docs.streamlit.ioz/Streamlit requires raw Python (.py) files, not z<.
For more information, please see https://docs.streamlit.io)r   r   splitextr   rF   BadArgumentUsage)r   r   	extensionr+   r+   r,   r      s   
r   
str | Nonec                  C  sV   dd l } t j}|d u rd S d|jv rtd|jg}|tjdd   | 	|S )Nr   zstreamlit.cliz}Running streamlit via `python -m streamlit.cli <command>` is unsupported. Please use `python -m streamlit <command>` instead.rk   )

subprocessrF   get_current_contextparentcommand_pathRuntimeErrorextendrn   ro   list2cmdline)r   r   cmd_line_as_listr+   r+   r,   rm     s   


rm   filer|   dict[str, Any] | Nonec                 C  sZ   t j| t_tj|pi d |d u rg }|d u ri }t dk}t  t	| ||| d S )Nr{   zstreamlit hello)
r   r   abspathrB   _main_script_pathr   load_config_optionsrm   r   r   )r   r   r|   is_hellor+   r+   r,   r     s   
r   cachec                   C     dS )zManage the Streamlit cache.Nr+   r+   r+   r+   r,   r   :     clearc                  C  s   t  } |   tj  dS )z1Clear st.cache_data and st.cache_resource caches.N)r   	clear_allr   cache_resourcer   )cache_storage_managerr+   r+   r,   cache_clear@  s   	r   r
   c                   C  r   )z#Manage Streamlit's config settings.Nr+   r+   r+   r+   r,   r
   Q  r   showc                  K  s   t j| d t  dS )z(Show all of Streamlit's config settings.r{   N)r   r   rB   show_config)ry   r+   r+   r,   config_showW  s   r   activate)invoke_without_commandctxr0   c                 C  s   | j st   dS dS )z*Activate Streamlit by entering your email.N)invoked_subcommandr   get_currentr   )r   r+   r+   r,   r   d  s   resetc                   C  s   t    dS )zReset Activation Credentials.N)r   r   r   r+   r+   r+   r,   activate_resetl  s   r   test)r=   c                   C  r   )zuInternal-only commands used for testing.

    These commands are not included in the output of `streamlit help`.
    Nr+   r+   r+   r+   r,   r   u  s   rd   c                  C  s@   t   t j} | du rtd| jdkrtd| j ddS )zAssert that the program name is set to `streamlit test`.

    This is used by our cli-smoke-tests to verify that the program name is set
    to `streamlit ...` whether the streamlit binary is invoked directly or via
    `python -m streamlit ...`.
    Nzparent is Nonezstreamlit testzParent command path is z not streamlit test.)rm   rF   r   r   AssertionErrorr   )r   r+   r+   r,   test_prog_name~  s   


r   init	directoryF)requiredc              
   C  s  ddl m} | r|| n| }z	|jddd W n ty- } ztd| d}~ww |d jdd	d
 |d jdd	d
 | rFt| nd}tj	ddd tj	| dd tj
ddd tj	d| ddd tjdddr|d }t
d tt| dS dS )zInitialize a new Streamlit project.

    If DIRECTORY is specified, create it and initialize the project there.
    Otherwise use the current directory.
    r   r   T)exist_okparentszFailed to create directory: Nzrequirements.txtz
streamlit
zutf-8)encodingr   u   import streamlit as st

st.title("🎈 My new app")
st.write(
    "Let's start building! For help and inspiration, head over to [docs.streamlit.io](https://docs.streamlit.io/)."
)
r   u!   ✨ Created new Streamlit app in F)nlblue)fgu   🚀 Run it with: zstreamlit run z/streamlit_app.pyu   ❓ Run the app now?)r   z
Starting Streamlit...)pathlibr   cwdmkdirOSErrorrF   ClickException
write_textrL   sechoru   confirmr   )r   r   project_dirr\   rel_path_strapp_pathr+   r+   r,   	main_init  s.   
r   __main__)r   r   r   r   )r   r   r   r.   )r;   r9   r   r9   )rK   rL   rM   rL   r   r4   )r   )re   rL   r   r4   )r   r4   )ry   r   r   r4   )N)r   rL   r   r   ry   r   r   r4   )r   rL   r   r4   )r   r   )NN)r   rL   r   r   r|   r   r   r4   )r   r0   r   r4   )r   r   r   r4   )>__doc__
__future__r   r   rn   collections.abcr   r   r   typingr   r   r   r	   rF   rl   r
   rB   streamlit.runtimer   streamlit.runtime.credentialsr   r   streamlit.webr   *streamlit.web.cache_storage_manager_configr   streamlit.config_optionr   r   __annotations__r   r-   r8   r9   rJ   r]   groupr"   Choiceversion_optionrj   commandr@   rq   rw   r   argumentr   r   rm   r   r   r   r   pass_contextr   r   r   r   r   rh   r+   r+   r+   r,   <module>   s   





4

+
