ó
‹²,]c           @   s  d  Z  d d l j Z d d l m Z m Z m Z d d l m	 Z	 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 m Z d d l m Z e d d ƒ Z d e f d „  ƒ  YZ d e e f d „  ƒ  YZ d S(   s   Pylint Code Analysis Plugin.iÿÿÿÿN(   t   Qtt   Signalt   Slot(   t	   QGroupBoxt   QInputDialogt   QLabelt   QVBoxLayout(   t   get_translation(   t   SpyderPluginMixin(   t   PluginConfigPage(   t   icon_manager(   t   is_module_installed(   t   create_actiont   MENU_SEPARATORi   (   t   PylintWidgett   pylintt   spyder_pylintt   PylintConfigPagec           B   s   e  Z d  „  Z RS(   c         C   sÈ  t  t d ƒ ƒ } |  j t d ƒ d d t ƒ} t  t d ƒ ƒ } t t d ƒ ƒ } | j t ƒ |  j t d ƒ t d ƒ d	 d d
 d d d d d d ƒ} t  t d ƒ ƒ } t t d ƒ ƒ } | j t ƒ t t j ƒ } | j	 t
 j ƒ | j t ƒ t ƒ  }	 |	 j | ƒ | j |	 ƒ t ƒ  }
 |
 j | ƒ |
 j | ƒ | j |
 ƒ t ƒ  } | j | ƒ | j | ƒ | j | ƒ t ƒ  } | j | ƒ | j | ƒ | j | ƒ | j d ƒ |  j | ƒ d  S(   Nt   Settingss   Save file before analyzing itt   save_beforet   defaultt   Historys5   The following option will be applied at next startup.s	   History: s    resultst   max_entriesi2   t   min_i
   t   max_i@B t   stept   Resultss   Results are stored here:i   (   R   t   _t   create_checkboxt   TrueR   t   setWordWrapt   create_spinboxR   t   DATAPATHt   setTextInteractionFlagsR    t   TextSelectableByMouseR   t	   addWidgett	   setLayoutt
   addStretch(   t   selft   settings_groupt   save_boxt
   hist_groupt   hist_label1t	   hist_spint   results_groupt   results_label1t   results_label2t   settings_layoutt   hist_layoutt   results_layoutt   vlayout(    (    s3   lib/python2.7/site-packages/spyder_pylint/pylint.pyt
   setup_page#   s@    				(   t   __name__t
   __module__R3   (    (    (    s3   lib/python2.7/site-packages/spyder_pylint/pylint.pyR   "   s   t   Pylintc           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 e ƒ  d „  ƒ Z e ƒ  d „  ƒ Z d „  Z RS(   s+   Python source code analysis based on pylintR   c         C   sC   t  j |  d | d |  j d d ƒ ƒt j |  | ƒ |  j ƒ  d  S(   Nt   parentR   i2   (   R   t   __init__t
   get_optionR   t   initialize_plugin(   R&   R7   (    (    s3   lib/python2.7/site-packages/spyder_pylint/pylint.pyR8   X   s    c         C   s
   t  d ƒ S(   s   Return widget titles   Static code analysis(   R   (   R&   (    (    s3   lib/python2.7/site-packages/spyder_pylint/pylint.pyt   get_plugin_titlea   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(    (    s3   lib/python2.7/site-packages/spyder_pylint/pylint.pyt   get_plugin_icone   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
   treewidget(   R&   (    (    s3   lib/python2.7/site-packages/spyder_pylint/pylint.pyt   get_focus_widgetj   s    c         C   sR   t  |  t d ƒ d t j d ƒ t d ƒ d |  j ƒ} |  j j d | f 7_ g  S(   s*   Return a list of actions related to plugins
   History...t   historys   Set history maximum entriest	   triggeredN(   R   R   t   NoneRA   RB   t   change_history_depthRE   t   common_actions(   R&   t   history_action(    (    s3   lib/python2.7/site-packages/spyder_pylint/pylint.pyt   get_plugin_actionsq   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&   (    (    s3   lib/python2.7/site-packages/spyder_pylint/pylint.pyt   on_first_registration{   s    c         C   s½   |  j  j |  j j j ƒ |  j j |  j j ƒ |  j j |  ƒ t |  t	 d ƒ d |  j
 ƒ} | j t d ƒ ƒ |  j | d d d d ƒ|  j j t | g 7_ |  j j j | g 7_ d S(	   s'   Register plugin in Spyder's main windows   Run static code analysisRH   R   t   contextR6   t   names   Run analysisN(   t	   edit_gotot   connectRN   t   editort   loadt   redirect_stdiot   redirect_internalshell_stdiot   add_dockwidgetR   R   t
   run_pylintt
   setEnabledR   t   register_shortcutt   source_menu_actionsR   t   pythonfile_dependent_actions(   R&   t
   pylint_act(    (    s3   lib/python2.7/site-packages/spyder_pylint/pylint.pyt   register_plugin€   s    c         C   s   |  j  ƒ  d S(   s   Refresh pylint widgetN(   t   remove_obsolete_items(   R&   (    (    s3   lib/python2.7/site-packages/spyder_pylint/pylint.pyt   refresh_plugin   s    c         C   s   t  S(   s3   Perform actions before parent main window is closed(   R   (   R&   t
   cancelable(    (    s3   lib/python2.7/site-packages/spyder_pylint/pylint.pyt   closing_plugin“   s    c         C   s   d S(   s*   Apply configuration file's plugin settingsN(    (   R&   t   options(    (    s3   lib/python2.7/site-packages/spyder_pylint/pylint.pyt   apply_plugin_settings—   s    c         C   sV   t  j |  t d ƒ t d ƒ |  j d ƒ d d ƒ \ } } | rR |  j d | ƒ n  d S(   s   Change history max entriesR   s   Maximum entriesR   i
   i'  N(   R   t   getIntR   R9   t
   set_option(   R&   t   deptht   valid(    (    s3   lib/python2.7/site-packages/spyder_pylint/pylint.pyRJ   ž   s    	c         C   sP   |  j  d t ƒ r) |  j j j ƒ  r) d S|  j ƒ  |  j |  j j j ƒ  ƒ d S(   s   Run pylint code analysisR   N(   R9   R   RN   RX   t   savet   switch_to_plugint   analyzet   get_current_filename(   R&   (    (    s3   lib/python2.7/site-packages/spyder_pylint/pylint.pyR]   ¨   s
    
c         C   sT   |  j  r@ |  j r@ |  j  j t ƒ |  j  j ƒ  |  j  j ƒ  n  t j |  | ƒ d S(   s   Reimplement analyze methodN(   RQ   t   ismaximizedt
   setVisibleR   t   setFocust   raise_R   Rp   (   R&   t   filename(    (    s3   lib/python2.7/site-packages/spyder_pylint/pylint.pyRp   ±   s
    N(   R4   R5   t   __doc__t   CONF_SECTIONR   t   CONFIGWIDGET_CLASSR   t   strt   intRV   RI   R8   R;   RD   RF   RM   RS   Rc   Re   t   FalseRg   Ri   R   RJ   R]   Rp   (    (    (    s3   lib/python2.7/site-packages/spyder_pylint/pylint.pyR6   R   s"   					
				
	(    Rw   t   os.pathRC   R=   t   qtpy.QtCoreR    R   R   t   qtpy.QtWidgetsR   R   R   R   t   spyder.config.baseR   t   spyder.pluginsR   t   spyder.plugins.configdialogR	   t   spyder.utilsR
   RA   t   spyder.utils.programsR   t   spyder.utils.qthelpersR   R   t   widgets.pylintguiR   R   R   R6   (    (    (    s3   lib/python2.7/site-packages/spyder_pylint/pylint.pyt   <module>   s   "0