
    Yf                        U d dl mZ d dlZd dlmZmZ d dlmZ d dlm	Z	 d dl
mZmZ d dlmZ ej                  j                   Zded	<   dd
Z G d de      Zy)    )annotationsN)AnyCallable)
processors)Frame)FrameRendererProcessorList)SessionzCallable[[str], str]
encode_strc                    | rdS dS )Ntruefalse )a_bools    c/var/www/highfloat_scraper/venv/lib/python3.12/site-packages/pyinstrument/renderers/jsonrenderer.pyencode_boolr      s    6((    c                  @     e Zd ZdZdZd fdZddZd	dZd
dZ xZ	S )JSONRendererz>
    Outputs a tree of JSON, containing processed frames.
    jsonc                $    t        |   di | y )Nr   )super__init__)selfkwargs	__class__s     r   r   zJSONRenderer.__init__   s    "6"r   c                   |yg }|j                  dt        |j                        z         |j                  dt        |j                  xs d      z         |j                  dt        |j                  xs d      z         |j                  d|j
                  xs dz         |j                  d|j                  z         |j                  d	|j                         z         |j                  d
t        |j                  xs d      z         g }|j                  D ]"  }|j                  | j                  |             $ |j                  ddj                  |      z         |j                  r1|j                  dt        |j                  j                        z         |j                  r'|j                  dt        |j                        z         ddj                  |      z  S )Nnullz"function": %sz"file_path_short": %s z"file_path": %sz"line_no": %dr   z
"time": %fz"await_time": %fz"is_application_code": %sFz"children": [%s],z"group_id": %sz"class_name": %sz{%s})appendr   functionfile_path_short	file_pathline_notime
await_timer   is_application_codechildrenrender_framejoingroupid
class_name)r   frameproperty_declschildren_jsonschilds        r   r*   zJSONRenderer.render_frame!   s   = %'.ENN1KKL5
5CXCXC^\^8__`/*U__=RPR2SSTo1C!DElUZZ78053C3C3EEF'+e6O6O6XSX*YY	

 %'^^ 	<E!!$"3"3E":;	<0388N3KKL;;!!"2Z5O"OP!!"4z%BRBR7S"ST000r   c                   | j                  |j                               }g }|j                  d|j                  z         |j                  d|j                  z         |j                  d|j
                  z         |j                  dt        |j                        z         |j                  d|j                  z         |j                  d| j                  |      z         ddj                  |      z  S )	Nz"start_time": %fz"duration": %fz"sample_count": %dz"program": %sz"cpu_time": %fz"root_frame": %sz{%s}
r    )
preprocess
root_framer!   
start_timedurationsample_countr   programcpu_timer*   r+   )r   sessionr/   r0   s       r   renderzJSONRenderer.render@   s     2 2 45$&073E3EEF.1A1AAB2W5I5IIJo
7??0KKL.1A1AAB043D3DU3KKL#((>222r   c                    t         j                  t         j                  t         j                  t         j                  t         j
                  t         j                  t         j                  t         j                  gS )N)	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JSONRenderer.default_processorsM   sT    ''++22//99..AA55	
 		
r   )r   r   )r/   zFrame | None)r;   r
   )returnr	   )
__name__
__module____qualname____doc__output_file_extensionr   r*   r<   rF   __classcell__)r   s   @r   r   r      s$     ##1>3

r   r   )r   bool)
__future__r   r   typingr   r   pyinstrumentr   pyinstrument.framer   pyinstrument.renderers.baser   r	   pyinstrument.sessionr
   encoderencode_basestringr   __annotations__r   r   r   r   r   <module>rX      sD    "    # $ D ( $(<<#A#A
  A)@
= @
r   