
    Yf                        d dl mZ d dlZd dlZd dlZd dlZd dlm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  G d	 d
e      Zy)    )annotationsN)Path)Any)
processors)FrameRendererProcessorList)JSONRenderer)Sessionc                  J     e Zd ZdZdZd fdZd	dZd
ddZd	dZddZ	 xZ
S )HTMLRendererzD
    Renders a rich, interactive web page, as a string of HTML.
    htmlc                $    t        |   di | y )N )super__init__)selfkwargs	__class__s     [/var/www/highfloat_scraper/venv/lib/python3.12/site-packages/pyinstrument/renderers/html.pyr   zHTMLRenderer.__init__   s    "6"    c                "   t        t              j                  dz  }|dz  }|dz  }|j                         r|j                         st	        d      |j                         }|j                         }| j                  |      }d| d| d| d}|S )	Nhtml_resourceszapp.jszapp.csszPCould not find app.js / app.css. Perhaps you need to run bin/build_js_bundle.py?z<!DOCTYPE html>
            <html>
            <head>
                <meta charset="utf-8">
            </head>
            <body>
                <div id="app"></div>

                <script>z!</script>
                <style>zK</style>

                <script>
                    const sessionData = z;
                    pyinstrumentHTMLRenderer.render(document.getElementById('app'), sessionData);
                </script>
            </body>
            </html>
        )r   __file__parentexistsRuntimeError	read_textrender_json)	r   sessionresources_dirjs_filecss_filejscsssession_jsonpages	            r   renderzHTMLRenderer.render   s    X--0@@(* 9,~~x'8b     "''0  u ) *6 7	& r   c                   |ht        j                  dd      }|j                  } t        j                  d      |      5 }|j                  | j                  |             ddd       n@t        j                  |dd      5 }|j                  | j                  |             ddd       t        j                  j                  dd|dddf      }t        j                  |       |S # 1 sw Y   ExY w# 1 sw Y   QxY w)	z
        Open the rendered HTML in a webbrowser.

        If output_filename=None (the default), a tempfile is used.

        The filename of the HTML file is returned.

        Nz.htmlF)suffixdeletezutf-8wfile )tempfileNamedTemporaryFilenamecodecs	getwriterwriter'   openurllibparse
urlunparse
webbrowser)r   r   output_filenameoutput_filefurls         r   open_in_browserzHTMLRenderer.open_in_browserA   s     ""55WUSK)..O*!!'*;7 .1G,-. . _c7; .qG,-. ll%%vr?BB&OP. .. .s   !C'!C3'C03C<c                |    t               }| j                  |_        | j                  |_        |j                  |      S N)r	   r   processor_optionsr'   )r   r   json_renderers      r   r   zHTMLRenderer.render_jsonW   s4    $#'?? *.*@*@'##G,,r   c                    t         j                  t         j                  t         j                  t         j                  t         j
                  t         j                  t         j                  t         j                  gS r?   )	r   remove_importlibremove_tracebackhidemerge_consecutive_self_timeaggregate_repeated_calls"remove_unnecessary_self_time_nodesremove_irrelevant_nodes*remove_first_pyinstrument_frames_processorgroup_library_frames_processor)r   s    r   default_processorszHTMLRenderer.default_processors]   sT    ''++22//99..AA55	
 		
r   )r   r   )r   r
   r?   )r   r
   r9   z
str | None)returnr   )__name__
__module____qualname____doc__output_file_extensionr   r'   r=   r   rK   __classcell__)r   s   @r   r   r      s*     ###J,-

r   r   )
__future__r   r1   r.   urllib.parser5   r8   pathlibr   typingr   pyinstrumentr   pyinstrument.renderers.baser   r   #pyinstrument.renderers.jsonrendererr	   pyinstrument.sessionr
   r   r   r   r   <module>r[      s4    "       # D < (
U
= U
r   