Hacked By AnonymousFox

Current Path : /opt/cloudlinux/venv/lib/python3.11/site-packages/flake8/formatting/__pycache__/
Upload File :
Current File : //opt/cloudlinux/venv/lib/python3.11/site-packages/flake8/formatting/__pycache__/base.cpython-311.pyc

�

�܋f����dZddlZddlZddlZddlmZddlmZddlmZddlmZddl	m
Z
ddlmZdd	l
mZGd
�d��ZdS)z8The base class and interface for all formatting plugins.�N)�IO)�List)�Optional)�Tuple)�_windows_color)�
Statistics)�	Violationc��eZdZdZdejddfd�Zdd�Zdeddfd�Z	deddfd	�Z
dd
�Zdd
�Zddde
efd�Zdd�Zdeeeefddfd�Zddde
efd�Zdeddfd�Zde
ede
eddfd�Zdd�ZdS)�
BaseFormattera"Class defining the formatter interface.

    .. attribute:: options

        The options parsed from both configuration files and the command-line.

    .. attribute:: filename

        If specified by the user, the path to store the results of the run.

    .. attribute:: output_fd

        Initialized when the :meth:`start` is called. This will be a file
        object opened for writing.

    .. attribute:: newline

        The string to add to the end of a line. This is only used when the
        output filename has been specified.
    �options�returnNc��||_|j|_d|_d|_|jdkp4|jdko)tj���otj
|_|���dS)aMInitialize with the options parsed from config and cli.

        This also calls a hook, :meth:`after_init`, so subclasses do not need
        to call super to call this method.

        :param options:
            User specified configuration parsed from both configuration files
            and the command-line interface.
        N�
�always�auto)r�output_file�filename�	output_fd�newline�color�sys�stdout�isattyr�terminal_supports_color�
after_init)�selfrs  �g/builddir/build/BUILD/cloudlinux-venv-1.0.6/venv/lib/python3.11/site-packages/flake8/formatting/base.py�__init__zBaseFormatter.__init__%s|������+��
�,0�������]�h�.�
��M�V�#�
7��
�!�!�#�#�
7��6�	
�
�
	
��������c��dS)z!Initialize the formatter further.N��rs rrzBaseFormatter.after_init:����rrc��dS)z�Notify the formatter that we're starting to process a file.

        :param filename:
            The name of the file that Flake8 is beginning to report results
            from.
        Nr!�rrs  r�	beginningzBaseFormatter.beginning=r#rc��dS)z�Notify the formatter that we've finished processing a file.

        :param filename:
            The name of the file that Flake8 has finished reporting results
            from.
        Nr!r%s  r�finishedzBaseFormatter.finishedEr#rc��|jrstj�tj�|j����}tj|d���t
|jd��|_dSdS)z}Prepare the formatter to receive input.

        This defaults to initializing :attr:`output_fd` if :attr:`filename`
        T)�exist_ok�aN)r�os�path�dirname�abspath�makedirs�openr)rr.s  r�startzBaseFormatter.startMsg��
�=�	6��g�o�o�b�g�o�o�d�m�&D�&D�E�E�G��K��$�/�/�/�/�!�$�-��5�5�D�N�N�N�	6�	6r�errorr	c��|�|��}|�|��}|�||��dS)aDHandle an error reported by Flake8.

        This defaults to calling :meth:`format`, :meth:`show_source`, and
        then :meth:`write`. To extend how errors are handled, override this
        method.

        :param error:
            This will be an instance of
            :class:`~flake8.violation.Violation`.
        N)�format�show_source�write)rr3�line�sources    r�handlezBaseFormatter.handleWsB���{�{�5�!�!���!�!�%�(�(���
�
�4�� � � � � rc� �td���)aFormat an error reported by Flake8.

        This method **must** be implemented by subclasses.

        :param error:
            This will be an instance of
            :class:`~flake8.violation.Violation`.
        :returns:
            The formatted error string.
        z3Subclass of BaseFormatter did not implement format.)�NotImplementedError)rr3s  rr5zBaseFormatter.formatfs��"�D�
�
�	
r�
statisticsrc��|���D]l}|�|��}t|��}|j}|t	d�|D����z
}|�|d�d|�d|j�����mdS)z Format and print the statistics.c3�$K�|]}|jV��dS)N)�count)�.0�stats  r�	<genexpr>z0BaseFormatter.show_statistics.<locals>.<genexpr>{s$����E�E����E�E�E�E�E�Erz<5� N)�error_codes�statistics_for�nextr@�sum�_write�message)rr=�
error_code�stats_for_error_code�	statisticr@s      r�show_statisticszBaseFormatter.show_statisticsus���$�0�0�2�2�	H�	H�J�#-�#<�#<�Z�#H�#H� ��1�2�2�I��O�E��S�E�E�0D�E�E�E�E�E�E�E��K�K�5�F�F�F�j�F�F�9�3D�F�F�G�G�G�G�	H�	Hr�
benchmarksc��dj}dj}|D]J\}}t|t��r|||���}n
|||���}|�|���KdS)z Format and print the benchmarks.z{value:<10.3} {statistic}z{value:<10} {statistic})rM�valueN)r5�
isinstance�intrI)rrO�float_format�
int_formatrMrQ�	benchmarks       r�show_benchmarkszBaseFormatter.show_benchmarks~s���3�9��.�5�
� *�	#�	#��I�u��%��%�%�
K�&�J��%�H�H�H�	�	�(�L�9�E�J�J�J�	��K�K�	�"�"�"�"�	#�	#rc��|jjr|j�dSd�d�|jd|jdz
�D����}|j�|�d�S)a�Show the physical line generating the error.

        This also adds an indicator for the particular part of the line that
        is reported as generating the problem.

        :param error:
            This will be an instance of
            :class:`~flake8.violation.Violation`.
        :returns:
            The formatted error string if the user wants to show the source.
            If the user does not want to show the source, this will return
            ``None``.
        N�c3�FK�|]}|���r|ndV��dS)rDN)�isspace)rA�cs  rrCz,BaseFormatter.show_source.<locals>.<genexpr>�sG����
�
�������%�A�A�#�
�
�
�
�
�
r��^)rr6�
physical_line�join�
column_number)rr3�indents   rr6zBaseFormatter.show_source�s~���|�'�	�5�+>�+F��2����
�
��(�)B�5�+>��+B�)B�C�
�
�
�
�
���%�0�v�0�0�0�0r�outputc�"�|j�"|j�||jz��|j�|jjrRt
jj�|���|j���z��dSdS)z9Handle logic of whether to use an output file or print().N)	rr7rr�teerr�buffer�encode)rrcs  rrIzBaseFormatter._write�s{���>�%��N� � ��$�,�!6�7�7�7��>�!�T�\�%5�!��J��#�#�F�M�M�O�O�d�l�6I�6I�6K�6K�$K�L�L�L�L�L�"�!rr8r9c�f�|r|�|��|r|�|��dSdS)a�Write the line either to the output file or stdout.

        This handles deciding whether to write to a file or print to standard
        out for subclasses. Override this if you want behaviour that differs
        from the default.

        :param line:
            The formatted string to print or write.
        :param source:
            The source code that has been formatted and associated with the
            line of output.
        N)rI)rr8r9s   rr7zBaseFormatter.write�sH���	��K�K������	 ��K�K�������	 �	 rc�X�|j�"|j���d|_dSdS)z%Clean up after reporting is finished.N)r�closer"s r�stopzBaseFormatter.stop�s1���>�%��N� � �"�"�"�!�D�N�N�N�&�%r)r
N)r3r	r
N)r=rr
N)�__name__�
__module__�__qualname__�__doc__�argparse�	Namespacerr�strr&r(r2r:rr5rNrr�floatrWr6rIr7rkr!rrrrs���������*�� 2��t�����*0�0�0�0��#��$�������������6�6�6�6�
!�
!�
!�
!�

�K�

�H�S�M�

�

�

�

�H�H�H�H�#�$�u�S�%�Z�/@�*A�#�d�#�#�#�#�*1��1��#��1�1�1�1�6M�S�M�T�M�M�M�M� �(�3�-� ��#�� �4� � � � �$"�"�"�"�"�"rr)rorpr,r�typingrrrr�flake8.formattingr�flake8.statisticsr�flake8.violationr	rr!rr�<module>rxs���>�>�����	�	�	�	�
�
�
�
�������������������������,�,�,�,�,�,�(�(�(�(�(�(�&�&�&�&�&�&�|"�|"�|"�|"�|"�|"�|"�|"�|"�|"r

Hacked By AnonymousFox1.0, Coded By AnonymousFox