o
    b
                  
   @   s   d Z ddlmZ ddlZddlZddlZddlmZ ddlm	Z	 ddl
mZ 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
    )print_functionN)	IReporter)BaseReporter)utils)
TextWriter) =-.z[mz[0m0134579)resetbolditalic	underlineblinkinversestrikeZ30Z31Z32Z33Z34Z35Z36Z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   Z_splitstripappendANSI_STYLESisdigitextendANSI_COLORSANSI_PREFIXjoinANSI_END)colorstyleZ	ansi_codeZstyle_attrsZeffect r.   T/var/www/secure340b-portal/env/lib/python3.10/site-packages/pylint/reporters/text.py_get_ansi_code<   s   
r0   c                 C   s4   |du r
|du r
| S t ||}|rd|| tf 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
    Nz%s%s%s)r0   
ANSI_RESET)msgr,   r-   Zescape_coder.   r.   r/   colorize_ansi^   s   
r3   c                   @   sJ   e Zd ZdZeZdZdZdZdddZ	dd	 Z
d
d Zdd Z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 | _d | _d S N)r   __init__set_modules	_templateselfoutputr.   r.   r/   r8      s   
zTextReporter.__init__c                 C   s   t | jjjp| j| _d S r7   )strlinterconfigZmsg_templateline_formatr;   )r=   modulefilepathr.   r.   r/   on_set_current_module   s   z"TextReporter.on_set_current_modulec                 C   s   |  || j dS )zJConvenience method to write a formated message with class default templateN)writelnformatr;   r=   r2   r.   r.   r/   write_message   s   zTextReporter.write_messagec                 C   sJ   |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 %sz************* N)rC   r:   rF   addrI   rH   r.   r.   r/   handle_message   s   
zTextReporter.handle_messagec                 C   s    t | jd t || j dS )zlaunch layouts display)fileN)printoutr   rG   )r=   Zlayoutr.   r.   r/   _display   s   zTextReporter._displayr7   )__name__
__module____qualname____doc__r   Z__implements__name	extensionrB   r8   rE   rI   rL   rP   r.   r.   r.   r/   r4   |   s    

r4   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>
    Z	parseablez0{path}:{line}: [{msg_id}({symbol}), {obj}] {msg}Nc                 C   s(   t d| j| jf t t| | d S )NzG%s output format is deprecated. This is equivalent to --msg-template=%s)warningswarnrU   rB   DeprecationWarningr4   r8   r<   r.   r.   r/   r8      s   
zParseableTextReporter.__init__r7   )rQ   rR   rS   rT   rU   rB   r8   r.   r.   r.   r/   rW      s
    rW   c                   @   s   e Zd ZdZdZdZdS )VSTextReporterzVisual studio text reporterZmsvsz/{path}({line}): [{msg_id}({symbol}){obj}] {msg}N)rQ   rR   rS   rT   rU   rB   r.   r.   r.   r/   r[      s    r[   c                   @   sB   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d ZdS )ColorizedTextReporterz.Simple TextReporter that colorizes text outputZ	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   )r4   r8   dictr\   COLOR_MAPPINGcolor_mappingosenvirongetsysplatformcoloramaAnsiToWin32rO   )r=   r>   rh   Z
ansi_termsrn   r.   r.   r/   r8      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)rh   KeyError)r=   Zmsg_idr.   r.   r/   _get_decoration   s
   z%ColorizedTextReporter._get_decorationc                    s   j | jvr/| 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
        rc   rJ   z************* %sc                    s    i | ]}|t t| qS r.   )r3   getattr).0attrr,   r2   r-   r.   r/   
<dictcomp>   s    z8ColorizedTextReporter.handle_message.<locals>.<dictcomp>)r2   symbolcategoryr^   Nr.   )	rC   r:   rr   r3   rF   rK   r^   _replacerI   )r=   r2   Zmodsepr.   rv   r/   rL      s    
z$ColorizedTextReporter.handle_messagerp   )	rQ   rR   rS   rT   rU   rg   r8   rr   rL   r.   r.   r.   r/   r\      s    

	r\   c                 C   s,   |  t |  t |  t |  t dS )z.Register the reporter classes with the linter.N)Zregister_reporterr4   rW   r[   r\   )r@   r.   r.   r/   register   s   


r{   rp   )rT   
__future__r   ri   rX   rl   Zpylint.interfacesr   Zpylint.reportersr   Zpylintr   Z%pylint.reporters.ureports.text_writerr   ZTITLE_UNDERLINESr)   r+   r1   r%   r(   r0   r3   r4   rW   r[   r\   r{   r.   r.   r.   r/   <module>   sL   


"$;