-KXdZddlZddlZddlZddlZddlZddlmZddlmZddlm Z ddlm Z ddlm Z ddlm Z ddl Z dd l mZdd l mZdd l mZdd l mZdd l mZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZeje Z!GddZ"dS)z3Module containing the application logic for Flake8.N)Dict)List)Optional)Sequence)Set)Tuple)checker)defaults) exceptions) style_guide)utils) BaseFormatter)debug)options) aggregator)config)manager)finder)reporterc peZdZdZddZdeedeej e effdZ de fdZ dejd ed eed eeddf d Zdd Zdejd ede eddfdZddZddZddZddZddZddZddZdeeddfdZddZdeeddfdZdeeddfdZdS) Applicationz&Abstract our application into a class.returnNctj|_d|_tj|_d|_d|_d|_d|_ d|_ d|_d|_ d|_ d|_ i|_dS)zInitialize our application.NrF)time start_timeend_timerstage1_arg_parserprelim_arg_parseroption_managerplugins formatterguidefile_checker_manager result_counttotal_result_countcatastrophic_failure parsed_diffselfs /srv/buildsys-work-dir/castor/build_node/builder-2/WGSG1/unpkd_srcs/cloudlinux-venv-1.0.6/venv/lib/python3.11/site-packages/flake8/main/application.py__init__zApplication.__init__$s)++)- ")!:!#t0$r||jYZwxYwdS)z.Parse configuration files and the CLI options.NT)indent sort_keysrzHthe --diff option is deprecated and will be removed in a future version. parse_options)rr raggregate_optionsr bug_reportr informationrJrKprintjsondumps SystemExitdiffLOGwarningr parse_unified_diffr' all_pluginsgetattrobj filenames TypeError)r)r:r;r-infoloadedrTs r*parse_configuration_and_cliz'Application.parse_configuration_and_clisy"...|'''!3          < " $V%7FFD $*T!t<<< = = =Q--  <  : KK"    %799D l..00 , ,F#FJFFM$ , 'LL*  , , , dl+++++ , , ,s !D,,E E c||jJ|jJtj|jj|j|_dS)z3Initialize a formatter based on the parsed options.N)r rrmake reportersr!r(s r*make_formatterzApplication.make_formatters<|'''|'''!t|'=t|LLr,c|jJ|jJtj|j|j|_|jjr!|j|jdSdS)zInitialize our StyleGuide.N)r!rr StyleGuideManagerr"r\add_diff_rangesr'r(s r* make_guidezApplication.make_guidess~)))|''' 2 L$.    <  9 J & &t'7 8 8 8 8 8 9 9r,c~|jJ|jJtj|j|jj|_dS)z#Initialize our FileChecker Manager.N)r r )r"r r Managercheckersr#r(s r*make_file_checker_managerz%Application.make_file_checker_managersJz%%%|'''$+O L)% % % !!!r,c|jJ|jJ|jjrt|j}|sdSnd}|j| |jnN#tj$r<}tt|tdd|_ Yd}~nd}~wwxYwt d|jtj|_dS)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 detailsTzFinished running)rr#r\sortedr'startrunr PluginExecutionFailedrXstrr&r]restoprr)r)files plugin_faileds r* run_checkszApplication.run_checkss$|'''(444 <  )/0@)A)AE  E !''... -  % ) ) + + + +/ - - - #m$$ % % % I J J J(,D % % % % % % - #$$$ !&&(((  sA//B:>2B55B:c|jJ|jjsdS|jJ|jJ|j|jz }d|fg}|j}t jdzD]I}|jj|}d|d}|||f|d}||t||z fJ|j J|j |dS)z9Aggregate, calculate, and report benchmarks for this run.Nzseconds elapsed)r{ztotal z processedz processed per second) r benchmarkr#rrappendr STATISTIC_NAMES statisticsr8r!show_benchmarks)r) time_elapsedr add_statistic statisticvaluetotal_descriptionper_second_descriptions r*report_benchmarkszApplication.report_benchmarkss|'''|%  F(444}(((}t6 (,78 ") !1J> O OI-8CE > > > >  M,e4 5 5 5(1%H%H%H " M13u|7K3L3LM N N N N~))) &&z22222r,ctd|jJ|j}|\|_|_td|j|jdS)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. zReporting errorsNz.Found a total of %d violations and reported %d)r]rer#reportr%r$)r)resultss r* report_errorszApplication.report_errorssy #$$$(444+22445<2!2  <  #       r,c|jJ|jjsdS|jJ|jJ|j|jjdS)z.Aggregate and report statistics from this run.N)rrr!r"show_statisticsstatsr(s r*report_statisticszApplication.report_statisticss_|'''|&  F~)))z%%% &&tz'788888r,c||\}}tj|j|jt j|j|j|j\}}| |||j |j | | ||||||dS)zInitialize the application to be run. This finds the plugins, registers their options, and parses the command-line arguments. )rextraisolatedr?N)r4rJconfigure_loggingverboser0r load_config append_configrrAr<r=rOrgrkrors)r)r- prelim_optsremaining_argsr:r;s r* initializezApplication.initializes'+&D&DT&J&J# ^ !4k6MNNN)%+ )   W   );'7    $$&&& ((g~FFF   &&(((((r,c|jJ|j||||jdS)z*Report errors, statistics, and benchmarks.N)r!rvrrrrzr(s r*rzApplication.report:st~)))           r,c||||dS)N)rr}r)r)r-s r*_runzApplication._runCs5   r,cH |||jJ|jjrt|jdSdS#t $rU}tdt dt |d|_ Yd}~dSd}~wtj $rJ}tdt|t |d|_ Yd}~dSd}~wtj $rd|_ tdYdSwxYw)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) rrcountrXr$KeyboardInterruptr]critical exceptionr&r ExecutionError EarlyQuit)r)r-excs r*rwzApplication.runHsV ) 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 BD!0?C55(D! D!)rN)__name__ __module__ __qualname____doc__r+rryrargparse Namespacerr4r8r9 configparserRawConfigParserrrArOrgrkrorsr}rrrrrrrwr,r*rr!s>00%3%3%3%3NSM x!49, -0.3....6  )66 $C= 6 "# 6 6666* ; ; ; ;),  )),),3i ),  ),),),),VMMMM 9 9 9 9    $$$$63333*    9999)x}))))):#4 ) )$))))))r,r)#rrrrYloggingrtypingrrrrrrrJr r r r r flake8.formatting.baser flake8.mainrrflake8.optionsrrrflake8.pluginsrr getLoggerrr]rrr,r*rs99   000000%%%%%%!!!!!!""""""!!!!!!######g!!@)@)@)@)@)@)@)@)@)@)r,