
    g,                       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	 ddl
Z
ddlmc mZ ddlmc mZ ddlmZ ddlmZmZ ddlmZ erddlmZ d	Zd
Z	 	 	 	 d@dZdAdZ e	dedef         ZdBdZ dCdZ! e
jD                  ddi       e
jF                  dd e
jH                  e             e
jJ                  d      dDd                     Z&e&jO                  d      d        Z(e&jO                  d      d        Z)e&jO                  d      d         Z*e&jO                  d!      e d"               Z+e&jO                  d#      e  e
jX                  d$dd%&       e
jX                  d'd()      dEdFd*                            Z-dGd+Z.	 	 dH	 	 	 	 	 dId,Z/e&jE                  d-      d.        Z0e0jO                  d/      d0        Z1e&jE                  d1      d2        ZejO                  d3      e d4               Z2e&jE                  d5d6      e
jf                  d7               Z4e4jO                  d8      d9        Z5e&jE                  d:d;      d<        Z6e6jO                  d=      d>        Z7e8d?k(  r e&        yy)Jz=A script which is run when the Streamlit package is executed.    )annotationsN)TYPE_CHECKINGAnyCallableTypeVar)config)Credentialscheck_credentials)$create_default_cache_storage_manager)ConfigOption)pypy3)errorwarninginfodebugc                   d| j                    }| j                   j                  dd      }| j                  }| j                  r#|d}|d| j                   d| j
                   z  }||| j                  || j                  | j                  dS )z>Composes given config option options as options for click lib.z--._ z
 z - )paramdescriptiontypeoptionenvvarmultiple)	keyreplacer   
deprecateddeprecation_textexpiration_dater   env_varr   )config_optionr   r   r   s       F/var/www/openai/venv/lib/python3.12/site-packages/streamlit/web/cli.py&_convert_config_option_to_click_optionr%   *   s     -##$%F%%c3/E++KK-001]5R5R4ST	

 """''!**     c                     d fd}|S )Nc                T    |y 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"   )_ctx_param	cli_valuer#   s      r$   callbackz1_make_sensitive_option_callback.<locals>.callbackC   s=    }((+ ,&..13
 	
r&   )r*   zclick.Contextr+   zclick.ParameterreturnNone )r#   r-   s   ` r$   _make_sensitive_option_callbackr1   B   s    
 Or&   F.)boundc                (   t        t        j                  j                               D ]g  \  }}t	        |      }|j
                  rdddt        |      d}nd|d   d}t        j                  |d   |d   f|d   |d	   |d
   d|} ||       } i | S )z;Decorator that adds config param keys to click dynamically.FT)expose_valuehiddenis_eagerr-   r   )show_envvarr   r   r   r   r   r   )helpr   r   )	reversed_config_config_options_templateitemsr%   	sensitiver1   clickr   )funcr   valueparsed_parameterclick_option_kwargsr#   s         r$   configurator_optionsrD   R   s    W==CCEF5A%H?? !& ;EB	#  $*84# X&W%
 "-0!&)%j1
 "
 T"1 G2 Kr&   c                B   ddl }t        | d      5 }	 |j                  |      }|j                          |j	                  |j
                         	 ddd       y# |j                  j                  $ r }t        j                  d| d|       d}~ww xY w# 1 sw Y   yxY w)z1Fetch remote file at url_path to main_script_pathr   NwbzUnable to fetch z.
)
requestsopengetraise_for_statuswritecontent
exceptionsRequestExceptionr?   BadParameter)main_script_pathurl_pathrG   fprespes         r$   _download_remoterU   p   s    		%	J<<)D!!#HHT\\"	 
&	%
 ""33 	J$$'7zQC%HII	J 
&	%s(   B<AB2BBBBauto_envvar_prefix	STREAMLIT)context_settingsz--log_levelT)show_defaultr   	Streamlit	prog_namec                P    | r$ddl m}  |t              }|j                  d       yy)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.loggerr^   __name__r   )	log_levelr^   LOGGERs      r$   mainrc   }   s+     /H%T	
	 r&   r9   c                     t                t        t        j                        dk(  sJ dt        j                  d<   t	        d       y)zPrint this help message.   z--help   	streamlitr[   N)_get_command_line_as_stringlensysargvrc   r0   r&   r$   r9   r9      s7    
  !sxx=A CHHQK;r&   versionc                     ddl } t                t        | j                        dk(  sJ d| j                  d<   t	                y)z!Print Streamlit's version number.r   Nre   z	--versionrf   )rj   rh   ri   rk   rc   )rj   s    r$   main_versionrn      s7       !sxx=ACHHQKFr&   docsc                 \    t        j                  d       ddlm}  | j	                  d       y)zShow help in browser.zShowing help page in browser...r   cli_utilzhttps://docs.streamlit.ioN)r?   echorg   rr   open_browserrq   s    r$   	main_docsru      s#     
JJ01"56r&   helloc                 n    ddl m} t        j                  |        |j                  }t        ||        y)zRuns the Hello World script.r   )streamlit_appflag_optionsN)streamlit.hellorx   	bootstrapload_config_options__file__	_main_run)kwargsrx   filenames      r$   
main_hellor      s*     .!!v6%%HhV,r&   runtargetSTREAMLIT_RUN_TARGET)requiredr   args)nargsc                   ddl m} t        j                  |       t        j
                  j                  |       \  }}|dd t        vr6|dd dk(  rt        j                  d      t        j                  d| d	      |j                  |       rdd
lm}  |       5 }ddlm}  ||       j
                  }	t        j
                  j                  ||	j!                  d      j#                  dd      d         }
|j%                  |       } t'        |
|        t)        |
||       ddd       yt        j
                  j+                  |       st        j,                  d|        t)        | ||       y# 1 sw Y   yxY w)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_utilry   rf   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   zFile does not exist: )rg   r   r|   r}   ospathsplitextACCEPTED_FILE_EXTENSIONSr?   BadArgumentUsageis_urlstreamlit.temporary_directoryr   urllib.parser   joinstriprsplitprocess_gitblob_urlrU   r   existsrO   )r   r   r   r   r   	extensionr   temp_dirr   r   rP   s              r$   main_runr      s\    #!!v677##F+LAy}44QR=B(( a  ((A)  MJ  K  vD!X-F#((D!ww||$**S/00a8<  11&9F-v6&6B "! ww~~f%$$'<VH%EFF&$V4 "!s   BE33E<c                     dd l } t        j                         j                  }|y d|j                  v rt        d      |j                  g}|j                  t        j                  dd         | j                  |      S )Nr   zstreamlit.cliz}Running streamlit via `python -m streamlit.cli <command>` is unsupported. Please use `python -m streamlit <command>` instead.rf   )

subprocessr?   get_current_contextparentcommand_pathRuntimeErrorextendrj   rk   list2cmdline)r   r   cmd_line_as_lists      r$   rh   rh      s}    &&(//F~&---P
 	

 ++,CHHQRL)""#344r&   c                r    |g }|i }t               dk(  }t                t        j                  | |||       y )Nzstreamlit hello)rh   r
   r|   r   )filer   rz   is_hellos       r$   r   r     s?    
 |*,0AAHMM$$5r&   cachec                      y)zManage the Streamlit cache.Nr0   r0   r&   r$   r   r          	r&   clearc                 t    t               } | j                          t        j                  j	                          y)z1Clear st.cache_data and st.cache_resource caches.N)r   	clear_allcachingcache_resourcer   )cache_storage_managers    r$   cache_clearr      s,     AB##%  "r&   r   c                      y)z#Manage Streamlit's config settings.Nr0   r0   r&   r$   r   r   1  r   r&   showc                 X    t        j                  |        t        j                          y)z(Show all of Streamlit's config settings.ry   N)r|   r}   r;   show_config)r   s    r$   config_showr   7  s    
 !!v6r&   activate)invoke_without_commandc                b    | j                   s#t        j                         j                          yy)z*Activate Streamlit by entering your email.N)invoked_subcommandr	   get_currentr   )ctxs    r$   r   r   D  s'     !!!**, "r&   resetc                 H    t        j                         j                          y)zReset Activation Credentials.N)r	   r   r   r0   r&   r$   activate_resetr   L  s     ##%r&   test)r6   c                      y)zuInternal-only commands used for testing.

    These commands are not included in the output of `streamlit help`.
    Nr0   r0   r&   r$   r   r   U  s     	r&   r\   c                 ~    t                t        j                         j                  } | J | j                  dk(  sJ y)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streamlit test)rh   r?   r   r   r   )r   s    r$   test_prog_namer   ^  s?      !&&(//F"2222r&   __main__)r#   r   r.   zdict[str, Any])r#   r   )r@   r2   r.   r2   )rP   strrQ   r   r.   r/   )r   )N)r   r   )r.   z
str | None)NN)r   zlist[str] | Nonerz   zdict[str, Any] | Noner.   r/   )9__doc__
__future__r   r   rj   typingr   r   r   r   r?   streamlit.runtime.cachingruntimer   streamlit.web.bootstrapwebr|   rg   r   r;   streamlit.runtime.credentialsr	   r
   *streamlit.web.cache_storage_manager_configr   streamlit.config_optionr   r   
LOG_LEVELSr%   r1   r2   rD   rU   groupr   Choiceversion_optionrc   commandr9   rn   ru   r   argumentr   rh   r   r   r   r   pass_contextr   r   r   r   r`   r0   r&   r$   <module>r      s   D " 	 
 8 8  + + + + ' H 4( 2
0
 CxS)*<
J 3[ABm$\U\\*5MN,
 - O C
( f
  
  i  f7 7 g-  - e40FGb!'5 " H  '5T5( "*.6
6 (6 
	6* G	 	
 w
# 
#  H	 	
    Jt4-  5- 
'& & F4 	 !	 k3 3" zF r&   