qҶdX d Z ddlZddlZddlZddlmZ ddlmZ ddlmZ ddlmZ ddl m
Z
ddlmZ dd l
mZ G d
d ZdS )z8The base class and interface for all formatting plugins. N)IO)List)Optional)Tuple)_windows_color)
Statistics) Violationc e Zd ZdZdej ddfdZddZdeddfdZ deddfd Z
dd
Zdd
Zddde
e fdZddZdeeeef ddfdZddde
e fdZdeddfdZde
e de
e ddfdZddZdS )
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.
optionsreturnNc || _ |j | _ d| _ d| _ |j dk p4|j dk o)t j ot j
| _ | dS )aM Initialize 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
alwaysauto)r output_filefilename output_fdnewlinecolorsysstdoutisattyr terminal_supports_color
after_init)selfr s h/builddir/build/BUILD/cloudlinux-venv-1.0.10/venv/lib/python3.11/site-packages/flake8/formatting/base.py__init__zBaseFormatter.__init__% s| +
,0]h.
MV#
7
!!##
76
c dS )z!Initialize the formatter further.N r s r r zBaseFormatter.after_init: r r c dS )zNotify 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! r r s r beginningzBaseFormatter.beginning= r# r c dS )zNotify 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.finishedE r# r c | j rst j t j | j }t j |d t
| j d | _ dS dS )z}Prepare the formatter to receive input.
This defaults to initializing :attr:`output_fd` if :attr:`filename`
T)exist_okaN)r ospathdirnameabspathmakedirsopenr )r r. s r startzBaseFormatter.startM sg
= 6goobgoodm&D&DEEGK$////!$-55DNNN 6 6r errorr c | | }| | }| || dS )aD Handle 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)formatshow_sourcewrite)r r3 linesources r handlezBaseFormatter.handleW sB {{5!!!!%((
4 r c t d )a Format 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)r r3 s r r5 zBaseFormatter.formatf s "D
r
statisticsr c | D ]l}| | }t | }|j }|t d |D z
}| |dd| d|j mdS )z Format and print the statistics.c 3 $ K | ]}|j V d S )N)count).0stats r