ok

Mini Shell

Direktori : /opt/cloudlinux/venv/lib64/python3.11/site-packages/flake8/__pycache__/
Upload File :
Current File : //opt/cloudlinux/venv/lib64/python3.11/site-packages/flake8/__pycache__/processor.cpython-311.pyc

�

�܋f/@��,�dZddlZddlZddlZddlZddlZddlmZddlmZddlm	Z	ddlm
Z
ddlmZddlmZdd	l
mZdd
l
mZddlmZeje��Zeejejg��Zeejejejejg��Ze
eeeeeffZee
ee
eefZGd�d
��Zdej de!fd�Z"dej de!fd�Z#dej de!fd�Z$dededefd�Z%dedefd�Z&dedefd�Z'dS)zFModule containing our file processor that tokenizes a file for checks.�N)�Any)�Dict)�	Generator)�List)�Optional)�Tuple)�defaults)�utils)�LoadedPluginc	�|�eZdZdZdZ	d(dedejdee	eddfd�Z
ede	ej
fd	���Zejd
ededfd���Zd)d
�Zd)d�Zd)d�Zdeddfd�Zdeddfd�Zd)d�Zdefd�Zdejfd�Z de!eeeffd�Z"dej
deeddffd�Z#de$ee%fde$ee&fde$ee&ffd�Z'deej
ddffd�Z(dedede$eeffd �Z)d
edeefd!�Z*defd"�Z+de	efd#�Z,de	efd$�Z-de	efd%�Z.de%fd&�Z/d)d'�Z0dS)*�
FileProcessora>Processes a file and holdes state.

    This processes a file by generating tokens, logical and physical lines,
    and AST trees. This also provides a way of passing state about the file
    to checks expecting that state. Any public attribute on this object can
    be requested by a plugin. The known public attributes are:

    - :attr:`blank_before`
    - :attr:`blank_lines`
    - :attr:`checker_state`
    - :attr:`indent_char`
    - :attr:`indent_level`
    - :attr:`line_number`
    - :attr:`logical_line`
    - :attr:`max_line_length`
    - :attr:`max_doc_length`
    - :attr:`multiline`
    - :attr:`noqa`
    - :attr:`previous_indent_level`
    - :attr:`previous_logical`
    - :attr:`previous_unindented_logical_line`
    - :attr:`tokens`
    - :attr:`file_tokens`
    - :attr:`total_lines`
    - :attr:`verbose`
    FN�filename�options�lines�returnc��||_||_|�|n|���|_|���d|_d|_i|_i|_|j	|_	d|_
d|_|j|_d|_
d|_|j|_|j|_d|_d|_d|_d|_g|_t-|j��|_|j|_ddi|_d|_d|_dS)z]Initialice our file processor.

        :param filename: Name of the file to process
        Nr�F�
logical lines)rr�
read_linesr�
strip_utf_bom�blank_before�blank_lines�_checker_states�
checker_state�hang_closing�indent_char�indent_level�indent_size�line_number�logical_line�max_line_length�max_doc_length�	multiline�previous_indent_level�previous_logical� previous_unindented_logical_line�tokens�len�total_lines�verbose�
statistics�_file_tokens�_noqa_line_mapping)�selfrrrs    �a/builddir/build/BUILD/cloudlinux-venv-1.0.6/venv/lib/python3.11/site-packages/flake8/processor.py�__init__zFileProcessor.__init__<s
����� ��
�#�/�U�U�T�_�_�5F�5F��
�������������:<���-/���#�0���*.������"�.���������&�6���%�4������%&��"� "���02��-�02����t�z�?�?�������*�A�.���@D���<@�����c���|j�=t|j���tt	j�fd�����|_|jS)z-Return the complete set of tokens for a file.Nc�"��t���S�N)�next)�	line_iters�r/�<lambda>z+FileProcessor.file_tokens.<locals>.<lambda>~s
����i���r1)r,�iterr�list�tokenize�generate_tokens)r.r6s @r/�file_tokenszFileProcessor.file_tokensxsR�����$��T�Z�(�(�I� $��(�)@�)@�)@�)@�A�A�!�!�D��� � r1r)NNNc#�<K�||_d|_dV�d|_dS)z2Context-manager to toggle the multiline attribute.TNF)rr#)r.rs  r/�inside_multilinezFileProcessor.inside_multiline�s+����
'������
��������r1c��d|_dS)z)Reset the blank_before attribute to zero.rN)r�r.s r/�reset_blank_beforez FileProcessor.reset_blank_before�s������r1c��|jd=dS)z-Delete the first token in the list of tokens.rN)r'r@s r/�delete_first_tokenz FileProcessor.delete_first_token�s���K��N�N�Nr1c�&�|xjdz
c_dS)z&Note that we visited a new blank line.�N)rr@s r/�visited_new_blank_linez$FileProcessor.visited_new_blank_line�s�����A�����r1�mappingc��|dd\}}|j|dz
}t|d|���|_|j|jkr|j|_dSdS)z:Update the indent level based on the logical line mapping.rrEN)r�
expand_indentrrr)r.rG�	start_row�	start_col�
start_lines     r/�update_statezFileProcessor.update_state�sg��!(���A����I��Z�	�A�
�.�
�)�*�Z�i�Z�*@�A�A�����t�/�/�/� $� 0�D����0�/r1�pluginc�f�d|jvr'|j�|ji��|_dSdS)z2Update the checker_state attribute for the plugin.rN)�
parametersr�
setdefault�
entry_namer)r.rNs  r/�update_checker_state_forz&FileProcessor.update_checker_state_for�sA���f�/�/�/�!%�!5�!@�!@��!�2�"�"�D����0�/r1c��|jr+|j|_|j|_|js|j|_d|_g|_dS)zoRecord the previous logical line.

        This also resets the tokens list and the blank_lines count.
        rN)r rr$r%r&rr'r@s r/�next_logical_linezFileProcessor.next_logical_line�sP��
��	J�)-�):�D�&�$(�$5�D�!��$�
J�8<�8I��5��������r1c��g}g}g}d}dx}}|jD]�\}}}	}
}|tvr�|sd|	fg}|tjkr|�|���?|tjkrt
|��}|rO|	\}}
||kr1|dz
}|dz
}|j||}|dks|dvr	|dvrd|��}n||
kr
|||
�|z}|�|��|t|��z
}|�||
f��|
\}}��|||fS)z4Build the mapping, comments, and logical line lists.rNrE�,z{[(�}])� )	r'�SKIP_TOKENSr:�COMMENT�append�STRING�
mutate_stringrr()r.�logical�commentsrG�length�previous_row�previous_column�
token_type�text�start�end�linerJ�start_column�	row_index�column_index�
previous_texts                 r/�build_logical_line_tokensz'FileProcessor.build_logical_line_tokens�sy������#%����)-�-���26�+�	2�	2�.�J��e�S�$��[�(�(���
'��u�:�,���X�-�-�-�����%�%�%���X�_�,�,�$�T�*�*���
E�,1�)��L��9�,�,� ,�q� 0�I�#2�Q�#6�L�$(�J�y�$9�,�$G�M�$��+�+�%�U�2�2�t�5�7H�7H�)�4�z�z���$��4�4���� <�=��D�D��N�N�4� � � ��c�$�i�i��F��N�N�F�C�=�)�)�)�.1�+�\�?�?���'�)�)r1c�Z�tjd�|j����S)z5Build an abstract syntax tree from the list of lines.r)�ast�parse�joinrr@s r/�	build_astzFileProcessor.build_ast�s ���y������,�,�-�-�-r1c���|���\}}}d�|��}d�|��|_|jdxxdz
cc<||j|fS)z2Build a logical line from the current tokens list.rrrE)rmrqr r+)r.r`r_�mapping_list�joined_commentss     r/�build_logical_linez FileProcessor.build_logical_line�sm��*.�*H�*H�*J�*J�'��'�<��'�'�(�+�+���G�G�G�,�,������(�(�(�A�-�(�(�(��� 1�<�?�?r1�tokenc#�K�t|jd|jd��D]$}|j|dz
V�|xjdz
c_�%dS)z|Split a physical line's line based on new-lines.

        This also auto-increments the line number for the caller.
        rrEN)�rangerfrgrr)r.rw�line_nos   r/�
split_linezFileProcessor.split_line�se�����U�[��^�U�Y�q�\�:�:�	"�	"�G��*�W�q�[�)�)�)�)�����!����	"�	"r1rP�	argumentsc���i}|���D]L\}}||vr�
	t||��||<�#t$r!|r�t�d|��Y�IwxYw|S)z8Generate the keyword arguments for a list of parameters.zPPlugin requested optional parameter "%s" but this is not an available parameter.)�items�getattr�AttributeError�LOG�warning)r.rPr|�ret�param�requireds      r/�keyword_arguments_forz#FileProcessor.keyword_arguments_for�s�����)�/�/�1�1�
	�
	�O�E�8��	�!�!��

�$�T�5�1�1��E�
�
��!�
�
�
�����K�K�B�������	
�����
s�6�(A!� A!c#�K�tj|j��D]:}|dd|jkrdS|j�|��|V��;dS)z'Tokenize the file and yield the tokens.�rN)r:r;�	next_liner)r'r\)r.rws  r/r;zFileProcessor.generate_tokenssj�����-�d�n�=�=�	�	�E��Q�x��{�T�-�-�-�����K���u�%�%�%��K�K�K�K�		�	r1�min_line�max_linec��t||dz��}d�|j|dz
|���}t�||��S)NrEr)ryrqr�dict�fromkeys)r.r�r��
line_range�joineds     r/�_noqa_line_rangezFileProcessor._noqa_line_rangesJ���8�X��\�2�2�
������H�q�L�8�$;�<�=�=���}�}�Z��0�0�0r1c�~�|j��	|j}i}t|j��dz}d}|D]�\}}\}}\}	}}|tjkrn}t
||��}t||	��}|tjtj	fvrB|�
|�||����t|j��dz}d}��|dkr)|�
|�||����||_n##tjtf$r
i|_YnwxYw|j�|��S)z7Retrieve the line which will be used to determine noqa.Nr����)r-r<r(rr:�	ENDMARKER�min�max�NL�NEWLINE�updater��
TokenError�SyntaxError�get)
r.rr<r�r�r��tp�_�s_line�e_lines
          r/�
noqa_line_forzFileProcessor.noqa_line_fors_���"�*�
.�"�.�����t�z�?�?�Q�.����:E�&�&�6�B��;�F�A����Q��X�/�/�/���"�8�V�4�4�H�"�8�V�4�4�H��h�k�8�+;�<�<�<��
�
�4�#8�#8��8�#L�#L�M�M�M�#&�t�z�?�?�Q�#6��#%���
�r�>�>��J�J�t�4�4�X�x�H�H�I�I�I�*-��'�'��9�'��5�
-�
-�
-�+-��'�'�'�
-����B�&�*�*�;�7�7�7s�D�D"�!D"c���|j|jkrdS|j|j}|xjdz
c_|j�#|dd�tjvr
|d|_|S)z Get the next line from the list.rrENr)rr)rrr	�
WHITESPACE)r.rhs  r/r�zFileProcessor.next_line=sj����t�/�/�/��2��z�$�*�+�����A������#��R�a�R��H�4G�(G�(G�#�A�w�D���r1c��|j�|jdkr(|jjpd|_|���}n|���}|S)z%Read the lines for this file checker.N�-�stdin)rr�stdin_display_name�read_lines_from_stdin�read_lines_from_filename)r.rs  r/rzFileProcessor.read_linesGsP���=� �D�M�S�$8�$8� �L�;�F�w�D�M��.�.�0�0�E�E��1�1�3�3�E��r1c�J�	tj|j��5}|���cddd��S#1swxYwYdS#tt
f$rHt|jd���5}|���cddd��cYS#1swxYwYYdSwxYw)zRead the lines for a file.Nzlatin-1)�encoding)r:�openr�	readlinesr��UnicodeError)r.�fds  r/r�z&FileProcessor.read_lines_from_filenamePs7��	&���t�}�-�-�
&���|�|�~�~�
&�
&�
&�
&�
&�
&�
&�
&�
&�
&�
&�
&����
&�
&�
&�
&�
&�
&���\�*�	&�	&�	&��d�m�i�8�8�8�
&�B��|�|�~�~�
&�
&�
&�
&�
&�
&�
&�
&�
&�
&�
&�
&�
&�
&����
&�
&�
&�
&�
&�
&�
&�	&���sU�A	�<�A	�A�A	�A�A	�	'B"�0B�
B"�B	�B"�B	�B"�!B"c�(�tj��S)z Read the lines from standard in.)r
�stdin_get_linesr@s r/r�z#FileProcessor.read_lines_from_stdin[s���$�&�&�&r1c���|jjs td�|jD����rdStd�|jD����rt�d��dSdS)z�Check if ``flake8: noqa`` is in the file to be ignored.

        :returns:
            True if a line matches :attr:`defaults.NOQA_FILE`,
            otherwise False
        c3�TK�|]#}tj�|��V��$dSr4)r	�	NOQA_FILE�match��.0rhs  r/�	<genexpr>z3FileProcessor.should_ignore_file.<locals>.<genexpr>fsD����1
�1
�/3�H��$�$�T�*�*�1
�1
�1
�1
�1
�1
r1Tc3�TK�|]#}tj�|��V��$dSr4)r	r��searchr�s  r/r�z3FileProcessor.should_ignore_file.<locals>.<genexpr>js3����H�H�T��#�*�*�4�0�0�H�H�H�H�H�Hr1z[Detected `flake8: noqa` on line with code. To ignore an error on a line use `noqa` instead.F)r�disable_noqa�anyrr�r�r@s r/�should_ignore_filez FileProcessor.should_ignore_file_s����|�(�	�S�1
�1
�7;�z�1
�1
�1
�.
�.
�	��4�
�H�H�T�Z�H�H�H�
H�
H�	��K�K�6�
�
�
��5��5r1c��|jsdSt|jdd��}|dvrdS|dkr|jddd�|jd<dS|jddd�dkr|jddd�|jd<dSdS)z-Strip the UTF bom from the lines of the file.Nr)���r�rE�u)r�ord)r.�
first_bytes  r/rzFileProcessor.strip_utf_bomss����z�	��F����A��q�)�*�*�
��^�+�+��F����� �J�q�M�!�"�"�-�D�J�q�M�M�M�
�Z��]�2�A�2�
�.�
0�
0� �J�q�M�!�"�"�-�D�J�q�M�M�M�1�
0r1r4)rN)1�__name__�
__module__�__qualname__�__doc__�noqa�str�argparse�	Namespacerrr0�propertyr:�	TokenInfor<�
contextlib�contextmanager�intrr>rArCrF�_LogicalMappingrMrrSrU�_Logicalrmro�ASTrrrrvr{r�boolrr�r;r�r�r�rr�r�r�r�r1r/r
r
s���������8�D�&*�	:A�:A��:A��#�:A���S�	�"�	:A�

�:A�:A�:A�:A�x�!�T�(�"4�5�!�!�!��X�!������	�#�	$�������������������1�O�1��1�1�1�1��|�����������!*�8�!*�!*�!*�!*�F.�3�7�.�.�.�.�@�E�#�s�O�*C�$D�@�@�@�@�"��'�"�	�3��d�?�	#�"�"�"�"����d��O����S��>��
�c�3�h��	����.��8�+=�t�T�+I�!J�����1��1��1��S�#�X��1�1�1�1�
&8��&8��#��&8�&8�&8�&8�P�3������D��I�����	&�$�s�)�	&�	&�	&�	&�'�t�C�y�'�'�'�'��D�����(.�.�.�.�.�.r1r
rwrc��|dtvp1|d|ddd����dkS)z+Check if the token is an end-of-line token.r�r�rENz\
)r��lstrip�rws r/�is_eol_tokenr��s<����8�w��L�%��(�5��8�A�;�=�=�"9�"@�"@�"B�"B�f�"L�Lr1c�B�|dtjko	d|dvS)z$Check if this is a multiline string.r�
rE)r:r]r�s r/�is_multiline_stringr��s!����8�x��&�;�4�5��8�+;�;r1c� �|dtvS)z0Check if the token type is a newline token type.r)r�r�s r/�token_is_newliner��s����8�w��r1�current_parentheses_count�
token_textc�*�|dvr|dzS|dvr|dz
S|S)z Count the number of parentheses.z([{rErXr�)r�r�s  r/�count_parenthesesr��s4���U���(�1�,�,�	�u�	�	�(�1�,�,�$�$r1rhc�F�t|�d����S)z�Return the amount of indentation.

    Tabs are expanded to the next multiple of 8.

    >>> expand_indent('    ')
    4
    >>> expand_indent('\t')
    8
    >>> expand_indent('       \t')
    8
    >>> expand_indent('        \t')
    16
    �)r(�
expandtabs)rhs r/rIrI�s���t���q�!�!�"�"�"r1rec���|�|d��dz}t|��dz
}|dd�dvr
|dz
}|dz}|d|�d||z
zz||d�zS)z�Replace contents with 'xxx' to prevent syntax matching.

    >>> mutate_string('"abc"')
    '"xxx"'
    >>> mutate_string("'''abc'''")
    "'''xxx'''"
    >>> mutate_string("r'abc'")
    "r'xxx'"
    r�rE���N)z"""z'''r��x)�indexr()rerfrgs   r/r^r^�s{��
�J�J�t�B�x� � �1�$�E�

�d�)�)�a�-�C��B�C�C�y�N�"�"�
��
���q�������<�#��u��-�-��S�T�T�
�:�:r1)(r�r�ror��loggingr:�typingrrrrrr�flake8r	r
�flake8.plugins.finderr�	getLoggerr�r��	frozensetr�r��INDENT�DEDENTrZr�r�r�r�r
r�r�r�r�r�r�rIr^r�r1r/�<module>r�s���L�L�����
�
�
�
�������������������������������������������������������������.�.�.�.�.�.��g���!�!��
�)�X�[�(�"2�3�
4�
4���i�
�[�(�"�H�O�X�_�E�����u�S�%��S��/�1�2�3����c��D��I��6�7��d.�d.�d.�d.�d.�d.�d.�d.�NM��*�M�t�M�M�M�M�
<�x�1�<�d�<�<�<�<�
�H�.��4�����
%��%�#�%�#�%�%�%�%�#��#��#�#�#�#�(;��;��;�;�;�;�;�;r1

Zerion Mini Shell 1.0