Your IP : 216.73.216.213


Current Path : /opt/alt/python37/lib/python3.7/site-packages/prospector/__pycache__/
Upload File :
Current File : //opt/alt/python37/lib/python3.7/site-packages/prospector/__pycache__/suppression.cpython-37.pyc

B

a�\|�@s~dZddlZddlZddlZddlmZddlmZe�dej	�Z
e�dej	�Ze�d�Zdd	�Z
d
diZdd
�Zdd�ZdS)aI
Each tool has its own method of ignoring errors and warnings.
For example, pylint requires a comment of the form

    # pylint disable=<error codes>

PEP8 will not warn on lines with

    # noqa

Additionally, flake8 follows that convention for pyflakes errors,
but pyflakes itself does not.

Finally, an entire file is ignored by flake8 if this line is found
in the file:

    # flake8\: noqa       (the \ is needed to stop prospector ignoring this file :))

This module's job is to attempt to collect all of these methods into
a single coherent list of error suppression locations.
�N)�encoding)�defaultdictzflake8[:=]\s*noqaz#\s+noqaz/^Suppressed \'([a-z0-9-]+)\' \(from line \d+\)$cCsNd}t�}x:t|�D].\}}t�|�r*d}t�|�r|�|d�qW||fS)z�
    Finds all pep8/flake8 suppression messages

    :param file_contents:
        A list of file lines
    :return:
        A pair - the first is whether to ignore the whole file, the
        second is a set of (0-indexed) line numbers to ignore.
    FT�)�set�	enumerate�_FLAKE8_IGNORE_FILE�search�_PEP8_IGNORE_LINE�add)�
file_contentsZignore_whole_file�ignore_lines�line_number�line�r�G/opt/alt/python37/lib/python3.7/site-packages/prospector/suppression.py�get_noqa_suppressions"s


rz
unused-import))ZpyflakesZFL0001)ZfrostedZE101cCs�t�}tdd��}xn|D]f}|jdkr|jdkrft�|j�}|�d�}||jj	}||jj
�|�q|jdkr|�|jj	�qW||fS)NcSstt�S)N)r�listrrrr�<lambda>A�z-_parse_pylint_informational.<locals>.<lambda>�pylintzsuppressed-messagerzfile-ignored)
rr�source�code�_PYLINT_SUPPRESSED_MESSAGE�match�message�group�location�pathr�appendr
)�messagesZignore_filesZignore_messagesrrZsuppressed_codeZ	line_dictrrr�_parse_pylint_informational?s




r cCsPt�}tt�}tdd��}x�|D]�}tj�||�}yt�|��d�}Wn>tjk
r�}	zt	�
d�|	j|	j�t
�w Wdd}	~	XYnXt|�\}
}|
r�|�|�|||O<q Wt|�\}}
||O}x||
��D]p\}}xf|��D]Z\}}xP|D]H}|||�d|f�|tkr�x$t|D]}|||�|��qWq�Wq�Wq�W|||fS)z�
    Given every message which was emitted by the tools, and the
    list of files to inspect, create a list of files to ignore,
    and a map of filepath -> line-number -> codes to ignore
    cSstt�S)N)rrrrrrrYrz"get_suppressions.<locals>.<lambda>�
z{0}: {1}Nr)rr�osr�joinrZread_py_file�splitZCouldNotHandleEncoding�warnings�warn�format�cause�
ImportWarningrr
r �items�_PYLINT_EQUIVALENTS)Zrelative_filepaths�rootrZpaths_to_ignoreZlines_to_ignoreZmessages_to_ignore�filepath�abspathr�errZignore_filerZpylint_ignore_filesZpylint_ignore_messagesrr
�codesrZ
equivalentrrr�get_suppressionsQs0


$r1)�__doc__r"�rer%�
prospectorr�collectionsr�compile�
IGNORECASErr	rrr+r r1rrrr�<module>s