o
    沪g7                     @  sf   d Z ddlmZ ddlZddlZddlmZmZ dd	d
ZdddZ	dddZ
dddZdddZdS )zUtilities related to the CLI.    )annotationsN)env_utilerrorsmessagestrreturnNonec                 K  sB   zddl }|j| fi | W dS  ty    t| dd Y dS w )zPrint a message to the terminal using click if available, else print
    using the built-in print function.

    You can provide any keyword arguments that click.secho supports.
    r   NT)flush)clicksechoImportErrorprintr   kwargsr
    r   N/var/www/html/chatdoc2/venv/lib/python3.10/site-packages/streamlit/cli_util.pyprint_to_cli   s   r   c                 K  s4   zddl }|j| fi |W S  ty   |  Y S w )zStyle a message using click if available, else return the message
    unchanged.

    You can provide any keyword arguments that click.style supports.
    r   N)r
   styler   r   r   r   r   style_for_cli'   s   r   urlc                 C  s   dd l }||  d S )Nr   )
webbrowseropen)r   r   r   r   r   _open_browser_with_webbrowser6   s   r   commandc                 C  sL   | |g}t tjd}tj||tjd W d    d S 1 sw   Y  d S )Nw)stdoutstderr)r   osdevnull
subprocessPopenSTDOUT)r   r   cmd_liner   r   r   r   _open_browser_with_command<   s   "r#   c                 C  sn   t jr	t|  dS t jrt drtd|  dS t|  dS t jr(td|  dS ddl}t	d|
  d)a  Open a web browser pointing to a given URL.

    We use this function instead of Python's `webbrowser` module because this
    way we can capture stdout/stderr to avoid polluting the terminal with the
    browser's messages. For example, Chrome always prints things like "Created
    new window in existing browser session", and those get on the user's way.

    url : str
        The URL. Must include the protocol.

    Nzxdg-openr   r   z!Cannot open browser in platform "")r   
IS_WINDOWSr   IS_LINUX_OR_BSDis_executable_in_pathr#   	IS_DARWINplatformr   Errorsystem)r   r)   r   r   r   open_browserB   s   


r,   )r   r   r   r   )r   r   r   r   )r   r   r   r   )r   r   r   r   r   r   )__doc__
__future__r   r   r   	streamlitr   r   r   r   r   r#   r,   r   r   r   r   <module>   s   



