L i `ddlmZddlZddlmZmZddlmZerddlm Z  d ddZ y) ) annotationsN)BaseHTTPRequestHandler HTTPServer) TYPE_CHECKING)Iterablect|tr|jdn|d}|tjd}nMt|tr|g}|D]} tj|}|n|t dt|zGfddt}td||ndf|}|jd|j|jy#tj $rYwxYw) a' Display an html document in a web browser without creating a temp file. Instantiates a simple http server and uses the webbrowser module to open the server's URL Parameters ---------- html: str HTML string to display using: str or iterable of str Name of the web browser to open (e.g. "chrome", "firefox", etc.). If an iterable, choose the first browser available on the system. If none, choose the system default browser. port: int Port to use. Defaults to a random port utf8Nz(Failed to locate a browser with name in c eZdZdfd ZdZy)3open_html_in_browser..OneShotRequestHandlerc|jd|jdd|jd}tdt |D]#}|j j |||z%y)Nz Content-typez text/htmlir) send_response send_header end_headersrangelenwfilewrite)self bufferSizei html_bytess X/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/altair/utils/_show.pydo_GETz:open_html_in_browser..OneShotRequestHandler.do_GET9sm   s #   ^[ 9    $J1c*oz: A   AJ!?@ Acy)N)rformatargss r log_messagez?open_html_in_browser..OneShotRequestHandler.log_messageBs rN)returnNone)__name__ __module__ __qualname__rr )rsrOneShotRequestHandlerr 8s A rr&z 127.0.0.1rzhttp://127.0.0.1:) isinstancestrencode webbrowsergetError ValueErrorrropen server_porthandle_request)htmlusingportbrowser browser_keyr&serverrs @ropen_html_in_browserr7 s.)34(=V$4JG }..& eS !GE  K $..5&'  ?G#e*TU U  6  d.dA68MF LL$V%7%7$89: 3##  sCC43C4)NN)r1z str | bytesr2zstr | Iterable[str] | Noner3z int | Noner!r") __future__rr* http.serverrrtypingrcollections.abcrr7rrrr<sM": ( )-@ @ %@ @ @r