Your IP : 216.73.217.32


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

B

A!p\2�@sldZddlZddlZddlmZmZddlmZddlm	Z	m
Z
Gdd�de�ZGdd	�d	e�Zd
d�Z
dS)zHCheck source code is ascii only or has an encoding declaration (PEP 263)�N)�IRawChecker�
ITokenChecker)�BaseChecker)�
OPTION_RGX�MessagesHandlerMixInc@s,eZdZdZeZdZddiZdZdd�Z	dS)	�ByIdManagedMessagesCheckerzIchecks for messages that are enabled or disabled by id instead of symbol.�
miscellaneousZI0023)z%szuse-symbolic-message-insteadz1Used when a message is enabled or disabled by id.�c	Csht��}xR|D]J\}}}}}||jkr|r:dj||d�}ndj||d�}|jd||d�qWt��dS)zHinspect the source file to find messages activated or deactivated by id.z;Id '{ident}' is used to disable '{symbol}' message emission)�ident�symbolz:Id '{ident}' is used to enable '{symbol}' message emissionzuse-symbolic-message-instead)�line�argsN)rZget_by_id_managed_msgs�name�format�add_messageZclear_by_id_managed_msgs)	�self�moduleZmanaged_msgs�mod_nameZmsg_idZ
msg_symbol�linenoZis_disabled�txtr	r	�E/opt/alt/python37/lib/python3.7/site-packages/pylint/checkers/misc.py�process_module2s

z)ByIdManagedMessagesChecker.process_moduleN)
�__name__�
__module__�__qualname__�__doc__r�__implements__r�msgs�optionsrr	r	r	rr srcsneZdZdZeefZdZddddddifd	�Zd
ddd
dd�ffZ	�fdd�Z
dd�Zdd�Zdd�Z
�ZS)�EncodingCheckerzWchecks for:
    * warning notes in the code like FIXME, XXX
    * encoding issues.
    r)z%s�fixmez5Used when a warning note as FIXME or XXX is detected.zACannot decode using encoding "%s", unexpected byte at position %dzinvalid-encoded-datazSUsed when a source line cannot be decoded using the specified source file encoding.Z
maxversion)�r)ZW0511ZW0512�notesZcsvz<comma separated values>)ZFIXMEZXXXZTODOzAList of note tags to take in consideration, separated by a comma.)�type�metavar�default�helpcs4t���t�dd�ttj|jj��tj	�|_
dS)Nz
#\s*(%s)\b�|)�super�open�re�compile�join�map�escape�configr"�I�_fixme_pattern)r)�	__class__r	rr)ls
zEncodingChecker.openc
Cs�y
|�|�Stk
rF}z|jd|||jdfd�Wdd}~XYnRtk
r�}z4|�d�r�d|kr�||kr�|jd|d�|�d�Wdd}~XYnXdS)Nzinvalid-encoded-data�)rr
�#Zcodingzsyntax-errorz/Cannot decode using encoding "{}", bad encoding)�decode�UnicodeDecodeErrorrr
�LookupError�
startswithr)rrr�
file_encoding�exr	r	r�_check_encodingrs
&zEncodingChecker._check_encodingc	CsR|jr|j}nd}|���.}x&t|�D]\}}|�|d||�q&WWdQRXdS)z0inspect the source file to find encoding problem�ascii�N)r9�stream�	enumerater;)rr�encodingr>rrr	r	rr�s
zEncodingChecker.process_modulec	Cs|jjsdSdd�|D�}x�|D]�}|jdd���}t�|�}|r�yD|�d��dd�\}}dd�|�d�D�}t|�t|jj�@r�w Wn2t	k
r�|j
d	|�d���|jd
�w YnX|j�d|�
��}	|	r |	�d�}
|j
d|j�
��|
�
��||jd
d�q WdS)z)inspect the source to find fixme problemsNcss|]}|jtjkr|VqdS)N)r#�tokenize�COMMENT)�.0Z
token_infor	r	r�	<genexpr>�sz1EncodingChecker.process_tokens.<locals>.<genexpr>r=�=cSsg|]}|�����qSr	)�strip�upper)rCZ_valr	r	r�
<listcomp>�sz2EncodingChecker.process_tokens.<locals>.<listcomp>�,zbad-inline-option)r
rr4r r)�
col_offsetr
r)r/r"�string�lstripr�search�group�split�set�
ValueErrorrrFr1�lower�index�start)r�tokens�comments�commentZcomment_textZdisable_option_match�_�value�values�matchZnoter	r	r�process_tokens�s4



zEncodingChecker.process_tokens)rrrrrrrrrrr)r;rr\�
__classcell__r	r	)r2rrCs"rcCs |�t|��|�t|��dS)z-required method to auto register this checkerN)Zregister_checkerrr)Zlinterr	r	r�register�sr^)rrAr*Zpylint.interfacesrrZpylint.checkersrZpylint.utilsrrrrr^r	r	r	r�<module>s#p