o
    Zh3                     @  s  U d Z ddlmZ ddlZddlZddlmZ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rKdd
lmZ dZded< dZded< doddZdpddZe
dedef dZdqddZ drd#d$Z!ej"d%d&id'ej#d(d)e$ed*ej%d+d,dsdtd/d0Z&e&'d1dud2d1Z(e&'d3dud4d5Z)e&'d6dud7d8Z*e&'d9e dvd<d=Z+e&'d>e ej,d?d)d@dAej,dBdCdDdwdxdFdGZ-dydIdJZ.		dzd{dNdOZ/e&"dPdudQdPZ0e0'dRdudSdTZ1e&"dUdudVdUZe'dWe dvdXdYZ2e&j"dZd)d[ej3d|d^dZZ4e4'd_dud`daZ5e&j"dbd)dcdudddbZ6e6'dedudfdgZ7e&'dhej,didjdkdwd}dldmZ8e9dnkr\e&  dS dS )~z=A script which is run when the Streamlit package is executed.    )annotationsN)TYPE_CHECKINGAnyCallable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)   R/var/www/html/Persson_Maskin/env/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-   r/   r1   r   r)   r*   callbackE   s   
z1_make_sensitive_option_callback.<locals>.callback)r-   r.   r/   r0   r1   r   r   r2   r)   )r   r5   r)   r4   r*   _make_sensitive_option_callbackB   s   	r6   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_eagerr5   r!   )show_envvarr!   r    r   r   r   r"   )helpr   r"   )	reversed_config_config_options_templateitemsr+   	sensitiver6   clickr    )r9   r   valueparsed_parameterclick_option_kwargsr   r)   r)   r*   configurator_optionsT   s.   
rH   main_script_pathstrurl_pathr2   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.exceptionsrL   opengetraise_for_statuswritecontentrD   BadParameter)rI   rK   rP   rL   fpresper)   r)   r*   _download_remoter   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.loggerrd   __name__r   )rc   rd   loggerr)   r)   r*   main   s   rh   r>   c                   C  s   t   dtjd< tdd dS )zPrint this help message.z--help   	streamlitra   N)_get_command_line_as_stringsysargvrh   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	--versionri   )rl   rk   rm   rh   )rl   r)   r)   r*   main_version   s   

ro   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)rD   echorj   rr   open_browserrq   r)   r)   r*   	main_docs   s   
ru   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.hellorx   __file__	_main_run)rw   rx   filenamer)   r)   r*   
main_hello   s   r   runtargetSTREAMLIT_RUN_TARGET)requiredr!   args)nargslist[str] | Nonec                 K  s   ddl m} tj| \}}|dd tvr,|dd dkr#tdtd| d|| rydd	l	m
} | 5}dd
lm} || j}	tj||	dddd }
|| } t|
|  t|
||d W d   dS 1 srw   Y  dS tj| std|  t| ||d dS )zRun a Python script, piping stderr to Streamlit.

    The script can be local or it can be an url. In the latter case, Streamlit
    will download the script to a temporary file and runs this file.

    r   )url_utilri   Nr   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)TemporaryDirectory)urlparse/r   ry   zFile does not exist: )rj   r   ospathsplitextr   rD   BadArgumentUsageis_urlstreamlit.temporary_directoryr   urllib.parser   joinstriprsplitprocess_gitblob_urlr[   r}   existsrW   )r   r   rw   r   r   	extensionr   temp_dirr   r   rI   r)   r)   r*   main_run   s2   




"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.ri   )

subprocessrD   get_current_contextparentcommand_pathRuntimeErrorextendrl   rm   list2cmdline)r   r   cmd_line_as_listr)   r)   r*   rk      s   


rk   filerz   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 )Nry   zstreamlit hello)
r   r   abspathr@   _main_script_pathr   load_config_optionsrk   r   r   )r   r   rz   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   4  r   showc                  K  s   t j| d t  dS )z(Show all of Streamlit's config settings.ry   N)r   r   r@   show_config)rw   r)   r)   r*   config_show:  s   r   activate)invoke_without_commandctxr.   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   G  s   resetc                   C  s   t    dS )zReset Activation Credentials.N)r
   r   r   r)   r)   r)   r*   activate_resetO  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   X  s   rb   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.)rk   rD   r   r   AssertionErrorr   )r   r)   r)   r*   test_prog_namea  s   


r   init	directoryF)r   c              
   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   )PathT)exist_okparentszFailed to create directory: Nzrequirements.txtz
streamlit
zutf-8)encodingzstreamlit_app.pyu   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?)defaultz
Starting Streamlit...)pathlibr   cwdmkdirOSErrorrD   ClickException
write_textrJ   sechors   confirmr}   )r   r   project_dirrZ   rel_path_strapp_pathr)   r)   r*   	main_initx  s.   
r   __main__)r   r   r   r   )r   r   r   r,   )r9   r7   r   r7   )rI   rJ   rK   rJ   r   r2   )r   )rc   rJ   r   r2   )r   r2   )rw   r   r   r2   )N)r   rJ   r   r   rw   r   r   r2   )r   r   )NN)r   rJ   r   r   rz   r   r   r2   )r   r.   r   r2   )r   r   r   r2   ):__doc__
__future__r   r   rl   typingr   r   r   r   r   rD   rj   r   r@   streamlit.runtimer	   streamlit.runtime.credentialsr
   r   streamlit.webr   *streamlit.web.cache_storage_manager_configr   streamlit.config_optionr   r   __annotations__r   r+   r6   r7   rH   r[   groupr    Choiceversion_optionrh   commandr>   ro   ru   r   argumentr   rk   r}   r   r   r   pass_contextr   r   r   r   r   rf   r)   r)   r)   r*   <module>   s   





(
+
