§
    øyIf¼  ã                  óx   — d Z ddlmZ ddlZddlZddlZddlmZ ddlm	Z	 ddl
mZ ddlmZ  G d„ d	¦  «        ZdS )
z8The base class and interface for all formatting plugins.é    )ÚannotationsN)ÚIO)Ú_windows_color)Ú
Statistics)Ú	Violationc                  óz   — e Zd ZdZd d„Zd!d„Zd"d
„Zd"d„Zd!d„Zd#d„Z	d$d„Z
d%d„Zd&d„Zd$d„Zd'd„Zd(d„Zd!d„ZdS ))Ú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úargparse.NamespaceÚreturnÚNonec                óú   — || _         |j        | _        d| _        d| _        |j        dk    p4|j        dk    o)t          j                             ¦   «         ot          j
        | _        |                      ¦   «          dS )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ú
ÚalwaysÚauto)r
   Úoutput_fileÚfilenameÚ	output_fdÚnewlineÚcolorÚsysÚstdoutÚisattyr   Úterminal_supports_colorÚ
after_init)Úselfr
   s     úJ/var/www/piapp/venv/lib/python3.11/site-packages/flake8/formatting/base.pyÚ__init__zBaseFormatter.__init__$   s|   € ð ˆŒØÔ+ˆŒØ)-ˆŒØˆŒØ”] hÒ.ð 
ØŒM˜VÒ#ð 7Ý”
×!Ò!Ñ#Ô#ð7åÔ6ð 	Œ
ð
 	�ŠÑÔÐÐÐó    c                ó   — dS )z!Initialize the formatter further.N© ©r   s    r   r   zBaseFormatter.after_init9   ó   € € € r   r   Ústrc                ó   — dS )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!   ©r   r   s     r   Ú	beginningzBaseFormatter.beginning<   r#   r   c                ó   — dS )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   ÚfinishedzBaseFormatter.finishedD   r#   r   c                óú   — | j         rst          j                             t          j                             | j         ¦  «        ¦  «        }t          j        |d¬¦  «         t          | j         d¦  «        | _        dS dS )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   )r   r/   s     r   ÚstartzBaseFormatter.startL   sg   € ð
 Œ=ð 	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                ó†   — |                       |¦  «        }|                      |¦  «        }|                      ||¦  «         dS )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)ÚformatÚshow_sourceÚwrite)r   r4   ÚlineÚsources       r   ÚhandlezBaseFormatter.handleV   sB   € ð �{Š{˜5Ñ!Ô!ˆØ×!Ò! %Ñ(Ô(ˆØ�
Š
�4˜Ñ Ô Ð Ð Ð r   ú
str | Nonec                ó    — 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   r4   s     r   r6   zBaseFormatter.formate   s   € õ "ØDñ
ô 
ð 	
r   Ú
statisticsr   c                ó  — |                      ¦   «         D ]l}|                     |¦  «        }t          |¦  «        }|j        }|t	          d„ |D ¦   «         ¦  «        z  }|                      |d›d|› d|j        › �¦  «         ŒmdS )z Format and print the statistics.c              3  ó$   K  — | ]}|j         V — Œd S )N)Úcount)Ú.0Ústats     r   ú	<genexpr>z0BaseFormatter.show_statistics.<locals>.<genexpr>z   s$   è è € ÐEÐE¨˜œÐEÐEÐEÐEÐEÐEr   z<5ú N)Úerror_codesÚstatistics_forÚnextrB   ÚsumÚ_writeÚmessage)r   r?   Ú
error_codeÚstats_for_error_codeÚ	statisticrB   s         r   Úshow_statisticszBaseFormatter.show_statisticst   s§   € à$×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ð 	Hr   Ú
benchmarksúlist[tuple[str, float]]c                ó¼   — dj         }dj         }|D ]J\  }}t          |t          ¦  «        r |||¬¦  «        }n |||¬¦  «        }|                      |¦  «         ŒKdS )z Format and print the benchmarks.z{value:<10.3} {statistic}z{value:<10} {statistic})rO   ÚvalueN)r6   Ú
isinstanceÚintrK   )r   rQ   Úfloat_formatÚ
int_formatrO   rT   Ú	benchmarks          r   Úshow_benchmarkszBaseFormatter.show_benchmarks}   s„   € ð 3Ô9ˆØ.Ô5ˆ
Ø *ð 	#ð 	#ÑˆI�uÝ˜%¥Ñ%Ô%ð KØ&˜J°À%ÐHÑHÔH�	�	à(˜L°9ÀEÐJÑJÔJ�	Ø�KŠK˜	Ñ"Ô"Ð"Ð"ð	#ð 	#r   c                ó¬   — | j         j        r|j        €dS d                     d„ |j        d|j        dz
  …         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Ú c              3  óF   K  — | ]}|                      ¦   «         r|nd V — ŒdS )rF   N)Úisspace)rC   Úcs     r   rE   z,BaseFormatter.show_source.<locals>.<genexpr>¥   sG   è è € ð 
ð 
àð —’‘”Ð%ˆAˆA #ð
ð 
ð 
ð 
ð 
ð 
r   é   ú^)r
   r7   Úphysical_lineÚjoinÚcolumn_number)r   r4   Úindents      r   r7   zBaseFormatter.show_source’   s~   € ð Œ|Ô'ð 	¨5Ô+>Ð+FØ�2ð —’ð 
ð 
àÔ(Ð)B¨5Ô+>ÀÑ+BÐ)BÔCð
ñ 
ô 
ñ 
ô 
ˆð Ô%Ð0 vÐ0Ð0Ð0Ð0r   Úoutputc                ó"  — | j         �"| j                              || j        z   ¦  «         | j         �| j        j        rRt
          j        j                             |                     ¦   «         | j                             ¦   «         z   ¦  «         dS dS )z9Handle logic of whether to use an output file or print().N)	r   r8   r   r
   Úteer   r   ÚbufferÚencode)r   rf   s     r   rK   zBaseFormatter._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ð "Ð!r   r9   r:   c                óf   — |r|                       |¦  «         |r|                       |¦  «         dS dS )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)rK   )r   r9   r:   s      r   r8   zBaseFormatter.write´   sH   € ð ð 	Ø�KŠK˜ÑÔÐØð 	 Ø�KŠK˜ÑÔÐÐÐð	 ð 	 r   c                óX   — | j         �"| j                              ¦   «          d| _         dS dS )z%Clean up after reporting is finished.N)r   Úcloser"   s    r   ÚstopzBaseFormatter.stopÆ   s1   € àŒ>Ð%ØŒN× Ò Ñ"Ô"Ð"Ø!ˆDŒNˆNˆNð &Ð%r   N)r
   r   r   r   )r   r   )r   r$   r   r   )r4   r   r   r   )r4   r   r   r<   )r?   r   r   r   )rQ   rR   r   r   )rf   r$   r   r   )r9   r<   r:   r<   r   r   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r'   r)   r3   r;   r6   rP   rZ   r7   rK   r8   rn   r!   r   r   r	   r	      s*  € € € € € ðð ð*ð ð ð ð*0ð 0ð 0ð 0ðð ð ð ðð ð ð ð6ð 6ð 6ð 6ð!ð !ð !ð !ð
ð 
ð 
ð 
ðHð Hð Hð Hð#ð #ð #ð #ð*1ð 1ð 1ð 1ð6Mð Mð Mð Mð ð  ð  ð  ð$"ð "ð "ð "ð "ð "r   r	   )rr   Ú
__future__r   Úargparser-   r   Útypingr   Úflake8.formattingr   Úflake8.statisticsr   Úflake8.violationr   r	   r!   r   r   ú<module>ry      s¼   ðØ >Ð >Ø "Ð "Ð "Ð "Ð "Ð "à €€€Ø 	€	€	€	Ø 
€
€
€
Ø Ð Ð Ð Ð Ð à ,Ð ,Ð ,Ð ,Ð ,Ð ,Ø (Ð (Ð (Ð (Ð (Ð (Ø &Ð &Ð &Ð &Ð &Ð &ð|"ð |"ð |"ð |"ð |"ñ |"ô |"ð |"ð |"ð |"r   