VL ipdZddlmZddlZddlZddlZddlmZddlm Z ddl m Z ddl m Z Gdd Zy) z8The base class and interface for all formatting plugins.) annotationsN)IO)_windows_color) Statistics) ViolationcxeZdZdZddZddZddZddZddZddZ ddZ dd Z dd Z dd Z dd Zdd ZddZy) 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. c||_|j|_d|_d|_|j dk(xsA|j dk(xr0t jjxrtj|_|jy)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) options output_filefilename output_fdnewlinecolorsysstdoutisattyrterminal_supports_color after_init)selfrs \/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/flake8/formatting/base.py__init__zBaseFormatter.__init__$sy ++ )- ]]h. MMV # 7 !!# 766 cy)z!Initialize the formatter further.Nrs rrzBaseFormatter.after_init9rcy)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. Nrrrs r beginningzBaseFormatter.beginning<r rcy)zNotify the formatter that we've finished processing a file. :param filename: The name of the file that Flake8 has finished reporting results from. Nrr"s rfinishedzBaseFormatter.finishedDr rc|jrytjjtjj |j}tj |dt |jd|_yy)z}Prepare the formatter to receive input. This defaults to initializing :attr:`output_fd` if :attr:`filename` T)exist_okaN)rospathdirnameabspathmakedirsopenr)rr+s rstartzBaseFormatter.startLsS ==ggoobggoodmm&DEG KK$ /!$--5DN rcl|j|}|j|}|j||y)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)rerrorlinesources rhandlezBaseFormatter.handleVs0{{5!!!%( 4 rctd)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)rr4s rr1zBaseFormatter.formates" D  rc|jD]c}|j|}t|}|j}|t d|Dz }|j |dd|d|j ey)z Format and print the statistics.c34K|]}|jyw)N)count).0stats r z0BaseFormatter.show_statistics..zsEEsz<5 N) error_codesstatistics_fornextr<sum_writemessage)r statistics error_codestats_for_error_code statisticr<s rshow_statisticszBaseFormatter.show_statisticsts}$002 HJ#-#<#.s% A# % s ^)rr2 physical_linejoin column_number)rr4indents rr2zBaseFormatter.show_sourceso||''5+>+>+F (()B5+>+>+BC   %%&vha00rcV|j(|jj||jz|j|jjrSt j jj|j|jjzyy)z9Handle logic of whether to use an output file or print().N) rr3rrteerrbufferencode)routputs rrEzBaseFormatter._writesr >> % NN $,,!6 7 >> !T\\%5%5 JJ   # #FMMOdll6I6I6K$K L&6rcR|r|j||r|j|yy)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)rE)rr5r6s rr3zBaseFormatter.writes'  KK   KK  rc`|j"|jjd|_yy)z%Clean up after reporting is finished.N)rclosers rstopzBaseFormatter.stops( >> % NN "!DN &rN)rzargparse.NamespacereturnNone)rirj)rstrrirj)r4rrirj)r4rri str | None)rGrrirj)rPzlist[tuple[str, float]]rirj)rdrkrirj)r5rlr6rlrirj)__name__ __module__ __qualname____doc__rrr#r%r/r7r1rKrTr2rEr3rhrrrr r sJ**0  6 !  H#*16M $"rr )rp __future__rargparser)rtypingrflake8.formattingrflake8.statisticsrflake8.violationrr rrrrws,>" ,(&|"|"r