
    G@dB                        d Z ddlZddlmZ ddlZddlZddlZddlZddl	Z	ddl
mZ ddlmZmZmZmZmZ ddlmZ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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+m,Z, ddl*m-Z- ddl.m/Z/m0Z0 ddl1m2Z2m3Z3 ddl4m5Z5m6Z6 e	j7        Z8dZ9dZ:e0j;        Z<e0j=        Z>e0j?        Z@e/jA        ZBe/jA        ZC G d d          ZD G d d          ZE G d d          ZF G d d          ZG G d de          ZH G d d e5          ZI G d! d"e          ZJd# ZKeLd$k    r eK             dS dS )%zPylint widget.    N)getopenfilename)
QByteArrayQProcessQProcessEnvironmentSignalSlot)QInputDialogQLabelQMessageBoxQTreeWidgetItemQVBoxLayout)on_conf_change_)PluginMainWidget)get_conf_path
is_pynsistrunning_in_mac_app)is_anaconda)get_pylintrc_path)
TextEditor)ima)getcwd_or_homeget_home_dir)get_python_executable)QStylePaletteSpyderPalette)PythonModulesComboBoxis_module_or_package)OneColumnTreeOneColumnTreeActions   d   c                       e Zd ZdZdZdZdZdS )PylintWidgetActionschange_history_depth_actionrun_analysis_actionbrowse_action
log_actionN)__name__
__module____qualname__ChangeHistoryRunCodeAnalysis
BrowseFileShowLog     Alib/python3.11/site-packages/spyder/plugins/pylint/main_widget.pyr%   r%   @   s"        1M+O JGGGr2   r%   c                       e Zd ZdZdZdZdS )PylintWidgetOptionsMenuSectionsglobal_sectionsection_sectionhistory_sectionN)r*   r+   r,   GlobalSectionHistoryr1   r2   r3   r5   r5   G   s        FGGGGr2   r5   c                       e Zd ZdZdS )PylintWidgetMainToolbarSectionsmain_sectionN)r*   r+   r,   Mainr1   r2   r3   r=   r=   M   s        DDDr2   r=   c                   "    e Zd ZdZdZdZdZdZdS )PylintWidgetToolbarItems
file_combo
rate_label
date_labelstretcher_1stretcher_2N)r*   r+   r,   FileComboBox	RateLabel	DateLabel
Stretcher1
Stretcher2r1   r2   r3   rA   rA   Q   s'        LIIJJJJr2   rA   c                        e Zd ZdZ ed           ej        d          d ed           ej        d          d ed           ej        d          d ed	           ej        d
          ddZ fdZ xZ	S )CategoryItemz~
    Category item for results.

    Notes
    -----
    Possible categories are Convention, Refactor, Warning and Error.
    
Convention
convention)translation_stringiconRefactorrefactorWarningwarningErrorerror)rN   rR   rT   rV   c                 J   |dk    s|dk    rt          d          }nt          d          }| j        |         d         }|d| d| dz  }t                                          ||gt          j                   | j        |         d	         }|                     d|           d S )
N   r   messagesmessagerP    ( )rQ   )r   
CATEGORIESsuper__init__r   TypesetIcon)selfparentcategorynumber_of_messagesrZ   titlerQ   	__class__s          r3   ra   zCategoryItem.__init__v   s    !!%71%<%<}}HH||H )*>?6(6686666%/*>??? x(0Qr2   )
r*   r+   r,   __doc__r   r   rQ   r_   ra   __classcell__ri   s   @r3   rM   rM   Z   s          #$!L//CH\**
 

 #$!J--CHZ((
 

 #$!I,,CHY''
 

 #$!G**CHW%%
 
 J&        r2   rM   c                   X     e Zd Z eeee          Z	  fdZd Zd Z	d Z
d Zd Z xZS )ResultsTreec                     t                                          |           d | _        d | _        d | _        |                     d           d S N )r`   ra   filenameresultsdata	set_title)rd   re   ri   s     r3   ra   zResultsTree.__init__   sH       	rr2   c                     | j                             t          |                    }|#|\  }}| j                            ||d           dS dS )zDouble-click eventNrq   )rt   getidsig_edit_goto_requestedemit)rd   itemrt   fnamelinenos        r3   	activatedzResultsTree.activated   sS    y}}RXX&& ME6(--eVR@@@@@ r2   c                     t          |t                    rB|                                r|                     |           dS |                     |           dS |                     |           dS )zClick event.N)
isinstancerM   
isExpandedcollapseItem
expandItemr~   )rd   r{   s     r3   clickedzResultsTree.clicked   sp    dL)) 	!   &!!$'''''%%%%%NN4     r2   c                 X    |                                   |                     d           d S rp   )clearru   rd   s    r3   clear_resultszResultsTree.clear_results   s'    

rr2   c                 J    || _         || _        |                                  d S N)rr   rs   refresh)rd   rr   rs   s      r3   set_resultszResultsTree.set_results   s!     r2   c                 t   t          d          | j        z   }|                     |           |                                  i | _        d| j        d         fd| j        d         fd| j        d         fd| j        d	         ff}|D ]\  }}t          | |t          |                    }|s|                    d
           i }|D ]q}t          |          dk    r t          t          |          d gz             }|\  }}	}
}}t          j        t          j        | j                            d         }|                    |          s|                    |          }||d          }t          j        | j                  }|                    d          s||k    rt          j        ||          }n%t          j        |g|                    d          R  }t          j        |          rt          j        |d          }dD ] }t          j        ||z             r||z   } n!t          j        | j                  rc|                    |          }|Kt-          ||gt,          j                  }|                    dt3          j        d                     |||<   |}n|}t          |          dk    r|sd}nd}|dz  }|                    |||	|
          }t-          ||gt,          j                  }|                    dt3          j        d                     ||	f| j        t9          |          <   sd S )NzResults for rN   C:rR   R:rT   W:rV   E:T   r   .ra   )z.pyz.pywpythonrY   z	{msg_id} z{msg_id} ({message_name}) zline {lineno}: {message})msg_idmessage_namer}   r[   arrow)r   rr   ru   r   rt   rs   rM   lensetDisabledtuplelistospsplitextbasename
startswithfinddirnamejoinsplitisdirisfilerw   r   rb   rc   r   rQ   formatrx   )rd   rh   rs   rf   rZ   
title_itemmodulesmessage_datamoduler}   r[   r   r   r   i_baser   modnameextre   r{   message_stringmsg_items                         r3   r   zResultsTree.refresh   sm   .!!DM1u

	 4<-.d+,T*+dl4()	
 #* 9	< 9	<Hh%dHc(mmDDJ -&&t,,,G ( 3< 3<|$$))#(l););tf)D#E#EL@L=<T](C(CDDQG((22 -#[[22F#FGG_F+dm44$$S)) DVx-?-?!hw77GG!hwCc1B1BCCCG9W%% <!hw
;;G*  Cz'#+.. ")C- 9T]++ 	($[[11F~.zF8/>/C E  EQ(:(:;;;+/(!%'Fv;;??' F)4)E"<<!/!6!6!!7 "7 "4 "4 +^,o.BD D  CHW$5$5666+2F*;	"X,,''g3<9	< 9	<r2   )r*   r+   r,   r   strintry   ra   r~   r   r   r   r   rk   rl   s   @r3   rn   rn      s        $fS#s33    A A A! ! !    
G< G< G< G< G< G< G<r2   rn   c                       e Zd ZdZdZ ed          ZdZ ee	e
e	          Z	  e            Z	 d) fd	Z e            d             Zd*d	Zd
 Zd Zd Zd Zd Zd Zd Zd Zd Z eddg          d             Zd Zd Z e             ee
          d+d                        Zd Z ee	          d             Z d+dZ!d Z"d Z#d Z$d  Z%d! Z&d*d"Z' e            d#             Z(d$ Z) e            d+d%            Z*d& Z+d' Z,d( Z- xZ.S ),PylintWidgetz
    Pylint widget.
    Tzpylint.resultsz1.1.0Nc                    t                                          |||           d | _        d | _        d | _        d | _        g | _        |                     d          | _        d | _	        d | _
        t          | t          j                  | _        t          |           | _        t          j        | j        _        t          |           | _        t          j        | j        _        t+          |           | _        t/          j        | j                  r	 t5          | j        d          5 }t7          j        |                                          }d d d            n# 1 swxY w Y   |d         | j        k    r|dd          | _        n# t>          t@          f$ r Y nw xY w| j        !                    | j        j"                   | j        d d d         D ]}| #                    |           tI                      }|%                    | j                   | &                    |           | j        j'        (                    | j)                   | j        j*        (                    | j*                   d S )Nhistory_filenamesid_rbr   rY   )+r`   ra   _processoutputerror_outputrr   rdataget_confcurr_filenamescode_analysis_actionr(   r   rA   rG   	filecombor
   	ratelabelrH   ID	datelabelrI   rn   
treewidgetr   r   DATAPATHopenpickleloadsreadVERSIONEOFErrorImportErrorsetInsertPolicyInsertAtTopset_filenamer   	addWidget	setLayoutvalidconnect_check_new_filery   )	rd   namepluginre   fhrt   r|   layoutri   s	           r3   ra   zPylintWidget.__init__'  s{   vv...  
"mm,?@@$(!! /.;= = =  4>4>%d++:dm$$ 	$-.. 3"!<		22D3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 7dl**!%abbDJk*    	&&t~'ABBB(2. 	% 	%Ee$$$$ )))v 	$$T%9:::/77(	* 	* 	* 	* 	*s6   F ''EF EF !E"#F FFc                 F                                       d _        d _        t                     x _        }|                    t          j                   |                    t                                 |j	        
                     j                   |j        
                     fd           |j        
                    t          j        f fd	                                                                           }t#                      }|                    dd           t&          j        dk    rt+                      }t&          j                            d|          }|                    d|           t1                      sAt3                      s3|                    dt&          j                            d                     t5                      r5t&          j                            d	          }|                    d	|           |                    |           |                    t:          j        |           |                                }|sF                                   tC          j"         tG          d
          tG          d                     dS dS )zStart the code analysis.rq   c                  0                          d          S )NT)rW   )_read_outputr   s   r3   <lambda>z%PylintWidget._start.<locals>.<lambda>g  s    D%%D%11 r2   c                 0                         | |          S r   )	_finished)ecesrd   s     r3   r   z%PylintWidget._start.<locals>.<lambda>i  s    t~~b"/E/E r2   PYTHONIOENCODINGutf8ntUSERPROFILEAPPDATA
PYTHONHOMErV   zProcess failed to startN)$start_spinnerr   r   r   r   setProcessChannelModeSeparateChannelssetWorkingDirectoryr   readyReadStandardOutputr   r   readyReadStandardErrorfinished
ExitStatusget_commandget_filenamer   insertosr   r   environrw   r   r   r   setProcessEnvironmentstartsys
executablewaitForStartedstop_spinnerr   criticalr   )rd   processcommand_argsprocessEnvironmenthome_diruser_profilepyhomerunnings   `       r3   _startzPylintWidget._start[  sq    	"*4..0%%h&?@@@##N$4$4555'//0ABBB&..1111	3 	3 	3  "-EEEEE	G 	G 	G ''(9(9(;(;<<022!!"4f===7d?? $~~H:>>-BBL%%m\BBB << P P")))RZ^^I5N5NOOO  	<Z^^L11F%%lF;;;%%&8999cnl333((** 	 '

+,,    	 	r2   Fc                    | j         }|r |                    t          j                   n|                    t          j                   t                      }|                                rE|r||                                z  }n||                                z  }|                                Et          |
                                d          }|r| xj        |z  c_        n| xj        |z  c_        |                                  d S )Nzutf-8)r   setReadChannelr   StandardErrorStandardOutputr   bytesAvailablereadAllStandardErrorreadAllStandardOutputr   rt   r   r   update_actions)rd   rW   r   qbatexts        r3   r   zPylintWidget._read_output  s   - 	<""8#9::::""8#:;;;ll$$&& 	7 7w33555w44666	 $$&& 	7 388::w'' 	 %KK4KKr2   c                 j   | j         sh|                                  | j        rKt          j        | t          d          | j                   t          d| j        z   t          j                   d S | 	                                }| 
                    | j                   \  }}}|                                  |                     |t          j                    |||f           | j        | j         z   | _         |                     d           |                                  |                                  d S )NrV   zpylint error:

)fileT)justanalyzed)r   r   r   r   r   r   printr   stderrr   parse_output_save_historyset_datatime	localtime	show_datar  )rd   	exit_codeexit_statusrr   ratepreviousrs   s          r3   r   zPylintWidget._finished  s)   { 		  P$gJJ%  
 )D,==CJOOOOF$$&&"&"3"3DK"@"@hh!1!147 KLLL'$+5D)))r2   c                 ~    |                                  }|| j        k    r|| _        |                                  d S d S r   )r   rr   r  )rd   r|   s     r3   r   zPylintWidget._check_new_file  sE    !!##DM!!!DMNN "!r2   c                 \    | j         }|d uo!|                                t          j        k    S r   )r   stater   Running)rd   r   s     r3   _is_runningzPylintWidget._is_running  s)    -d"Jw}}(:J'JJr2   c                     | j                                          | j                             d           |                                  d S )Ni  )r   closewaitForFinishedr   r   s    r3   _kill_processzPylintWidget._kill_process  sD    %%d+++r2   c                 Z   |                      d          }| j                                        |k    r| j                                        }||z
  }t          |          D ]8}| j                                        }| j                            |dz
             9| j                                         dS | j                                        }||z
  }t          |||z             D ]E}|t          | j                  k    r dS | j        |         }| j                            ||           FdS )z:Change the number of files listed in the history combobox.max_entriesrY   N)	r   r   countrange
removeItemselectedr   r   
insertItem)rd   r'  num_elementsdiff__iact_filenames          r3   _update_combobox_historyz%PylintWidget._update_combobox_history  s3   mmM22>!!K//>//11L+-DDkk < <#~3355)),*:;;;;N##%%%%%>//11L-D<)<== ; ;D/0000EE#215))!\::::	; ;r2   c                    | j         rwg }| j        D ]<}t          d          |vr)t          j        |          }|                    |           =|dt                   | _        |                     d| j                   dS g | _        dS )z#Save the current history filenames.untitledNr   )re   r   r   r   normpathappendMAX_HISTORY_ENTRIESset_conf)rd   list_save_filesr|   rr   s       r3   r  zPylintWidget._save_history  s    ; 
	% O, 5 5Z==--"|E22H#**8444"12F3F2F"GDMM-t/BCCCCC"$Dr2   c                      t          d          S )NzCode Analysisr   r   s    r3   	get_titlezPylintWidget.get_title  s    !!!r2   c                     | j         S r   )r   r   s    r3   get_focus_widgetzPylintWidget.get_focus_widget  s
    r2   c                 J	   |                      t          j        t          d          t          d          |                     d          | j                  }|                      t          j        t          d          t          d          |                     d          | j                  | _        |                      t          j	        t          d          t          d          |                     d          | j
                  | _        |                      t          j        t          d	          t          d
          |                     d          | j                  | _        |                                 }|                     | j                            t&          j                  |t*          j                   |                     | j                            t&          j                  |t*          j                   |                     | j                            t&          j                  |t*          j                   |                     | j                            t&          j                  |t*          j                   |                     ||t*          j                   |                     || j        j        t*          j                   | j        j                            d           |                                 }| j         | j        | j        fD ]$}| !                    ||tD          j#                   %| $                    d          }| j%        | &                    tN          j(                  | j)        | &                    tN          j*                  | j        fD ]$}| !                    ||tD          j#                   %| +                                 | j,        rs| -                                 | j         .                    d| /                                           | j        0                    | j         1                                           n| j        0                    d           | j         j2        3                    | j        j0                   d S )Nz
History...zSet history maximum entrieshistory)r  tiprQ   	triggeredzRun code analysisrunSelect Python filefileopenOutputzComplete outputlog)menusectionFrH  	secondaryr   r   )4create_actionr%   r-   r   create_iconchange_history_depthr.   sig_start_analysis_requestedr   r/   select_filer(   r0   show_logr)   get_options_menuadd_item_to_menur   
get_actionr!   CollapseAllActionr5   r9   ExpandAllActionCollapseSelectionActionr:   ExpandSelectionActionr;   rG  restore_action
setVisibleget_main_toolbarr   add_item_to_toolbarr=   r?   create_toolbarr   create_stretcherrA   rJ   r   rK   r  r   remove_obsolete_itemsinsertItemsget_filenames
setEnabledis_validr   r   )rd   r&   options_menutoolbarr{   secondary_toolbars         r3   setupzPylintWidget.setup  s   &*&8&8-</00!!),,/ '9 '
 '
# %)$6$6/&''%&&!!%((7 %7 %
 %
! "//*'((&''!!*--& 0 
 
 ,,'8#$$!!%((m - 
 
 ,,..O&&$68 83:	 	 	
 	
 	
 	O&&$46 63:	 	 	
 	
 	
 	O&&$<> >3;	 	 	
 	
 	
 	O&&$:< <3;	 	 	
 	
 	
 	'3; 	 	
 	
 	
 	'%3; 	 	
 	
 	

 	&11%888''))^T%7.0 	 	D$$7< %     !//<<^**5@ + B B^**5@ + B B_& 	 	D $$!7< %     	: 	8&&(((N&&q$*<*<*>*>???%001H1H1J1JKKKK%00777 	$$T%>%IJJJJJr2   r'  r   )optionc                     |dk    r|                                   d S |dk    r|| _        |                                   d S d S )Nr'  r   )r2  r   )rd   rg  values      r3   on_conf_updatezPylintWidget.on_conf_updateU  sY    ]""))+++++***"'D))+++++ +*r2   c                    |                                  r.| j                            |                     d                     n-| j                            |                     d                     |                                  d S )NstoprB  )r!  r   rc   rL  r^  r   s    r3   r  zPylintWidget.update_actions]  s|     	G%--d.>.>v.F.FGGGG%--d.>.>u.E.EFFF""$$$$$r2   c                 .    |                                   d S r   )stop_code_analysisr   s    r3   on_closezPylintWidget.on_closee  s    !!!!!r2   c                 h    |t                     }|                    d           |                    t          d                     |                    t          d                     |                    t           j                   |                    t          t                     |
                    d           |                                         d                     |j                             fd           |                                 dS                      d|           dS )a  
        Set history maximum 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.
        NFr;   zMaximum entriesrY   r'  c                 0                         d|           S )Nr'  )r8  )ri  rd   s    r3   r   z3PylintWidget.change_history_depth.<locals>.<lambda>  s    dmmM5AA r2   )r	   setModalsetWindowTitler   setLabelTextsetInputModeIntInputsetIntRangeMIN_HISTORY_ENTRIESr7  
setIntStepsetIntValuer   intValueSelectedr   showr8  )rd   ri  dialogs   `  r3   rM  z!PylintWidget.change_history_depthj  s    =!$''F OOE"""!!!I,,///"3 4 4555 566624GHHHa   t}}];;<<< #++AAAAC C C KKMMMMMMM-/////r2   c                 N    t          | j                                                  S )z3
        Get current filename in combobox.
        )r   r   currentTextr   s    r3   r   zPylintWidget.get_filename  s      4>--//000r2   c                    |                                  r|                                  t          |          }t          j        |          }|                                 |k    rdS |                     |          \  }}|| j        vrQ| j        	                    d|           | j        
                    d|           | j                            d           n	 | j                            |          }| j                            |           | j                            |           n*# t          $ r | j                            |           Y nw xY w| j        	                    d|           | j        
                    d|           | j                            d           | j                                        }||                     d          k    r| j                            |dz
             | j                                         dS )z3
        Set current filename in combobox.
        Nr   r'  rY   )r!  r%  r   r   r5  r   get_datar   r   r,  r   setCurrentIndexfindTextr*  pop
IndexErrorremover(  r   r+  )rd   rr   index_datar-  s        r3   r   zPylintWidget.set_filename  s   
  	!   x==<))
 (**F}}X..u4...N%%a222&&q(333N**1----5//99))%000#''.... 5 5 5#**8444445N%%a222&&q(333N**1---~++--$--6666N%%lQ&6777!!!!!s   AD( ($EEc                    |                                  r|                                  nD||                     |           | j                                        r|                                  |                                  dS )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.
        N)r!  r%  r   r   rb  r  r  )rd   rr   s     r3   start_code_analysisz PylintWidget.start_code_analysis  s      	    #!!(+++~&&(( r2   c                 Z    |                                  r|                                  dS dS )z1
        Stop the code analysis process.
        N)r!  r%  r   s    r3   rn  zPylintWidget.stop_code_analysis  s:      	!     	! 	!r2   c                 2    d | j         D             | _         dS )z*
        Removing obsolete items.
        c                 :    g | ]\  }}t          |          ||fS r1   )r   ).0rr   rt   s      r3   
<listcomp>z6PylintWidget.remove_obsolete_items.<locals>.<listcomp>  s=     9 9 9>8T-h779x& 9 9 9r2   Nr   r   s    r3   r^  z"PylintWidget.remove_obsolete_items  s'    9 9TZ 9 9 9


r2   c                 $    d | j         D             S )zI
        Return all filenames for which there is data available.
        c                     g | ]\  }}|S r1   r1   )r  rr   r  s      r3   r  z.PylintWidget.get_filenames.<locals>.<listcomp>  s    ;;;_Xu;;;r2   r  r   s    r3   r`  zPylintWidget.get_filenames  s     <;
;;;;r2   c                     t          j        |          }t          | j                  D ]\  }\  }}||k    r||fc S dS )zG
        Get and load code analysis data for given `filename`.
        )NN)r   abspath	enumerater   )rd   rr   r  r|   rt   s        r3   r  zPylintWidget.get_data  s\     ;x(($-dj$9$9 	 	 E=E4  d{""" ! :r2   c                 T   t          j        |          }|                     |          \  }}|| j                            |           | j                            d||f           t          | j                  |                     d          k    rE| j                            d           t          | j                  |                     d          k    Et          | j	        d          5 }t          j        | j        g| j        z   |d           ddd           dS # 1 swxY w Y   dS )zI
        Set and save code analysis `data` for given `filename`.
        Nr   r'  r   wb   )r   r  r  r   r  r   r   r   r   r   r   dumpr   )rd   rr   rt   r  r  r   s         r3   r  zPylintWidget.set_data  sG    ;x((}}X..uJNN5!!!
!h-...$*oom < <<<JNN2 $*oom < <<< $-&& 	<"K3R;;;	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	<s   +%DD!$D!c                    t           }t          }|sd| _        | j                            | j        duot          | j                  dk               |                                 r|                                  |                                 }|sdS | 	                    |          \  }}|+t          d          }| j                                         d}n|\  }	}
}}|
+t          d          }| j                                         d}nd}d}d}t          }t          |
          d	k    rt          }nt          |
          d
k    rt           }t          d          }|||fz  ||d|
z  fz  z   }|r"t          d          }d|d|d}||||fz  z  }| j                            ||           t%          j        d|	          }|||fz  }| j                            |           | j                            |           dS )z*
        Show data in treewidget.
        Nr   z#Source code has not been rated yet.rq   z7Analysis did not succeed (see output for more details).z)<span style="color: %s"><b>%s </b></span>z(<span style="color: %s"><b>%s</b></span>z!<span style="color: %s">%s</span>g      @g      @zGlobal evaluation:z%s/10zprevious run:r\   r]   z/10)z%Y-%m-%d %H:%M:%S)MAIN_TEXT_COLORMAIN_PREVRATE_COLORr   r)   ra  r   r!  r%  r   r  r   r   r   DANGER_COLORfloatSUCCESS_COLORWARNING_COLORr   r  strftimer   setTextr   )rd   r  
text_colorprevrate_colorrr   _indexrt   r  	date_textdatetimer  previous_raters   
text_style
rate_styleprevrate_stylecolor	text_prundates                      r3   r  zPylintWidget.show_data  sA    %
, 	DK""4;d#: $<'*4;'7'7!';	= 	= 	=  	!   $$&& 	F}}X..<:;;DO))+++II592HdM7| : ; ;--///		J
I
!F$;;##)EE4[[2%%)E-..#z4&88%4(AAC  I !/ 2 2II1:MMM JINni-HHHD++Hg>>>}%8(CC&*d);;	t$$$y)))))r2   c                     | j         rQt          | j         t          d          | d          }|                    dd           |                                 dS dS )z)
        Show output log dialog.
        zCode analysis outputT)rh   re   readonlyi  i  N)r   r   r   resizeexec_)rd   output_dialogs     r3   rP  zPylintWidget.show_log5  ss    
 ; 	"&.//	  M   c***!!!!!	" 	"r2   c                     t          j        |          t                      |                     d          t          j        d          g}t          |          S )zQ
        Get the path to the most proximate pylintrc config to the file.
        project_dir~)search_paths)r   r   r   r   
expanduserr   )rd   rr   r  s      r3   r   zPylintWidget.get_pylintrc_pathF  sP     K!!MM-((N3	
 !l;;;;r2   c                 H   |r| j                             d           t          | t          d          t	                      t          d          dz             \  }}| j                             d           |r+|                     |           |                                  dS dS )z
        Select filename using a open file dialog and set as current filename.

        If `filename` is provided, the dialog is not used.
        NFrC  zPython filesz (*.py ; *.pyw)T)sig_redirect_stdio_requestedrz   r   r   r   r   r  )rd   rr   
_selfilters      r3   rO  zPylintWidget.select_fileW  s     -225999#2&''  .!!$55	$ $ Hj -224888 	'h'''$$&&&&&	' 	'r2   c                 t   t          j        |                     dd                    }|                     dd          st                      |k    rd}nbt          j        |          rLt
          j        dk    rt          j        |          }n)t          j        t          j        |                    }nd}|S )z|
        Check if custom interpreter is active and if so, return path for the
        environment that contains it.
        r   main_interpreterrI  defaultNr   )r   r5  r   r   r   r   r   r   )rd   custom_interpreterpath_of_custom_interpreters      r3   test_for_custom_interpreterz(PylintWidget.test_for_custom_interpreterl  s    
 !\MM,0BMCC
 

 MM)-?M@@	2$&&*<<<)-&& z,-- 2
 7d??14*2, 2,.. 25S[*>, >, 2- 2-.. .2*))r2   c                 2   g }t           g d}|                                 }|-|d                    |                    dd                    gz  }|                     |          }||d                    |          gz  }|                    |           |S )zN
        Return command to use to run code analysis on given filename
        N)z-mpylintz--output-format=textz;--msg-template={msg_id}:{symbol}:{line:3d},{column}: {msg}"z}--init-hook=import pylint_venv;                     pylint_venv.inithook('{}',                    force_venv_activation=True)\z\\rr   z--rcfile={})
PYLINT_VERr  r   replacer   r6  )rd   rr   r   r  pylintrc_paths        r3   r   zPylintWidget.get_command  s     !  L &*%E%E%G%G"%11 282::4HH2J 2J	 L ...AA$]11-@@AALH%%%r2   c                     g g g g d}d}d}|                                 D ]2}|                    |          r|t          |          d         }0t          j        d|          sFi }d}d}g d}	t          |	          D ]\  }
}|
t          |	          dz
  k    rt          |          }n|                    d	|          }|dk     r n|||         }|s n||d
k    r(t          |                    d          d                   }|||<   |dz   }||d
         |d         |d         |d         f}||d         d	z            	                    |           4d}d}|                    |          }|dk    r6|                    d|          }|dk    r||t          |          z   |         }d}|Nd}|                    ||          }|dk    r0|                    d|          }||t          |          z   |         }|||fS )zK
        Parse output and return current revious rate and results.
        )r   r   r   r   z************* Module rq   Nz^[CRWE]+([0-9]{4})?:r   )r   r   line_nbr[   rY   :r  ,r[   r   r   zYour code has been rated at z/10zprevious run: )

splitlinesr   r   rematchr  r   r   r   r6  )rd   r   rs   
txt_moduler   lineitemsidx_0idx_1	key_nameskey_idxkey_namer{   pylint_itemr  txt_ratei_rate
i_rate_endr  txt_pruni_prun
i_prun_ends                         r3   r  zPylintWidget.parse_output  s\   
 2Rr::,
%%'' "	; "	;Dz** c*oo../83T:: EEEHHHI%.y%9%9 ; ;!c)nnq000IIEE IIc511E199EUEM* Ey((tzz#q122D"&h	%uY'7y9I$Xn0EGQ#&--k::: 1X&&A::UF33JA~~fS]]2:=> 'H[[:66Fzz#[[77
!&X"6z"ABXw&&r2   )NNN)Fr   )/r*   r+   r,   rj   ENABLE_SPINNERr   r   r   r   r   r   ry   rN  ra   r   r  r   r   r   r!  r%  r2  r  r;  r=  rf  r   rj  r  ro  rM  r   r   r  rn  r^  r`  r  r  r  rP  r   rO  r  r   r  rk   rl   s   @r3   r   r     s
         N}-..HG %fS#s33 $*688 0* 0* 0* 0* 0* 0*h 
TVV, , V,\   ,  *  K K K  
; ; ;&% % % " " "  fK fK fKP ^M+>?@@@, , A@,% % %" " "
 
TVV	T#YY0 0 0 Y V0<1 1 1 
T#YY%" %" Y%"N   (! ! !9 9 9< < <	 	 	< < <"7* 7* 7* 7*r 
TVV" " V" < < <" 
TVV' ' ' V'(* * *@  >?' ?' ?' ?' ?' ?' ?'r2   r   c                     ddl m}  ddlm}  |            }d|_         | d          }t          d|          }|                                 |                                 |                    dd	           |	                                 |
                    t          
           t          j        |                                           dS )zRun pylint widget testr   )qapplication)	MagicMockr     )	test_time)r   r   i  i  r  N)spyder.utils.qthelpersr  unittest.mockr  CONF_SECTIONr   _setuprf  r  r|  r  __file__r   exitr  )r  r  plugin_mockappwidgets        r3   testr    s    333333'''''')++K'K
,
$
$
$Cx<<<F
MMOOO
LLNNN
MM#s
KKMMM
111HSYY[[r2   __main__)Mrj   r   os.pathpathr   r   r  r   r  r  qtpy.compatr   qtpy.QtCorer   r   r   r   r   qtpy.QtWidgetsr	   r
   r   r   r   spyder.api.config.decoratorsr   spyder.api.translationsr   spyder.api.widgets.main_widgetr   spyder.config.baser   r   r   spyder.config.utilsr   spyder.plugins.pylint.utilsr   2spyder.plugins.variableexplorer.widgets.texteditorr   spyder.utils.icon_managerr   spyder.utils.miscr   r   r   spyder.utils.paletter   r   spyder.widgets.comboboxesr   r   spyder.widgets.onecolumntreer    r!   __version__r  rx  r7  COLOR_ERROR_1r  COLOR_WARN_1r  COLOR_SUCCESS_1r  COLOR_TEXT_1r  r  r%   r5   r=   rA   rM   rn   r   r  r*   r1   r2   r3   <module>r     s     
			        				 



   ' ' ' ' ' '             ) ) ) ) ) ) ) ) ) ) ) ) ) ) 8 7 7 7 7 7 % % % % % % ; ; ; ; ; ; L L L L L L L L L L + + + + + + 9 9 9 9 9 9 I I I I I I ) ) ) ) ) ) : : : : : : : : 3 3 3 3 3 3 = = = = = = = == = = = = = = = L L L L L L L L
 
  **-
  ,#0                                     + + + + +? + + +by< y< y< y< y<- y< y< y<xc' c' c' c' c'# c' c' c'R  $ zDFFFFF r2   