
    c*              
      D   d 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mZm	Z	 ddl
mZmZ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 erdd
lmZ ddlmZ  G d de          Zeeef         Z g dZ!dZ"dZ#dZ$ddddddddZ%dddddddd d!d"	Z&d#  e	e          D             Z'	 dEd'Z(e	 dFdGd+            Z)e	 	 dHd(d,dId0            Z)	 	 dJdKd4Z)dLd6Z* G d7 d8e          Z+ G d9 d:e+          Z, G d; d<e+          Z- G d= d>e-          Z. G d? d@e+          Z/dMdDZ0dS )NzwPlain text reporters:.

:text: the default one grouping messages by module
:colorized: an ANSI colorized text reporter
    )annotationsN)asdictfields)TYPE_CHECKINGDict
NamedTupleOptionalTextIOcastoverload)Message)BaseReporter)
TextWriter)_splitstrip)PyLinter)Sectionc                  .    e Zd ZU dZded<   	 dZded<   dS )MessageStylezStyling of a message.
str | Nonecolor ztuple[str, ...]styleN)__name__
__module____qualname____doc____annotations__r   r       5lib/python3.11/site-packages/pylint/reporters/text.pyr   r      s<           EJJr   r   ) =-.z[mz[0m0134579)resetbolditalic	underlineblinkinversestrike3031323334353637)	r,   blackredgreenyellowbluemagentacyanwhitec                    h | ]	}|j         
S r   )name).0is     r   	<setcomp>rG   E   s    222Q!&222r   	msg_stylereturnstrc                d   d | j         D             }| j        rp| j                                        r2|                    ddg           |                    | j                   n%|                    t
          | j                            |r%t          d                    |          z   t          z   S dS )zReturn ANSI escape code corresponding to color and style.

    :param msg_style: the message style

    :raise KeyError: if a nonexistent color or style identifier is given

    :return: the built escape code
    c                (    g | ]}t           |         S r   )ANSI_STYLES)rE   effects     r   
<listcomp>z"_get_ansi_code.<locals>.<listcomp>R   s    CCCV$CCCr   38r)   ;r    )	r   r   isdigitextendappendANSI_COLORSANSI_PREFIXjoinANSI_END)rH   	ansi_codes     r   _get_ansi_coderZ   I   s     DC9?CCCI ;?""$$ 	;dC[)))Y_----[9::: <SXXi0008;;2r   .msgMessageStyle | Nonec                    d S Nr   )r[   rH   s     r   colorize_ansir_   ^   s	    
 Cr   )r   r   r   r   c                   d S r^   r   )r[   rH   r   r   s       r   r_   r_   f   s	     Cr   r    MessageStyle | str | Nonekwargsc                l   t          |t                    s_t          j        dt          d           |                    d          }t          t          |                    }t          |p||          }|j        t          |j
                  dk    r| S t          |          }|r| |  t           S | S )a  colorize message by wrapping it with ANSI escape codes

    :param msg: the message string to colorize

    :param msg_style: the message style
        or color (for backwards compatibility): the color of the message style

    :param style: the message's style elements, this will be deprecated

    :param \**kwargs: used to accept `color` parameter while it is being deprecated

    :return: the ANSI escaped string
    zeIn pylint 3.0, the colorize_ansi function of Text reporters will only accept a MessageStyle parameter   
stacklevelr   Nr   )
isinstancer   warningswarnDeprecationWarninggettupler   r   lenr   rZ   
ANSI_RESET)r[   rH   r   rb   r   style_attrsescape_codes          r   r_   r_   r   s    ( i.. Bs	
 	
 	
 	

 

7##K..// !3)[AA	 3y#7#71#< 
 ++K 10s0J000Jr   r   c                    d| j          S )Nz************* Module )module)r[   s    r   make_headerrs      s    /3:///r   c                  R     e Zd ZdZdZdZdZdd fd
ZddZddZ	ddZ
ddZ xZS )TextReporterz+Reports messages and layouts in plain text.texttxtz2{path}:{line}:{column}: {msg_id}: {msg} ({symbol})NoutputTextIO | NonerI   Nonec                    t                                          |           t                      | _        | j        | _        | j        | _        d S r^   )super__init__set_modulesline_format	_template_fixed_templateselfrx   	__class__s     r   r}   zTextReporter.__init__   sA       "%%%)#/QQr   rr   rJ   filepathr   c                X   t          | j        j        j        p| j                  }|| j        k    rdS || _        t          j        d|          }|D ]Q}|d         t          vr@t          j	        d|d          d           t          j
        d|d         z   dz   d|          }R|| _        dS )	zHSet the format template to be used and check for unrecognized arguments.Nz\{(\w+?)(:.*)?\}r   zDon't recognize the argument 'zW' in the --msg-template. Are you sure it is supported on the current version of pylint?z\{z	(:.*?)?\}r    )rJ   linterconfigmsg_templater   refindallMESSAGE_FIELDSrh   ri   subr   )r   rr   r   template	argumentsarguments         r   on_set_current_modulez"TextReporter.on_set_current_module   s    t{)6H$.II t~% 	F " J2H==	! 	T 	TH{.0 TUXa[ U U U   6%(1+"5"Db(SS'r   r[   r   c                    t          |          }dD ]}||         pd||<   |                      | j        j        di |           dS )z]Convenience method to write a formatted message with class default
        template.
        )end_line
end_columnr    Nr   )r   writelnr   format)r   r[   	self_dictkeys       r   write_messagezTextReporter.write_message   sa     3KK	- 	2 	2C&s^1rIcNN0T)0==9==>>>>>r   c                    |j         | j        vrA|                     t          |                     | j                            |j                    |                     |           dS )z<Manage message of different type and in the context of path.N)rr   r   r   rs   addr   r   r[   s     r   handle_messagezTextReporter.handle_message   s_    :T]* 	*LLS))***Mcj)))3r   layoutr   c                ~    t          | j                   t                                          || j                   dS )zLaunch layouts display.)fileN)printoutr   r   )r   r   s     r   _displayzTextReporter._display   s7    48FDH-----r   r^   rx   ry   rI   rz   )rr   rJ   r   r   rI   rz   r[   r   rI   rz   )r   r   rI   rz   )r   r   r   r   rD   	extensionr   r}   r   r   r   r   __classcell__r   s   @r   ru   ru      s        55DIFKR R R R R R R( ( ( (,? ? ? ?       . . . . . . . .r   ru   c                      e Zd ZdZdZd	dZdS )
NoHeaderReporterzCReports messages and layouts in plain text without a module header.z	no-headerr[   r   rI   rz   c                    |j         | j        vr| j                            |j                    |                     |           dS )z'Write message(s) without module header.N)rr   r   r   r   r   s     r   r   zNoHeaderReporter.handle_message   sE    :T]* 	*Mcj)))3r   Nr   )r   r   r   r   rD   r   r   r   r   r   r      s3        MMD           r   r   c                  .     e Zd ZdZdZdZd
d fd	Z xZS )ParseableTextReporterzA reporter very similar to TextReporter, but display messages in a form
    recognized by most text editors :

    <filename>:<linenum>:<msg>
    	parseablez0{path}:{line}: [{msg_id}({symbol}), {obj}] {msg}Nrx   ry   rI   rz   c                    t          j        | j         d| j         t          d           t                                          |           d S )NzC output format is deprecated. This is equivalent to --msg-template=rd   re   )rh   ri   rD   r   rj   r|   r}   r   s     r   r}   zParseableTextReporter.__init__   sY    yoo]a]moo	
 	
 	
 	

 	     r   r^   r   )r   r   r   r   rD   r   r}   r   r   s   @r   r   r      sX          DDK! ! ! ! ! ! ! ! ! ! !r   r   c                      e Zd ZdZdZdZdS )VSTextReporterzVisual studio text reporter.msvsz/{path}({line}): [{msg_id}({symbol}){obj}] {msg}N)r   r   r   r   rD   r   r   r   r   r   r      s        &&DCKKKr   r   c            
           e Zd ZU dZdZ ed           edd           edd           ed           edd           edd	           ed
d          dZded<   	 	 dd fdZddZ	d dZ
 xZS )!ColorizedTextReporterz/Simple TextReporter that colorizes text output.	colorizedr=   N)r-   r@   )r-   r.   r<   )r-   r/   r>   )r1   )ICRWEFSColorMappingDictCOLOR_MAPPINGrx   ry   color_mapping;ColorMappingDict | dict[str, tuple[str | None, str]] | NonerI   rz   c                   t                                          |           |rt          t          |                                          d         t
                    sxt          j        dt          d           i }|	                                D ]B\  }}|d         }t          t          |d                             }t          ||          ||<   C|}n t          t          t                   |          }|pt          j        | _        ddg}t$          j                            d          |vr5t*          j        d	k    r'dd l}	|	                    | j                  | _        d S d S d S )
Nr   zeIn pylint 3.0, the ColorizedTextReporter will only accept ColorMappingDict as color_mapping parameterrd   re      zxterm-16colorzxterm-256colorTERMwin32)r|   r}   rg   listvaluesr   rh   ri   rj   itemsrl   r   r   r	   r   r   r   r   osenvironrk   sysplatformcoloramaAnsiToWin32r   )r   rx   r   temp_color_mappingr   valuer   ro   
ansi_termsr   r   s             r   r}   zColorizedTextReporter.__init__  sw    	    	L%%''((+\"
 "
 	L Mw"   
 46+1133 K K
Ua#Ka$9$9::*6uk*J*J"3''.MM *:!;]KKM*Q.C.Q%'78
:>>&!!3 	:|w& :#//99	: 	:: :r   msg_idrJ   r   c                `    | j                             |d                   pt          d          S )z;Returns the message style as defined in self.color_mapping.r   N)r   rk   r   )r   r   s     r   _get_decorationz%ColorizedTextReporter._get_decoration.  s*    !%%fQi00FL4F4FFr   r[   r   c                   |j         | j        vrf|                     d          }t          t	          |          |          }|                     |           | j                            |j                    |                     |j                  }t          |j        |          |_        t          |j	        |          |_	        t          |j
        |          |_
        t          |j        |          |_        |                     |           dS )z`Manage message of different types, and colorize output
        using ANSI escape codes.
        r   N)rr   r   r   r_   rs   r   r   r   r[   symbolcategoryr   )r   r[   rH   modseps       r   r   z$ColorizedTextReporter.handle_message2  s     :T]* 	*,,S11I";s#3#3Y??FLL   Mcj)))((//	33"3:y99
$S\9==ceY//3r   )NN)rx   ry   r   r   rI   rz   )r   rJ   rI   r   r   )r   r   r   r   rD   r   r   r   r}   r   r   r   r   s   @r   r   r      s        99D\'""\$	**\)%788\)$$\%++\%!677\(L11' 'M     !%  :  :  :  :  :  :  :DG G G G               r   r   r   r   rz   c                
   |                      t                     |                      t                     |                      t                     |                      t                     |                      t
                     d S r^   )register_reporterru   r   r   r   r   )r   s    r   registerr   D  so    
\***
-...
2333
^,,,
233333r   )rH   r   rI   rJ   ).)r[   rJ   rH   r\   rI   rJ   )..)
r[   rJ   rH   r   r   rJ   r   r   rI   rJ   )Nr    )
r[   rJ   rH   ra   r   rJ   rb   r   rI   rJ   )r[   r   rI   rJ   )r   r   rI   rz   )1r   
__future__r   r   r   r   rh   dataclassesr   r   typingr   r   r   r	   r
   r   r   pylint.messager   pylint.reportersr   %pylint.reporters.ureports.text_writerr   pylint.utilsr   pylint.lintr   pylint.reporters.ureports.nodesr   r   rJ   r   TITLE_UNDERLINESrV   rX   rn   rM   rU   r   rZ   r_   rs   ru   r   r   r   r   r   r   r   r   <module>r      s  
  # " " " " " 				 				 



  & & & & & & & & T T T T T T T T T T T T T T T T T T " " " " " " ) ) ) ) ) ) < < < < < < $ $ $ $ $ $ 8$$$$$$777777K K K K K: K K K \)* &&& 
  
 
 32&&//222 &   * 
 &)    
 
  
      
 ,0$ $ $ $ $N0 0 0 08. 8. 8. 8. 8.< 8. 8. 8.v	  	  	  	  	 | 	  	  	 ! ! ! ! !L ! ! !&D D D D D* D D DC  C  C  C  C L C  C  C L4 4 4 4 4 4r   