Your IP : 216.73.216.213


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__/spelling.cpython-37.pyc

B

A!p\�3�@sjdZddlZddlZddlZy,ddlZddlmZmZmZm	Z	m
Z
mZWn4ek
r|dZGdd�d�ZGdd�d�ZYnXddl
mZmZdd	lmZdd
lmZedk	r�e��Ze��Zdgdd
�eD�Zdd
�eD�Zd�e�ZdZndZdgZdZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�Z dd�Z!dS) z8Checker for spelling errors in comments and docstrings.
�N)�
get_tokenizer�Chunker�Filter�EmailFilter�	URLFilter�WikiWordFilterc@seZdZdd�ZdS)rcCst�dS)N)�NotImplementedError)�self�word�r�I/opt/alt/python37/lib/python3.7/site-packages/pylint/checkers/spelling.py�_skip'szFilter._skipN)�__name__�
__module__�__qualname__r
rrrrr&src@seZdZdS)rN)rrrrrrrr*sr)�
ITokenChecker�IAstroidChecker)�BaseTokenChecker)�check_messages�cCsg|]}|d�qS)rr)�.0�drrr�
<listcomp>5srcCs"g|]}d|d|djf�qS)z%s (%s)r�)�name)rrrrrr6sz, �nonez3 To make it working install python-enchant package.c@seZdZdZdd�ZdS)�WordsWithDigigtsFilterzSkips words with digits.
    cCsx|D]}|��rdSqWdS)NTF)�isdigit)r	r
�charrrrr
Cs
zWordsWithDigigtsFilter._skipN)rrr�__doc__r
rrrrr?src@seZdZdZdd�ZdS)�WordsWithUnderscoreszSSkips words with underscores.

    They are probably function parameter names.
    cCsd|kS)N�_r)r	r
rrrr
PszWordsWithUnderscores._skipN)rrrrr
rrrrr Jsr c@s"eZdZdZe�d�Zdd�ZdS)�CamelCasedWordz�Filter skipping over camelCasedWords.
    This filter skips any words matching the following regular expression:

           ^([a-z]\w+[A-Z]+\w+)

    That is, any words that are camelCasedWords.
    z^([a-z]+([\d]|[A-Z])(?:\w+)?)cCst|j�|��S)N)�bool�_pattern�match)r	r
rrrr
^szCamelCasedWord._skipN)rrrr�re�compiler$r
rrrrr"Ts
r"c@s"eZdZdZe�d�Zdd�ZdS)�SphinxDirectivesz�Filter skipping over Sphinx Directives.
    This filter skips any words matching the following regular expression:

           ^:([a-z]+):`([^`]+)(`)?

    That is, for example, :class:`BaseQuery`
    z^:([a-z]+):`([^`]+)(`)?cCst|j�|��S)N)r#r$r%)r	r
rrrr
mszSphinxDirectives._skipN)rrrrr&r'r$r
rrrrr(bs
r(c@s eZdZdZdd�Zdd�ZdS)�ForwardSlashChunkderz[
    This chunker allows splitting words like 'before/after' into 'before' and 'after'
    cCs�x�|jst��d|jkr2|j}d|_d|_|dfS|j�dd�\}}||_d|_|rp|rp|d��rp|d��s�d|_d|_|d|dfS|dfSdS)N�/rrr���)�_text�
StopIteration�_offset�split�isalpha)r	�text�pre_text�	post_textrrr�nextvs&
zForwardSlashChunkder.nextcCslx`d|jkr|jdfS|j�dd�\}}|r0|s2P|d��rJ|d��sPt��|d||_qWt��dS)Nr*rrr+� )r,r/r0r-)r	r2r3rrr�_next�s

zForwardSlashChunkder._nextN)rrrrr4r6rrrrr)qsr)c
@s�eZdZdZeefZdZdddd�Zddd	d
e	de
efd�fd
ddddd�fdddddd�fdddddd�fdddddd�ffZdd �Z
d!d"�Zd#d$�Zd%d&�Zed'�d(d)��Zed'�d*d+��Zed'�d,d-��ZeZd.d/�Zd0S)1�SpellingCheckerz)Check spelling in comments and docstringsZspelling)zEWrong spelling of a word '%s' in a comment:
%s
%s
Did you mean: '%s'?zwrong-spelling-in-commentz5Used when a word in comment is not spelled correctly.)zGWrong spelling of a word '%s' in a docstring:
%s
%s
Did you mean: '%s'?zwrong-spelling-in-docstringz7Used when a word in docstring is not spelled correctly.)z$Invalid characters %r in a docstringzinvalid-characters-in-docstringz;Used when a word in docstring cannot be checked by enchant.)ZC0401ZC0402ZC0403z
spelling-dictr�choicez<dict name>z8Spelling dictionary name. Available dictionaries: %s.%s.)�default�type�metavar�choices�helpzspelling-ignore-words�stringz<comma separated words>z9List of comma separated words that should not be checked.)r9r:r;r=zspelling-private-dict-filez<path to file>zEA path to a file that contains private dictionary; one word per line.zspelling-store-unknown-words�nZynz<y_or_n>z�Tells whether to store unknown words to indicated private dictionary in --spelling-private-dict-file option instead of raising a message.zmax-spelling-suggestions��int�Nz:Limits count of emitted suggestions for spelling mistakes.c
Cs�d|_d|_tdkrdS|jj}|s(dSdd�|jj�d�D�|_|j�ddg�|jj	rnt
j�|jj	�|j_	|jj	r�t�
||jj	�|_t|jj	d�|_nt�|�|_|jjr�t�|_t|tgtttttttgd�|_d	|_dS)
NFcSsg|]}|���qSr)�strip)r�wrrrr�sz(SpellingChecker.open.<locals>.<listcomp>�,�param�pylint�a)Zchunkers�filtersT)�initialized�private_dict_file�enchant�config�
spelling_dictZspelling_ignore_wordsr/�ignore_list�extendZspelling_private_dict_file�os�path�
expanduserZDictWithPWL�open�Dict�spelling_store_unknown_words�set�
unknown_wordsrr)rrrrr r"r(�	tokenizer)r	Z	dict_namerrrrT�s<zSpellingChecker.opencCs|jr|j��dS)N)rK�close)r	rrrrZszSpellingChecker.closec
Cs�|}|���d�r(|��dd�}d}nd}�xz|�|���D�]f\}}|��}||jks>||jkrfq>|�d�r�t|�dkr�|dd�}|dd�}y |j�|�r�w>|j�|�r�w>Wn,tj	j
k
r�|jd||fd�w>YnX|jj
�r||jk�r�|j�d	|�|j�|�q>|j�|�}	|	|jjd�=t�d
||�}
|
�rV|
jdd}n
|�|�}|�rn|d7}d|d
t|�}|j|||||d�d�|	��fd�q>WdS)N�#rTF)zu'zu"zr'zr"�zinvalid-characters-in-docstring)�line�argsz%s
z(\W|^)(%s)(\W|$)rr5�^z'{}'z' or ')rC�
startswithrY�casefoldrO�lenrN�checkrL�errors�ErrorZadd_messagerMrVrXrK�write�addZsuggestZmax_spelling_suggestionsr&�search�regs�index�format�join)
r	�msgidr]Zline_numZ
original_lineZstarts_with_commentr
r!Zlower_cased_wordZsuggestions�m�colZ	indicatorrrr�_check_spellingsR

zSpellingChecker._check_spellingcCsb|js
dSxR|D]J\}}\}}}}|tjkr|dkr@|�d�r@q|�d�rLq|�d||�qWdS)Nrz#!/z	# pylint:zwrong-spelling-in-comment)rJ�tokenize�COMMENTr`rp)r	�tokens�tok_type�tokenZ	start_rowr!rrr�process_tokensas

zSpellingChecker.process_tokenszwrong-spelling-in-docstringcCs|js
dS|�|�dS)N)rJ�_check_docstring)r	�noderrr�visit_modulepszSpellingChecker.visit_modulecCs|js
dS|�|�dS)N)rJrw)r	rxrrr�visit_classdefvszSpellingChecker.visit_classdefcCs|js
dS|�|�dS)N)rJrw)r	rxrrr�visit_functiondef|sz!SpellingChecker.visit_functiondefcCsH|j}|sdS|jd}x*t|���D]\}}|�d|||�q&WdS)z&check the node has any spelling errorsNrzwrong-spelling-in-docstring)�doc�lineno�	enumerate�
splitlinesrp)r	rxZ	docstringZ
start_line�idxr]rrrrw�s
z SpellingChecker._check_docstringN)rrrrrrZ__implements__rZmsgs�dict_choices�dicts�instr�optionsrTrZrprvrryrzr{Zvisit_asyncfunctiondefrwrrrrr7�sT1Dr7cCs|�t|��dS)z.required method to auto register this checker N)Zregister_checkerr7)Zlinterrrr�register�sr�)"rrQrqr&rLZenchant.tokenizerrrrrr�ImportErrorZpylint.interfacesrrZpylint.checkersrZpylint.checkers.utilsrZBroker�brZ
list_dictsr�r�rlr�rr r"r(r)r7r�rrrr�<module>s>$

)x