ó
‹²,]c           @   sÿ   d  Z  d d l j Z d d l m Z m Z d d l m Z m	 Z	 m
 Z
 d d l m Z d d l m Z d d l m Z d d l m Z d d	 l m Z d d
 l m Z d d l m Z m Z e d d ƒ Z d e f d „  ƒ  YZ d e e f d „  ƒ  YZ d S(   s   Profiler Plugin.iÿÿÿÿN(   t   Qtt   Signal(   t	   QGroupBoxt   QLabelt   QVBoxLayout(   t   get_translation(   t   SpyderPluginMixin(   t   PluginConfigPage(   t   get_run_configuration(   t   icon_manager(   t   create_actioni   (   t   ProfilerWidgett   is_profiler_installedt   profilert   spyder_profilert   ProfilerConfigPagec           B   s   e  Z d  „  Z RS(   c         C   sÁ   t  t d ƒ ƒ } t t d ƒ ƒ } | j t ƒ t t j ƒ } | j t j	 ƒ | j t ƒ t
 ƒ  } | j | ƒ | j | ƒ | j | ƒ t
 ƒ  } | j | ƒ | j d ƒ |  j | ƒ d  S(   Nt   ResultssR   Profiler plugin results (the output of python's profile/cProfile)
are stored here:i   (   R   t   _R   t   setWordWrapt   TrueR   t   DATAPATHt   setTextInteractionFlagsR    t   TextSelectableByMouseR   t	   addWidgett	   setLayoutt
   addStretch(   t   selft   results_groupt   results_label1t   results_label2t   results_layoutt   vlayout(    (    s7   lib/python2.7/site-packages/spyder_profiler/profiler.pyt
   setup_page    s    		(   t   __name__t
   __module__R    (    (    (    s7   lib/python2.7/site-packages/spyder_profiler/profiler.pyR      s   t   Profilerc           B   sž   e  Z d  Z d Z e Z e e e e ƒ Z	 d d „ Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d	 „  Z e d
 „ Z d „  Z d „  Z d „  Z RS(   s,   Profiler (after python's profile and pstats)R   c         C   sC   t  j |  d | d |  j d d ƒ ƒt j |  | ƒ |  j ƒ  d  S(   Nt   parentt   max_entriesi2   (   R   t   __init__t
   get_optionR   t   initialize_plugin(   R   R$   (    (    s7   lib/python2.7/site-packages/spyder_profiler/profiler.pyR&   @   s    c         C   s
   t  d ƒ S(   s   Return widget titleR#   (   R   (   R   (    (    s7   lib/python2.7/site-packages/spyder_profiler/profiler.pyt   get_plugin_titleI   s    c         C   s+   t  j |  j |  j ƒ } t j d d | ƒS(   s   Return widget iconR   t	   icon_path(   t   ospt   joint   PLUGIN_PATHt   IMG_PATHt   imat   icon(   R   t   path(    (    s7   lib/python2.7/site-packages/spyder_profiler/profiler.pyt   get_plugin_iconM   s    c         C   s   |  j  S(   sq   
        Return the widget to give focus to when
        this plugin's dockwidget is raised on top-level
        (   t   datatree(   R   (    (    s7   lib/python2.7/site-packages/spyder_profiler/profiler.pyt   get_focus_widgetR   s    c         C   s   g  S(   s*   Return a list of actions related to plugin(    (   R   (    (    s7   lib/python2.7/site-packages/spyder_profiler/profiler.pyt   get_plugin_actionsY   s    c         C   s*   |  j  j |  j  j |  ƒ |  j j ƒ  d S(   s3   Action to be performed on first plugin registrationN(   t   maint   tabify_pluginst   helpt
   dockwidgett   hide(   R   (    (    s7   lib/python2.7/site-packages/spyder_profiler/profiler.pyt   on_first_registration]   s    c         C   sÃ   |  j  j |  j j j ƒ |  j j |  j j ƒ |  j j |  ƒ t |  t	 d ƒ d |  j
 ƒ  d |  j ƒ} | j t ƒ  ƒ |  j | d d d d ƒ|  j j | g 7_ |  j j j | g 7_ d S(	   s'   Register plugin in Spyder's main windowt   ProfileR0   t	   triggeredt   contextR#   t   names   Run profilerN(   t	   edit_gotot   connectR6   t   editort   loadt   redirect_stdiot   redirect_internalshell_stdiot   add_dockwidgetR
   R   R2   t   run_profilert
   setEnabledR   t   register_shortcutt   run_menu_actionst   pythonfile_dependent_actions(   R   t   profiler_act(    (    s7   lib/python2.7/site-packages/spyder_profiler/profiler.pyt   register_pluginb   s    c         C   s   d S(   s   Refresh profiler widgetN(    (   R   (    (    s7   lib/python2.7/site-packages/spyder_profiler/profiler.pyt   refresh_pluginr   t    c         C   s   t  S(   s3   Perform actions before parent main window is closed(   R   (   R   t
   cancelable(    (    s7   lib/python2.7/site-packages/spyder_profiler/profiler.pyt   closing_pluginv   s    c         C   s   d S(   s*   Apply configuration file's plugin settingsN(    (   R   t   options(    (    s7   lib/python2.7/site-packages/spyder_profiler/profiler.pyt   apply_plugin_settingsz   s    c         C   s<   |  j  j j ƒ  r8 |  j ƒ  |  j |  j  j j ƒ  ƒ n  d S(   s   Run profilerN(   R6   RB   t   savet   switch_to_plugint   analyzet   get_current_filename(   R   (    (    s7   lib/python2.7/site-packages/spyder_profiler/profiler.pyRG      s    
c      	   C   sÇ   |  j  r@ |  j r@ |  j  j t ƒ |  j  j ƒ  |  j  j ƒ  n  |  j j ƒ  } t | ƒ } d g  } } | d k	 r¡ | j
 r‰ | j } n  | j r¡ | j } q¡ n  t j |  | d | d | d | ƒd S(   s   Reimplement analyze methodt   wdirt   argst
   pythonpathN(   R9   t   ismaximizedt
   setVisibleR   t   setFocust   raise_R6   t   get_spyder_pythonpathR   t   Nonet   wdir_enabledRX   t   args_enabledRY   R   RV   (   R   t   filenameRZ   t   runconfRX   RY   (    (    s7   lib/python2.7/site-packages/spyder_profiler/profiler.pyRV   ‡   s    		N(   R!   R"   t   __doc__t   CONF_SECTIONR   t   CONFIGWIDGET_CLASSR   t   strt   intR@   R`   R&   R)   R2   R4   R5   R;   RM   RN   t   FalseRQ   RS   RG   RV   (    (    (    s7   lib/python2.7/site-packages/spyder_profiler/profiler.pyR#   :   s    										(   Re   t   os.pathR1   R+   t   qtpy.QtCoreR    R   t   qtpy.QtWidgetsR   R   R   t   spyder.config.baseR   t   spyder.pluginsR   t   spyder.plugins.configdialogR   t   spyder.plugins.runconfigR   t   spyder.utilsR	   R/   t   spyder.utils.qthelpersR
   t   widgets.profilerguiR   R   R   R   R#   (    (    (    s7   lib/python2.7/site-packages/spyder_profiler/profiler.pyt   <module>	   s   