
    G@d_                         d Z ddlmZ ddlmZmZ ddlmZm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  G d
 d          Z G d de          ZdS )z
Profiler Plugin.
    )Signal)PluginsSpyderDockablePlugin)on_plugin_availableon_plugin_teardown_)ApplicationMenus)ProfilerConfigPage)ProfilerWidgetis_profiler_installed)get_run_configurationc                       e Zd ZdZdS )ProfilerActionsprofile_current_filename_actionN)__name__
__module____qualname__ProfileCurrentFile     >lib/python3.11/site-packages/spyder/plugins/profiler/plugin.pyr   r      s        :r   r   c                       e Zd ZdZdZej        ej        gZej	        gZ
ej        gZeZeZeZdZ e            Z	  e            Z	 ed             Zd Zd Zd Z eej                  d	             Z eej                  d
             Z eej	                  d             Z eej                  d             Z  eej                  d             Z! eej	                  d             Z"d Z#d Z$d Z%dS )Profilerz7
    Profiler (after python's profile and pstats).
    profilerFc                       t          d          S )Nr   r   r   r   r   get_namezProfiler.get_name:   s    }}r   c                      t          d          S )Nz*Profile your scripts and find bottlenecks.r   selfs    r   get_descriptionzProfiler.get_description>   s    =>>>r   c                 ,    |                      d          S )Nr   )create_iconr   s    r   get_iconzProfiler.get_iconA   s    
+++r   c                    |                                  }|j                            | j                   |j                            | j                   |                     t
          j        t          d          t          d          |                     d          | j	        d          }|
                    t                                 d S )NzRun profilerr   T)texttipicon	triggeredregister_shortcut)
get_widgetsig_startedconnectsig_finishedcreate_actionr   r   r	   r#   run_profiler
setEnabledr   )r    widget
run_actions      r   on_initializezProfiler.on_initializeD   s    """"4#3444##D$5666''.>"".!!!!*--'" ( 
 

 	35566666r   )pluginc                     |                                  }|                     t          j                  }|j                            |j                   d S N)r+   
get_pluginr   Editorsig_edit_goto_requestedr-   loadr    r2   editors      r   on_editor_availablezProfiler.on_editor_availableT   sC    ""00&..v{;;;;;r   c                 n    |                      t          j                  }|                    |            d S r7   )r8   r   Preferencesregister_plugin_preferencesr    preferencess     r   on_preferences_availablez!Profiler.on_preferences_availableZ   s0    oog&9:://55555r   c                     |                      t          j                  }|                     t          j                  }|                    |t          j                   d S N)menu_id)	r8   r   MainMenu
get_actionr   r   add_item_to_application_menur
   Run)r    mainmenur3   s      r   on_main_menu_availablezProfiler.on_main_menu_available_   sZ    ??7#344___%GHH
-- 0 4 	. 	6 	6 	6 	6 	6r   c                     |                                  }|                     t          j                  }|j                            |j                   d S r7   )r+   r8   r   r9   r:   
disconnectr;   r<   s      r   on_editor_teardownzProfiler.on_editor_teardowng   sC    ""00&11&+>>>>>r   c                 n    |                      t          j                  }|                    |            d S r7   )r8   r   r@   deregister_plugin_preferencesrB   s     r   on_preferences_teardownz Profiler.on_preferences_teardownm   s0    oog&9::11$77777r   c                     |                      t          j                  }|                    t          j        t          j                   d S rF   )r8   r   rH   !remove_item_from_application_menur   r   r
   rK   )r    rL   s     r   on_main_menu_teardownzProfiler.on_main_menu_teardownr   sI    ??7#34422.$( 	3 	
 	
 	
 	
 	
r   c                     |                      t          j                  }|                                r=|                                  |                     |                                           dS dS )z
        Run profiler.

        Notes
        -----
        This method will check if the file on the editor can be saved first.
        N)r8   r   r9   saveswitch_to_pluginanalyzeget_current_filename)r    r=   s     r   r0   zProfiler.run_profiler}   sg     00;;== 	8!!###LL446677777	8 	8r   c                 R    |                                                                   dS )z 
        Stop profiler.
        N)r+   stopr   s    r   stop_profilerzProfiler.stop_profiler   s&     	     r   c                     dg }}t          |          }||j        r|j        }|j        r|j        }|                                                     |||           dS )z
        Run profile analysis on `filename`.

        Parameters
        ----------
        filename: str
            Path to file to analyze.
        N)wdirargs)r   wdir_enabledr`   args_enabledra   r+   rZ   )r    filenamer`   ra   runconfs        r   rZ   zProfiler.analyze   s~     2d'11# $|# $|!! 	" 	
 	
 	
 	
 	
r   N)&r   r   r   __doc__NAMEr   r@   r9   REQUIRESrH   OPTIONALHelpTABIFYr   WIDGET_CLASSCONF_SECTIONr   CONF_WIDGET_CLASS	CONF_FILEr   r,   r.   staticmethodr   r!   r$   r4   r   r>   rD   rM   r   rP   rS   rV   r0   r^   rZ   r   r   r   r   r   "   s         D#W^4H !Hl^F!LL*I &((KM688LN   \? ? ?, , ,7 7 7  ///< < 0/<
  34446 6 546  01116 6 216 w~...? ? /.?
 w23338 8 438 w/000
 
 10
8 8 8! ! !
 
 
 
 
r   r   N)rf   qtpy.QtCorer   spyder.api.pluginsr   r   )spyder.api.plugin_registration.decoratorsr   r   spyder.api.translationsr	   spyder.plugins.mainmenu.apir
    spyder.plugins.profiler.confpager   +spyder.plugins.profiler.widgets.main_widgetr   r   spyder.plugins.run.widgetsr   r   r   r   r   r   <module>ry      sD   
       = < < < < < < <- - - - - - - - % % % % % % 8 8 8 8 8 8 ? ? ? ? ? ?P P P P P P P P < < < < < <
; ; ; ; ; ; ; ;D
 D
 D
 D
 D
# D
 D
 D
 D
 D
r   