
    yIf:                    0   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Zddlm	Z	 ddl
mZmZmZ ddlZddlmZ ddlmZmZmZmZmZmZmZ ddlmZmZ dd	lmZ dd
lmZm Z  ddl!m"Z" ddl#m$Z$m%Z% ej&        dk    rddl'Z'nddl(Z'erddl)m*Z*  G d d          Z+dS )JArguments manager class used to handle command-line arguments and options.    )annotationsN)Sequence)TYPE_CHECKINGAnyTextIO)utils)	_Argument_CallableArgument_ExtendArgument_StoreArgument_StoreNewNamesArgument_StoreOldNamesArgument_StoreTrueArgument)UnrecognizedArgumentAction_UnrecognizedOptionError)_HelpFormatter)_convert_option_to_argument_parse_rich_type_value)MAIN_CHECKER_NAME)DirectoryNamespaceDict
OptionDict)      )_ArgumentsProviderc                      e Zd ZdZ	 d/d0d
Zed1d            Zej        d2d            Zd3dZd4dZ	e
d5d            Zd6dZd7dZ	 d8d9dZ	 d:d;d%Zd<d&Zd'd(d=d+Zd>d.ZdS )?_ArgumentsManagerr   Nprogstrusage
str | NonedescriptionreturnNonec                    t          j                    | _        	 | j        | _        	 t          j        ||pd|t
          d          | _        	 i | _        	 i | _        	 i | _	        d S )Nz%(prog)s [options]resolve)r   r    r"   formatter_classconflict_handler)
argparse	Namespace_config_base_configArgumentParserr   _arg_parser_argument_groups_dict_option_dicts_directory_namespaces)selfr   r    r"   s       S/var/www/piapp/venv/lib/python3.11/site-packages/pylint/config/arguments_manager.py__init__z_ArgumentsManager.__init__3   s      )++( L	 $2//#*&
 
 
 	0IK"446@=?"LL    argparse.Namespacec                    | j         S )zNamespace for all options.r+   r2   s    r3   configz_ArgumentsManager.configT   s     |r5   valuec                    || _         d S Nr8   )r2   r;   s     r3   r:   z_ArgumentsManager.configY   s    r5   providerr   c                   |j         D ]\  }}|| j        |<   t          ||          }|j        p|j                                        }|j                            |d          }|j        t          k    r'|j	        r |j	        
                    d          d         }|                     |||           |                                  dS )z3Register an options provider and load its defaults.Nz

r   )optionsr0   r   sectionname
capitalizeoption_groups_descsgetr   __doc__split_add_arguments_to_parser_load_default_argument_values)r2   r>   optoptdictargumentrA   section_descs          r3   _register_options_providerz,_ArgumentsManager._register_options_provider]   s    $, 	K 	KLC&-Ds#23@@H&D(-*B*B*D*DG#7;;GTJJL } 111h6F1'/55f==a@))'<JJJJ**,,,,,r5   rA   rM   rL   r
   c                    	 | j         |         }nS# t          $ rF |r| j                            ||          }n| j                            |          }|| j         |<   Y nw xY w|                     ||           dS )z6Add an argument to the correct argument section/group.titleN)r/   KeyErrorr.   add_argument_group_add_parser_option)r2   rA   rM   rL   section_groups        r3   rH   z*_ArgumentsManager._add_arguments_to_parsern   s    		@ 6w?MM 	@ 	@ 	@ S $ 0 C C\! ! !% 0 C C' C R R2?D&w///	@ 	x88888s    AA A rU   argparse._ArgumentGroupc                R   t          |t                    r7 | j        |j        |j        |j        |j        |j        |j        |j	        d dS t          |t                    r | j        |j        i |j        |j        |j        |j        |j        |j        |j	        d |j        d         sJ |j        d         D ]?}|                     d| d|j        |j        t          j        |j        |j	                   @dS t          |t                    r@ | j        |j        i |j        |j        |j        |j        |j        |j        |j	        d dS t          |t                    r% | j        |j        |j        |j        |j        d dS t          |t                     r. | j        |j        i |j        |j        |j        |j        d dS t          |t"                    r= | j        |j        |j        |j        |j        |j        |j        |j	        |j        d dS t&          )	zAdd an argument.)actiondefaulttypehelpmetavarchoices	old_names--store)rX   rY   r[   )rX   r[   r\   )rX   rY   rZ   r[   r\   r]   destN)
isinstancer   add_argumentflagsrX   rY   rZ   r[   r\   r]   r   kwargsr)   SUPPRESSr   r   r   r   ra   r   )rU   rL   old_names      r3   rT   z$_ArgumentsManager._add_parser_option~   s   
 h// H	-&M& (]] ( (      "899 >	-&M&	/	   (]] ( (	 	 	 	 	 ?;////$OK8 	 	**#OO"$,!!*$,$, +    	 	 "899 &	-&M&	/	   (]] ( (	 	 	 	 	 	 	 "455 	-&M& (]	      "344 	-&M&/  ] (       /22 	-&M& (]] ( (]	 	 	 	 	 	 -,r5   c                P    | j                             g | j                  | _        dS )z3Loads the default values of all registered options.N)r.   
parse_argsr:   r9   s    r3   rI   z/_ArgumentsManager._load_default_argument_values   s"    &11"dkBBr5   	arguments	list[str]c                8   	 | j                             || j                  \  | _        }n$# t          $ r t	          j        d           Y nw xY wg }|D ]4}|                    d          r|                    |dd                    5|rt          |          dS )zEParse the arguments found in a configuration file into the namespace.    r_      N)r@   )	r.   parse_known_argsr:   
SystemExitsysexit
startswithappendr   )r2   rj   parsed_argsunrecognized_optionsrJ   s        r3   _parse_configuration_filez+_ArgumentsManager._parse_configuration_file   s    	'+'7'H'H4;( ($DK  	 	 	HRLLLLL	*, 	5 	5C~~d## 5$++CG444 	I*3GHHHH	I 	Is   (+ AASequence[str] | Nonec                    |t           j        dd         n|}| j                            || j                  \  | _        }|S )zAParse the arguments found on the command line into the namespace.N   )rq   argvr.   ro   r:   )r2   rj   ru   s      r3   !_parse_command_line_configurationz3_ArgumentsManager._parse_command_line_configuration   sJ     %.$5CHQRRLL9	#'#3#D#Dt{$
 $
 [ r5    streamTextIO | Noneskipsectionstuple[str, ...]c                \   i }g }t          | j        j        d           D ]}|j        }|sJ ||v rg }d |j        D             }t          |d           D ]}	d|	j        v r|	j        d         dd         }
	 | j        |
         }n# t          $ r Y <w xY w|                    |
|t          | j
        |
                    d	d
                    f           d |D             }|r|                    |           |||<   |pt          j        }d}|D ]}|rt          d|           t          j                    5  t          j        dt$                     t'          j        ||                                t          ||                              ddd           n# 1 swxY w Y   d}dS )zsWrite a configuration file according to the current configuration
        into the given stream or stdout.
        c                &    | j         dk    | j         fS NMainrP   xs    r3   <lambda>z4_ArgumentsManager._generate_config.<locals>.<lambda>       17f,ag6 r5   keyc                F    g | ]}t          |t          j                  |S r}   rb   r)   _SubParsersAction.0is     r3   
<listcomp>z6_ArgumentsManager._generate_config.<locals>.<listcomp>   ;       !!X%?@@  r5   c                ,    | j         d         dd          S Nr   rn   option_stringsr   s    r3   r   z4_ArgumentsManager._generate_config.<locals>.<lambda>  s    A<LQ<OPQPRPR<S r5   z--helpr   rn   N-_c                J    g | ] \  }}}|                     d           |||f!S )
deprecated)rE   )r   ndvs       r3   r   z6_ArgumentsManager._generate_config.<locals>.<listcomp>  sE       "+1aaeeL>Q>Q1I  r5   F
)fileignore)categoryT)sortedr.   _action_groupsrQ   _group_actionsr   r0   rR   rt   getattrr:   replacerq   stdoutprintwarningscatch_warningsfilterwarningsDeprecationWarningr	   format_sectionupper)r2   r~   r   options_by_sectionsectionsgroup
group_namer@   option_actionsrJ   optnamerK   printedrA   s                 r3   _generate_configz"_ArgumentsManager._generate_config   s     +66
 
 
 (	9 (	9E J\))G -  N
 n2S2STTT  s111,Q/3"09GG   H W__S#-F-FGG   /6    9
+++18":.%3: 	 	G )d(((((**  ';MNNNN$GMMOOV4Fw4O-P-P                
 GG	 	s%   :B
BB;AFF"	%F"	c                4    | j                                         S )z7Return the usage string based on the available options.)r.   format_helpr9   s    r3   r[   z_ArgumentsManager.help)  s    ++---r5   F)minimalr   boolc          	        t          j                    }t          j        d          }|                    t          j        d          |           t          j        d          }|                    t          j        d          |           t          | j        j        d           D ]}|j        dv r|j	        st          j                    }d |j	        D             }t          |d	           D ]e}|j
        d
         dd         }		 | j        |	         }
n# t          $ r Y 3w xY w|
                    d          rM|so|
                    dd          }t          |t                    sJ t!          j        |d          }|D ])}|                    t          j        |                     *t'          | j        |	                    dd                    }|sT|sP|                    t          j        |	 d                     |                    t          j                               =d|
v r)t          |
d         t.                    sJ d|
d         v rjt          |t0          j                  r|j        }nHt          |t6          t8          f          r,t          |d
         t0          j                  rd |D             }|
                    d          dk    rd                    d |D                       }|r||
                    d          k    r)|                    |	|           |                    t          j                               g|j        sJ |r-|                    |j                                        |           t          j        |          }tA          j!        |           t          |          S )z_Write a configuration file according to the current configuration into
        stdout.
        T)is_super_tabletoolpylintc                &    | j         dk    | j         fS r   rP   r   s    r3   r   z9_ArgumentsManager._generate_config_file.<locals>.<lambda>:  r   r5   r   >   optional argumentsr@   Commandsc                F    g | ]}t          |t          j                  |S r}   r   r   s     r3   r   z;_ArgumentsManager._generate_config_file.<locals>.<listcomp>E  r   r5   c                ,    | j         d         dd          S r   r   r   s    r3   r   z9_ArgumentsManager._generate_config_file.<locals>.<lambda>J  s    q?OPQ?RSTSUSU?V r5   r   rn   Nhide_from_config_filer[    O   )widthr   r   z =re   	new_namesc                    g | ]	}|j         
S r}   )patternr   s     r3   r   z;_ArgumentsManager._generate_config_file.<locals>.<listcomp>t  s    6661QY666r5   rZ   
py_version.c              3  4   K   | ]}t          |          V  d S r=   )r   r   s     r3   	<genexpr>z:_ArgumentsManager._generate_config_file.<locals>.<genexpr>x  s(      $;$;SVV$;$;$;$;$;$;r5   rY   )"tomlkitdocumenttableaddr   r   r.   r   rQ   r   r   r0   rR   rE   rb   r   textwrapwrapcommentr   r:   r   nldictrePatternr   listtuplejoinlowerdumpstomllibloads)r2   r   toml_doc
tool_tablepylint_tool_tabler   group_tabler   rX   r   rK   help_msg	help_textliner;   toml_strings                   r3   _generate_config_filez'_ArgumentsManager._generate_config_file-  s    #%%]$777
W[((*555#M>>>w{8,,.?@@@+66
 
 
 L	H L	HE
 {KKK ' !-//K -  N
 !5V5VWWW 6. 6. /21226"09GG   H ;;677   ?&{{6266H%h44444 (hb A A AI ) ? ?#(=(=>>>>  W__S#-F-FGG  " 6#7(G(GHHH#
555 w&&%gh&7>>>>>"gh&777  eRZ00 7!MEEe}55 7*!Hbj; ; 7 76666E ;;v&&,66HH$;$;U$;$;$;;;E  uI(>(>>> ///
----; H!%%ek&7&7&9&9;GGGmH-- 	k""";s   D
D)(D)r   r   c                    | j                             d|                    dd           t          |          g| j                  d         | _        dS )z&Set an option on the namespace object.r_   r   r   r   N)r.   ro   r   r   r:   )r2   r   r;   s      r3   
set_optionz_ArgumentsManager.set_option  sV    &77-'//#s++--/Ee/L/LMK
 
 r5   )NN)r   r   r    r!   r"   r!   r#   r$   )r#   r6   )r;   r6   r#   r$   )r>   r   r#   r$   )rA   r   rM   r!   rL   r
   r#   r$   )rU   rV   rL   r
   r#   r$   )r#   r$   )rj   rk   r#   r$   r=   )rj   rx   r#   rk   )Nr}   )r~   r   r   r   r#   r$   )r#   r   )r   r   r#   r   )r   r   r;   r   r#   r$   )__name__
__module____qualname__rF   r4   propertyr:   setterrN   rH   staticmethodrT   rI   rw   r|   r   r[   r   r   r}   r5   r3   r   r   0   s       TT NRM M M M MB    X ]   ]- - - -"9 9 9 9  L- L- L- \L-\C C C CI I I I  15
 
 
 
 
 MO; ; ; ; ;z. . . . 8= ^  ^  ^  ^  ^  ^ @     r5   r   ),rF   
__future__r   r)   r   rq   r   r   collections.abcr   typingr   r   r   r   r   r	   pylint.config.argumentr
   r   r   r   r   r   r   pylint.config.exceptionsr   r   pylint.config.help_formatterr   pylint.config.utilsr   r   pylint.constantsr   pylint.typingr   r   version_infor   tomli pylint.config.arguments_providerr   r   r}   r5   r3   <module>r      s  
 Q P " " " " " "  				 



   $ $ $ $ $ $ - - - - - - - - - -                                8 7 7 7 7 7 S S S S S S S S . . . . . . < < < < < < < <wNNNN  DCCCCCCb b b b b b b b b br5   