
    Je                         d Z ddlmZmZm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 dd
lmZ  G d d      Z G d de	      Zy)z
Pylint Code Analysis Plugin.
    )QtSignalSlot)SpyderAPIError)PluginsSpyderDockablePlugin)on_plugin_availableon_plugin_teardown_)is_module_installed)ApplicationMenus)PylintConfigPage)PylintWidgetc                       e Zd ZdZy)PylintActionszrun analysisN)__name__
__module____qualname__AnalyzeCurrentFile     >/usr/lib/python3/dist-packages/spyder/plugins/pylint/plugin.pyr   r      s    'r   r   c                      e Zd ZdZeZeZeZe	j                  e	j                  gZe	j                  e	j                  gZe	j                   gZdZdZ eee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$ e"e	j                        d        Z% e"e	j                        d        Z& e'       d        Z(d Z)d Z*ddZ+d Z, e'       dd       Z-d Z.y)PylintpylintFc                      t        d      S )NzCode Analysisr   r   r   r   get_namezPylint.get_name:   s    !!r   c                     t        d      S )NzRun Code Analysis.r   selfs    r   get_descriptionzPylint.get_description>   s    %&&r   c                 $    | j                  d      S )Nr   )create_iconr    s    r   get_iconzPylint.get_iconA   s    ))r   c           	         | j                         }|j                  j                  | j                         |j                  j                  | j                         | j                  t        j                  t        d      t        d      | j                  d      | j                  t        j                  d      }|j                  t        d             y )NzRun code analysisr   T)texttipicon	triggeredcontextregister_shortcut)
get_widgetsig_edit_goto_requestedconnectsig_start_analysis_requestedstart_code_analysiscreate_actionr   r   r   r$   r   ApplicationShortcut
setEnabledr   )r!   widget
pylint_acts      r   on_initializezPylint.on_initializeD   s    " 	&&..t/K/KL++33D4L4LM '',,&'%&!!(+..**" ( 

 	1(;<r   )pluginc                 `   | j                         }| j                  t        j                        }|j                  j                  |j                         |j                  j                  | j                         | j                  t        j                        }|xj                  |gz  c_        y N)r-   
get_pluginr   Editorr.   r/   loadsig_editor_focus_changed_set_filename
get_actionr   r   pythonfile_dependent_actionsr!   r5   editorr6   s       r   on_editor_availablezPylint.on_editor_availableW   s}    "0 	&&..v{{;''//0B0BC__]%E%EF
 	++
|;+r   c                 d    | j                  t        j                        }|j                  |        y r:   )r;   r   Preferencesregister_plugin_preferencesr!   preferencess     r   on_preferences_availablezPylint.on_preferences_availablee   s$    oog&9&9://5r   c                     | j                  t        j                        }|j                  j	                  | j
                         |j                  j	                  | j                         y r:   )r;   r   Projectssig_project_loadedr/   _set_project_dirsig_project_closed_unset_project_dirr!   projectss     r   on_projects_availablezPylint.on_projects_availablej   sL     ??7#3#34##++D,A,AB##++D,C,CDr   c                     | j                  t        j                        }| j                  t        j
                        }|j                  |t        j                         y N)menu_id)	r;   r   MainMenur@   r   r   add_item_to_application_menur   Source)r!   mainmenur6   s      r   on_main_menu_availablezPylint.on_main_menu_availabler   sI    ??7#3#34__]%E%EF
-- 0 7 7 	. 	9r   c                    | j                         }| j                  t        j                        }|j                  j                  |j                         |j                  j                  | j                         | j                  t        j                        }|j                  d       |j                  j                  |       y )NF)r-   r;   r   r<   r.   
disconnectr=   r>   r?   r@   r   r   
setVisiblerA   removerB   s       r   on_editor_teardownzPylint.on_editor_teardownz   s    "0 	&&11&++>''2243E3EF__]%E%EF
 	e$++22:>r   c                 d    | j                  t        j                        }|j                  |        y r:   )r;   r   rF   deregister_plugin_preferencesrH   s     r   on_preferences_teardownzPylint.on_preferences_teardown   s$    oog&9&9:11$7r   c                     | j                  t        j                        }|j                  j	                  | j
                         |j                  j	                  | j                         y r:   )r;   r   rL   rM   r]   rN   rO   rP   rQ   s     r   on_projects_teardownzPylint.on_projects_teardown   sL     ??7#3#34##..t/D/DE##..t/F/FGr   c                     | j                  t        j                        }|j                  t        j
                  t        j                         y rU   )r;   r   rW   !remove_item_from_application_menur   r   r   rY   )r!   rZ   s     r   on_main_menu_teardownzPylint.on_main_menu_teardown   s;    ??7#3#3422,,$++ 	3 	
r   c                     	 | j                  t        j                        }|r.| j                         j	                  |j                                yy# t        $ r Y yw xY w)z5
        Set filename without code analysis.
        N)r;   r   r<   r-   set_filenameget_current_filenamer   )r!   rC   s     r   r?   zPylint._set_filename   sQ    
	__W^^4F!..v/J/J/LM  		s   AA 	AAc                 H    | j                         }|j                  d|       y Nproject_dirr-   set_conf)r!   valuer5   s      r   rN   zPylint._set_project_dir   s    "u-r   c                 H    | j                         }|j                  dd        y rm   ro   )r!   _unusedr5   s      r   rP   zPylint._unset_project_dir   s    "t,r   Nc                 D    | j                         j                  |       y)a  
        Change history maximum number of entries.

        Parameters
        ----------
        value: int or None, optional
            The valur to set  the maximum history depth. If no value is
            provided, an input dialog will be launched. Default is None.
        )rq   N)r-   change_history_depth)r!   rq   s     r   ru   zPylint.change_history_depth   s     	..U.;r   c                 >    | j                         j                         S )z3
        Get current filename in combobox.
        )r-   get_filenamer    s    r   rw   zPylint.get_filename   s      --//r   c                 N   | j                  t        j                        }|r#| j                  dd      r|j	                         sy|t        |t              r| j                         j                         }| j                  d       | j                         j                  |       y)z
        Perform code analysis for given `filename`.

        If `filename` is None default to current filename in combobox.

        If this method is called while still running it will stop the code
        analysis.
        save_beforeTN)force_focus)r;   r   r<   get_confsave
isinstanceboolr-   rw   switch_to_pluginr1   )r!   filenamerC   s      r   r1   zPylint.start_code_analysis   s|     0}}]D1&++-z(D9(557H$/--h7r   c                 @    | j                         j                          y)z1
        Stop the code analysis process.
        N)r-   stop_code_analysisr    s    r   r   zPylint.stop_code_analysis   s     	,,.r   r:   )/r   r   r   NAMEr   WIDGET_CLASSCONF_SECTIONr   CONF_WIDGET_CLASSr   rF   r<   REQUIRESrW   rL   OPTIONALHelpTABIFY	CONF_FILEDISABLE_ACTIONS_WHEN_HIDDENr   strintr.   staticmethodr   r"   r%   r7   r	   rD   rJ   rS   r[   r
   r`   rc   re   rh   r   r?   rN   rP   ru   rw   r1   r   r   r   r   r   r      s   DLL(##W^^4H  '"2"23Hll^FI"' %S#s3 " "'*=& /< 0<  3 346 56  0 01E 2E  0 019 29 w~~.? /? w2238 48 w//0H 1H w//0
 1
 
V
 
.-
<0 
V8 8(/r   r   N)__doc__qtpy.QtCorer   r   r   spyder.api.exceptionsr   spyder.api.pluginsr   r   )spyder.api.plugin_registration.decoratorsr	   r
   spyder.api.translationsr   spyder.utils.programsr   spyder.plugins.mainmenu.apir   spyder.plugins.pylint.confpager   !spyder.plugins.pylint.main_widgetr   r   r   r   r   r   <module>r      sG   
 ) ( 1 <- % 5 8 ; :( (C/! C/r   