
    7 f                        d Z ddlmZ ddlZddlZddlZddlZddlm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 dd
lmZ ddlmZ ddlmZ ddlmZ  ej        e          Z G d d          ZdS )z3Module containing the application logic for Flake8.    )annotationsN)Sequence)checker)defaults)
exceptions)style_guide)BaseFormatter)debug)
parse_args)finder)reporterc                  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 )Applicationz&Abstract our application into a class.returnNonec                    t          j                     | _        d| _        d| _        d| _        d| _        d| _        d| _        d| _        d| _	        d| _
        dS )zInitialize our application.Nr   F)time
start_timeend_timeplugins	formatterguidefile_checker_manageroptionsresult_counttotal_result_countcatastrophic_failureselfs    M/var/www/equiseq/venv/lib/python3.11/site-packages/flake8/main/application.py__init__zApplication.__init__   sh     )++&*.2/3 <@
 =A! 37  #$ %*!!!    intc                r    | j         rdS | j        J | j        j        rdS t          | j        dk              S )zReturn the program exit code.   Nr   )r   r   	exit_zeror#   r   r   s    r    	exit_codezApplication.exit_code:   sH    $ 	1|'''<! 	.1t(1,---r"   c                |    | j         J | j        J t          j        | j         j        | j                  | _        dS )z3Initialize a formatter based on the parsed options.N)r   r   r   make	reportersr   r   s    r    make_formatterzApplication.make_formatterD   s<    |'''|'''!t|'=t|LLr"   c                r    | j         J | j        J t          j        | j        | j                   | _        dS )zInitialize our StyleGuide.N)r   r   r   StyleGuideManagerr   r   s    r    
make_guidezApplication.make_guideJ   s?    ~)))|''' 2L$.
 



r"   argvSequence[str]c                    | j         J | j        J t          j        | j         | j        j        |          | _        dS )z#Initialize our FileChecker Manager.N)r   r   r/   )r   r   r   Managercheckersr   r   r/   s     r    make_file_checker_managerz%Application.make_file_checker_managerR   sM    z%%%|'''$+O
L)%
 %
 %
!!!r"   c                   | j         J | j                                          	 | j                                          nN# t          j        $ r<}t          t          |                     t          d           d| _        Y d}~nd}~ww xY wt          	                    d           | j         
                                 t          j                    | _        dS )zRun the actual checks with the FileChecker Manager.

        This method encapsulates the logic to make a
        :class:`~flake8.checker.Manger` instance run the checks it is
        managing.
        Nz5Run flake8 with greater verbosity to see more detailsTzFinished running)r   startrunr   PluginExecutionFailedprintstrr   LOGinfostopr   r   )r   plugin_faileds     r    
run_checkszApplication.run_checks\   s     (444!'')))	-%))++++/ 	- 	- 	-#m$$%%%IJJJ(,D%%%%%%	- 	#$$$!&&(((	s   > B	2BB	c                   | j         J | j         j        sdS | j        J | j        J | j        | j        z
  }d|fg}|j        }t          j        dz   D ]I}| j        j        |         }d| d} |||f           | d} ||t          ||z            f           J| j
        J | j
                            |           dS )z9Aggregate, calculate, and report benchmarks for this run.Nzseconds elapsed)filesztotal z
 processedz processed per second)r   	benchmarkr   r   r   appendr   STATISTIC_NAMES
statisticsr#   r   show_benchmarks)r   time_elapsedrF   add_statistic	statisticvaluetotal_descriptionper_second_descriptions           r    report_benchmarkszApplication.report_benchmarksp   s   |'''|% 	F(444}(((}t6(,78
")!1J> 	O 	OI-8CE > > > >M,e4555(1%H%H%H"M13u|7K3L3LMNNNN~)))&&z22222r"   c                    t                               d           | j        J | j                                        }|\  | _        | _        t                               d| j        | j                   dS )zReport all the errors found by flake8 3.0.

        This also updates the :attr:`result_count` attribute with the total
        number of errors, warnings, and other messages found.
        zReporting errorsNz.Found a total of %d violations and reported %d)r<   r=   r   reportr   r   )r   resultss     r    report_errorszApplication.report_errors   sy     	#$$$(444+22445<2!2<#	
 	
 	
 	
 	
r"   c                    | j         J | j         j        sdS | j        J | j        J | j                            | j        j                   dS )z.Aggregate and report statistics from this run.N)r   rF   r   r   show_statisticsstatsr   s    r    report_statisticszApplication.report_statistics   s_    |'''|& 	F~)))z%%%&&tz'788888r"   c                ~   t          |          \  | _        | _        | j        j        rWt	          j        t          j        | j                  }t          t          j
        |dd                     t          d          |                                  |                                  |                     |           dS )zInitialize the application to be run.

        This finds the plugins, registers their options, and parses the
        command-line arguments.
           T)indent	sort_keysr   N)r   r   r   
bug_reportr
   informationflake8__version__r:   jsondumps
SystemExitr+   r.   r5   )r   r/   r=   s      r    
initializezApplication.initialize   s     &0%5%5"dl<" 	 $V%7FFD$*T!t<<<===Q--&&t,,,,,r"   c                    | j         J | j                                          |                                  |                                  |                                  | j                                          dS )z*Report errors, statistics, and benchmarks.N)r   r7   rR   rV   rN   r>   r   s    r    rP   zApplication.report   st    ~)))      r"   c                    |                      |           |                                  |                                  d S )N)rb   r@   rP   r4   s     r    _runzApplication._run   s5    r"   c                H   	 |                      |           | j        J | j        j        rt          | j                   dS dS # t
          $ rU}t          d           t                              d           t                              |           d| _	        Y d}~dS d}~wt          j        $ rJ}t          d           t          |           t                              |           d| _	        Y d}~dS d}~wt          j        $ r d| _	        t          d           Y dS w xY w)zRun our application.

        This method will also handle KeyboardInterrupt exceptions for the
        entirety of the flake8 application. If it sees a KeyboardInterrupt it
        will forcibly clean up the :class:`~flake8.checker.Manager`.
        Nz... stoppedz#Caught keyboard interrupt from userTz6There was a critical error during execution of Flake8:z"... stopped while processing files)re   r   countr:   r   KeyboardInterruptr<   critical	exceptionr   r   ExecutionError	EarlyQuit)r   r/   excs      r    r8   zApplication.run   sV   	)IIdOOO <+++|! )d'((((() ) ! 	- 	- 	--   LL>???MM#(,D%%%%%%%( 	- 	- 	-JKKK#JJJMM#(,D%%%%%%%# 	8 	8 	8(,D%6777777	8s*   A 
D!A
BD!0?C55(D! D!N)r   r   )r   r#   )r/   r0   r   r   )__name__
__module____qualname____doc__r!   r'   r+   r.   r5   r@   rN   rR   rV   rb   rP   re   r8    r"   r    r   r      s"       00* * * *<. . . .M M M M
 
 
 

 
 
 
$ $ $ $(3 3 3 3*
 
 
 
 9 9 9 9- - - -"      
) ) ) ) ) )r"   r   )rq   
__future__r   argparser_   loggingr   typingr   r]   r   r   r   r   flake8.formatting.baser	   flake8.mainr
   flake8.options.parse_argsr   flake8.pluginsr   r   	getLoggerrn   r<   r   rr   r"   r    <module>r|      sN   9 9 " " " " " "                                    0 0 0 0 0 0       0 0 0 0 0 0 ! ! ! ! ! ! # # # # # # g!!~) ~) ~) ~) ~) ~) ~) ~) ~) ~)r"   