o
    gE!                  
   @   s  d 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 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 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-dd Zd-d!d"ZG d#d$ d$eZG d%d& d&eZG d'd( d(eZG d)d* d*eZd+d, ZdS ).zvPlain text reporters:

:text: the default one grouping messages by module
:colorized: an ANSI colorized text reporter
    N)TYPE_CHECKINGOptional)utils)	IReporter)Message)BaseReporter)
TextWriter)Section) =-.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                 C   sx   g }|rt |}|D ]	}|t|  q| r/|  r(|ddg ||  n|t|   |r:td| t	 S dS )a  return ansi escape code corresponding to color and style

    :type color: str or None
    :param color:
      the color name (see `ANSI_COLORS` for available values)
      or the color number when 256 colors are available

    :type style: str or None
    :param style:
      style string (see `ANSI_COLORS` for available values). To get
      several style effects at the same time, use a coma as separator.

    :raise KeyError: if an unexistent color or style identifier is given

    :rtype: str
    :return: the built escape code
    38r   ;r
   )
r   _splitstripappendANSI_STYLESisdigitextendANSI_COLORSANSI_PREFIXjoinANSI_END)colorstyle	ansi_codestyle_attrseffect r=   S/home/ubuntu/cloudmapper/venv/lib/python3.10/site-packages/pylint/reporters/text.py_get_ansi_codeC   s   
r?   c                 C   s6   |du r
|du r
| S t ||}|r| |  t S | S )aC  colorize message by wrapping it with ansi escape codes

    :type msg: str or unicode
    :param msg: the message string to colorize

    :type color: str or None
    :param color:
      the color identifier (see `ANSI_COLORS` for available values)

    :type style: str or None
    :param style:
      style string (see `ANSI_COLORS` for available values). To get
      several style effects at the same time, use a coma as separator.

    :raise KeyError: if an unexistent color or style identifier is given

    :rtype: str or unicode
    :return: the ansi escaped string
    N)r?   
ANSI_RESET)msgr8   r9   escape_coder=   r=   r>   colorize_ansie   s   
rC   c                   @   sh   e Zd ZdZeZdZdZdZdddZ	de
d	ee
 d
dfddZdd Zded
dfddZdddZdS )TextReporterz*Reports messages and layouts in plain texttexttxtz2{path}:{line}:{column}: {msg_id}: {msg} ({symbol})Nc                 C   s    t | | t | _| j| _d S N)r   __init__set_modulesline_format	_templateselfoutputr=   r=   r>   rH      s   zTextReporter.__init__modulefilepathreturnc                 C   s   t | jjjp| j| _d S rG   )strlinterconfigmsg_templaterL   )rN   rP   rQ   r=   r=   r>   on_set_current_module   s   z"TextReporter.on_set_current_modulec                 C   s   |  || j dS )zKConvenience method to write a formatted message with class default templateN)writelnformatrL   rN   rA   r=   r=   r>   write_message   s   zTextReporter.write_messagerA   c                 C   sL   |j | jvr|j r| d|j   | j|j  n| d | | dS )z;manage message of different type and in the context of path************* Module ************* N)rP   rJ   rX   addr[   rZ   r=   r=   r>   handle_message   s   
zTextReporter.handle_messagelayoutr	   c                 C   s    t | jd t || j dS )zlaunch layouts display)fileN)printoutr   rY   )rN   r`   r=   r=   r>   _display   s   zTextReporter._displayrG   )r`   r	   rR   N)__name__
__module____qualname____doc__r   __implements__name	extensionrK   rH   rS   r   rW   r[   r   r_   rd   r=   r=   r=   r>   rD      s    

rD   c                   @   s"   e Zd ZdZdZdZdddZd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}Nc                 C   s*   t | j d| j t t| | d S )NzC output format is deprecated. This is equivalent to --msg-template=)warningswarnrj   rK   DeprecationWarningrD   rH   rM   r=   r=   r>   rH      s
   zParseableTextReporter.__init__rG   )re   rf   rg   rh   rj   rK   rH   r=   r=   r=   r>   rl      s
    rl   c                   @   s   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)re   rf   rg   rh   rj   rK   r=   r=   r=   r>   rq      s    rq   c                   @   sL   e Zd ZdZdZddddddd	d
ZdddZdd ZdeddfddZ	dS )ColorizedTextReporterz.Simple TextReporter that colorizes text output	colorized)r'   N)Nr   )r*   zbold, italic)r*   N)r&   r   )r&   zbold, underline)r(   r   )ICRWEFSNc                 C   s`   t | | |pttj| _ddg}tjd|vr,t	j
dkr.dd l}|| j| _d S d S d S )Nzxterm-16colorzxterm-256colorTERMwin32r   )rD   rH   dictrs   COLOR_MAPPINGcolor_mappingosenvirongetsysplatformcoloramaAnsiToWin32rc   )rN   rO   r   
ansi_termsr   r=   r=   r>   rH      s   
zColorizedTextReporter.__init__c                 C   s&   z| j |d  W S  ty   Y dS w )zgReturns the tuple color, style associated with msg_id as defined
        in self.color_mapping
        r   NN)r   KeyError)rN   msg_idr=   r=   r>   _get_decoration   s
   z%ColorizedTextReporter._get_decorationrA   rR   c                    s   j | jvr1| d\ j rtdj   }n
tdj   }| | | jj  | j\ jdi  fdddD |  dS )	z_manage message of different types, and colorize output
        using ansi escape codes
        r{   r\   r]   c                    s    i | ]}|t t| qS r=   )rC   getattr).0attrr8   rA   r9   r=   r>   
<dictcomp>   s    z8ColorizedTextReporter.handle_message.<locals>.<dictcomp>)rA   symbolcategoryrv   Nr=   )	rP   rJ   r   rC   rX   r^   rv   _replacer[   )rN   rA   modsepr=   r   r>   r_      s    
z$ColorizedTextReporter.handle_messager   )
re   rf   rg   rh   rj   r   rH   r   r   r_   r=   r=   r=   r>   rs      s    

	rs   c                 C   s,   |  t |  t |  t |  t dS )z.Register the reporter classes with the linter.N)register_reporterrD   rl   rq   rs   )rT   r=   r=   r>   register   s   


r   r   ) rh   r   r   rn   typingr   r   pylintr   pylint.interfacesr   pylint.messager   pylint.reportersr   %pylint.reporters.ureports.text_writerr   pylint.reporters.ureports.nodesr	   TITLE_UNDERLINESr5   r7   r@   r1   r4   r?   rC   rD   rl   rq   rs   r   r=   r=   r=   r>   <module>   sR   


"$;