
    g                        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 ddlmZ  ej&                  e      Zd	Z G d
 d      Z G d d      ZddZy)zModule containing shims around Flake8 2.x behaviour.

Previously, users would import :func:`get_style_guide` from ``flake8.engine``.
In 3.0 we no longer have an "engine" module but we maintain the API from it.
    )annotationsN)Any)expand_paths)base)application)
parse_args)get_style_guidec                  2    e Zd ZdZddZedd       ZddZy)	Reporta"  Public facing object that mimic's Flake8 2.0's API.

    .. note::

        There are important changes in how this object behaves compared to
        the object provided in Flake8 2.x.

    .. warning::

        This should not be instantiated by users.

    .. versionchanged:: 3.0.0
    c                    |j                   J || _        |j                   | _        | j                  j                  | _        y)zlInitialize the Report for the user.

        .. warning:: This should not be instantiated by users.
        N)guide_application_style_guidestats_statsselfr   s     T/var/www/html/brdwt/brdwt/brdwtenv/lib/python3.12/site-packages/flake8/api/legacy.py__init__zReport.__init__'   s?    
   ,,,''--''--    c                .    | j                   j                  S )z"Return the total number of errors.)r   result_countr   s    r   total_errorszReport.total_errors1   s       ---r   c                    | j                   j                  |      D cg c]*  }|j                   d|j                   d|j                   , c}S c c}w )zGet the list of occurrences of a violation.

        :returns:
            List of occurrences of a violation formatted as:
            {Count} {Error Code} {Message}, e.g.,
            ``8 E531 Some error message about the error``
         )r   statistics_forcount
error_codemessage)r   	violationss      r   get_statisticszReport.get_statistics6   sP     [[//	:
 wwiqa		{3
 	
 
s   /ANr   zapp.ApplicationreturnNone)r%   int)r!   strr%   	list[str])__name__
__module____qualname____doc__r   propertyr   r#    r   r   r   r      s%    . . .
r   r   c                      e Zd ZdZd
dZedd       Zedd       ZdddZdddZ		 d	 	 	 ddZ
	 	 	 d	 	 	 	 	 	 	 	 	 dd	Zy)
StyleGuideaD  Public facing object that mimic's Flake8 2.0's StyleGuide.

    .. note::

        There are important changes in how this object behaves compared to
        the StyleGuide object provided in Flake8 2.x.

    .. warning::

        This object should not be instantiated directly by users.

    .. versionchanged:: 3.0.0
    c                4    || _         |j                  | _        y)zInitialize our StyleGuide.N)r   file_checker_manager_file_checker_managerr   s     r   r   zStyleGuide.__init__S   s    '%0%E%E"r   c                ^    | j                   j                  J | j                   j                  S )zuReturn application's options.

        An instance of :class:`argparse.Namespace` containing parsed options.
        )r   optionsr   s    r   r6   zStyleGuide.optionsX   s.       ((444  (((r   c                r    | j                   j                  J | j                   j                  j                  S )z+Return the extra arguments passed as paths.)r   r6   	filenamesr   s    r   pathszStyleGuide.pathsa   s4       ((444  ((222r   Nc                    | j                   j                  J || j                   j                  _        | j                   j                          | j                   j	                          t        | j                         S )a)  Run collected checks on the files provided.

        This will check the files passed in and return a :class:`Report`
        instance.

        :param paths:
            List of filenames (or paths) to check.
        :returns:
            Object that mimic's Flake8 2.0's Reporter class.
        )r   r6   r8   
run_checksreport_errorsr   )r   r9   s     r   check_fileszStyleGuide.check_filesg   se       ((444.3!!+$$&'')d''((r   c                |     d fd} ||      xs, |duxr&  |t         j                  j                  ||            S )a"  Determine if a file is excluded.

        :param filename:
            Path to the file to check if it is excluded.
        :param parent:
            Name of the parent directory containing the file.
        :returns:
            True if the filename is excluded, False otherwise.
        c                    t        t        | gj                  j                  j                  j                  j                  j
                              }| S )N)r9   stdin_display_namefilename_patternsexclude)tupler   r6   r@   filenamerB   )pathr9   r   s     r   excludedz%StyleGuide.excluded.<locals>.excluded   sK    &'+||'F'F&*ll&;&; LL00	E 9r   N)rE   r(   r%   bool)osrE   join)r   rD   parentrF   s   `   r   rF   zStyleGuide.excludedx   s=    		 ! 
$K8BGGLL,J#K	
r   c                D   |yt        |t        j                        st        d       || j                        | j
                  _        d| j
                  _        | j
                  j                          d| j
                  _        | j
                  j                  g        y)z*Set up a formatter for this run of Flake8.Nz<Report should be subclass of flake8.formatter.BaseFormatter.)

issubclass	formatterBaseFormatter
ValueErrorr6   r   r   
make_guider3   make_file_checker_manager)r   reporters     r   init_reportzStyleGuide.init_report   s    
 (I$;$;<2  '/t||&<#"& 	$$&15.33B7r   c                &    | j                  |g      S )a  Run collected checks on a single file.

        This will check the file passed in and return a :class:`Report`
        instance.

        :param filename:
            The path to the file to check.
        :param lines:
            Ignored since Flake8 3.0.
        :param expected:
            Ignored since Flake8 3.0.
        :param line_offset:
            Ignored since Flake8 3.0.
        :returns:
            Object that mimic's Flake8 2.0's Reporter class.
        )r=   )r   rD   linesexpectedline_offsets        r   
input_filezStyleGuide.input_file   s    . 
++r   r$   )r%   zargparse.Namespace)r%   r)   )N)r9   zlist[str] | Noner%   r   )rD   r(   rJ   z
str | Noner%   rG   )rR   z$type[formatter.BaseFormatter] | Noner%   r&   )NNr   )
rD   r(   rU   
Any | NonerV   rY   rW   rY   r%   r   )r*   r+   r,   r-   r   r.   r6   r9   r=   rF   rS   rX   r/   r   r   r1   r1   D   s    F
 ) ) 3 3
)"
8 :>868 
80 !#"#,, , 	,
  , 
,r   r1   c                    t        j                         }t        g       \  |_        |_        |j                  }| j                         D ]  \  }}	 t        ||       t        |||       ! |j                          |j                          |j                  g        t        |      S # t        $ r t        j                  d|       Y w xY w)zProvision a StyleGuide for use.

    :param \*\*kwargs:
        Keyword arguments that provide some options for the StyleGuide.
    :returns:
        An initialized StyleGuide
    zCould not update option "%s")appApplicationr   pluginsr6   itemsgetattrsetattrAttributeErrorLOGerrormake_formatterrP   rQ   r1   )kwargsr   r6   keyvalues        r   r	   r	      s     //#K/9"~,K, !!Glln ;
U	;GS!GS%(;  ))"-k""  	;II4c:	;s   B''C	C	)re   r   r%   r1   )r-   
__future__r   argparseloggingos.pathrH   typingr   flake8.discover_filesr   flake8.formattingr   rM   flake8.mainr   r[   flake8.options.parse_argsr   	getLoggerr*   rb   __all__r   r1   r	   r/   r   r   <module>rs      s]   
 #     . / * 0g! )
 )
Xz, z,z#r   