iddZddlZddlZddlZddlmZddlmZddlmZddlmZddl m Z ddl m Z dd l mZGd d ZdS) z8The base class and interface for all formatting plugins.N)IO)List)Optional)Tuple)_windows_color) Statistics) ViolationceZdZdZdejddfdZddZdeddfdZ deddfd Z dd Z dd Z d d de efdZddZdeeeefddfdZd d de efdZdeddfdZde ede eddfdZddZdS) 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|_|jdkp4|jdko)t jo tj |_| 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 alwaysauto) r output_filefilename output_fdnewlinecolorsysstdoutisattyrterminal_supports_color after_init)selfr s K/opt/cloudlinux/venv/lib/python3.11/site-packages/flake8/formatting/base.py__init__zBaseFormatter.__init__%s| + ,0 ]h. MV # 7 !!## 76 cdS)z!Initialize the formatter further.Nrs rrzBaseFormatter.after_init:rrcdS)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!rrs r beginningzBaseFormatter.beginning=r#rcdS)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 rfinishedzBaseFormatter.finishedEr#rc|jrstjtj|j}tj|dt |jd|_dSdS)z}Prepare the formatter to receive input. This defaults to initializing :attr:`output_fd` if :attr:`filename` T)exist_okaN)rospathdirnameabspathmakedirsopenr)rr.s rstartzBaseFormatter.startMsg = 6goobgoodm&D&DEEG K$ / / / /!$-55DNNN 6 6rerrorr 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_sourcewrite)rr3linesources rhandlezBaseFormatter.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|Dz }||dd|d|jmdS)z Format and print the statistics.c3$K|] }|jV dS)N)count).0stats r z0BaseFormatter.show_statistics..{s$EEEEEEEErz<5 N) error_codesstatistics_fornextr@sum_writemessage)rr= error_codestats_for_error_code statisticr@s rshow_statisticszBaseFormatter.show_statisticsus$0022 H HJ#-#<#.sG   %AA#      r^)r r6 physical_linejoin column_number)rr3indents rr6zBaseFormatter.show_sources~|' 5+>+F2  ()B5+>+B)BC      %0v0000routputc"|j"|j||jz|j |jjrRt jj||jzdSdS)z9Handle logic of whether to use an output file or print().N) rr7rr teerrbufferencode)rrcs rrIzBaseFormatter._writes{ > % N $,!6 7 7 7 > !T\%5 ! J  # #FMMOOdl6I6I6K6K$K L L L L L " !rr8r9cf|r|||r||dSdS)aWrite 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.writesH   KK     KK       rcX|j"|jd|_dSdS)z%Clean up after reporting is finished.N)rcloser"s rstopzBaseFormatter.stops1 > % N " " "!DNNN & %r)r N)r3r r N)r=rr N)__name__ __module__ __qualname____doc__argparse Namespacerrstrr&r(r2r:rr5rNrrfloatrWr6rIr7rkr!rrr r s* 2t*0000 # $          6666 ! ! ! !  K  HSM     HHHH#$uS%Z/@*A#d####*11#11116MSMTMMMM (3- # 4    $""""""rr )rorpr,rtypingrrrrflake8.formattingrflake8.statisticsrflake8.violationr r r!rrrxs>> ,,,,,,((((((&&&&&&|"|"|"|"|"|"|"|"|"|"r