
    eF"              	      >   U d Z ddlmZ ddl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mZ ddlmZmZmZmZmZmZ dd	lmZ dd
lmZ e
rddlm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edfdedfde dfde!dfde"dfde"dfde#dfdZ$de%d<   d"dZ&y)#z1Utils for arguments/options parsing and handling.    )annotationsN)CallableSequence)Path)TYPE_CHECKINGAny)
extensionsutils)_CallableArgument_ExtendArgument_StoreArgument_StoreNewNamesArgument_StoreOldNamesArgument_StoreTrueArgument)_CallbackAction)ArgumentPreprocessingError)Runc                   d|  g}d|v r|d|d    gz  }|j                  dd      }|dk(  rQt        |||j                  dd      |j                  d	d
      |j                  dd      |j                  dd            S t        |t              srt	        |t
              rbt        |||j                  d	d
      |j                  di       |j                  dd      |j                  dd      |j                  dd            S |d   }|dk(  r|t        |||g n||d   |j                  dd      |j                  d	d
      |j                  dd
      |j                  dd      |j                  dd      |j                  dd      
      S d|v rd|d   v rwt        |||d   |j                  dd      |j                  d	d
      |j                  dd
      |j                  dd      |j                  di       |j                  dd      	      S d|d   v rwt        |||d   |j                  dd      |j                  d	d
      |j                  dd
      |j                  dd      |j                  di       |j                  dd      	      S d|v rmt        |||d   |j                  dd      |j                  d	d
      |j                  dd
      |j                  dd      d|d   gi|j                  dd      	      S t        ||||d   |j                  dd      |j                  d	d
      |j                  dd
      |j                  dd      |j                  dd      	      S )z1Convert an optdict to an Argument class instance.z--short-actionstore
store_truedefaultThelp hideFgroupN)flagsr   r   arg_help	hide_helpsectionkwargsmetavar)r   r   r    r#   r!   r"   r$   extendtypechoicesdest)
r   r   r   arg_typer'   r    r$   r!   r"   r(   	old_names)	r   r   r)   r'   r    r$   r!   r#   r"   	new_names)	r   r   r   r)   r'   r    r$   r!   r"   )getr   
isinstancestr
issubclassr   r   r   r   r   r   )optoptdictr   r   r   s        5/usr/lib/python3/dist-packages/pylint/config/utils.py_convert_option_to_argumentr3      sq    #ZLE'Agg&'()) [[7+F!KK	40[[,kk&%0KK.
 	
 fc"z&/'J [[,;;x,kk&%0KK.KK	40
 	
 i G!/BwV_KK	40[[,KK	2.kk&%0KK.VT*
 	
 7'(++) It4 VR0Ir2!++fe4{{8R0GT2
 
 '(++) It4 VR0Ir2!++fe4{{8R0GT2
 
 %V_KK	40[[,KK	2.kk&%0'&/!23KK.

 
	
 It,VR(Ir*++fe,GT*
 
    c                >   t        | t        t        f      rdj                  d | D              S t        | t        j
                        rt        | j                        S t        | t              r&dj                  d | j                         D              S t        |       S )z%Parse rich (toml) types into strings.,c              3  2   K   | ]  }t        |        y w)N)_parse_rich_type_value).0is     r2   	<genexpr>z)_parse_rich_type_value.<locals>.<genexpr>   s     Aa.q1As   c              3  0   K   | ]  \  }}| d |   yw):N )r9   kvs      r2   r;   z)_parse_rich_type_value.<locals>.<genexpr>   s     =tq!1#Qqc
=s   )
r-   listtuplejoinrePatternr.   patterndictitems)values    r2   r8   r8      sq    %$'xxA5AAA%$5==!!%xx=u{{}===u:r4   c                "    |J t        |       y)zhExecute arbitrary code from the init_hook.

    This can be used to set the 'sys.path' for example.
    N)execrunrI   s     r2   
_init_hookrN      s    
 Kr4   c                    |J || _         y)zSet the rcfile.N)_rcfilerL   s     r2   _set_rcfilerQ          CKr4   c                    |J || _         y)zSet the output.N)_outputrL   s     r2   _set_outputrU      rR   r4   c                h    |J | j                   j                  t        j                  |             y)z,Add plugins to the list of loadable plugins.N)_pluginsr%   r
   _splitstriprL   s     r2   _add_pluginsrY      s+    LL))%01r4   c                    |J d| _         y )NT)verboserL   s     r2   _set_verbose_moder\      s    ==CKr4   c                B   |J t        t        j                        j                  j	                         D ]g  }|j
                  dk(  s|j                  j                  d      r/d|j                   }|| j                  vsM| j                  j                  |       i y)zEnable all extensions.Nz.py_zpylint.extensions.)
r   r	   __file__parentiterdirsuffixstem
startswithrW   append)rM   rI   filenameextension_names       r2   _enable_all_extensionsrh      s    ==,,-44<<> 4??e#HMM,D,DS,I1(--ANS\\1##N3	4r4   T         F   	   )z--init-hookz--rcfilez--outputz--load-pluginsz	--verbosez-vz--enable-all-extensionsz>dict[str, tuple[bool, Callable[[Run, str | None], None], int]]PREPROCESSABLE_OPTIONSc                   g }d}|t        |      k  r"||   }|j                  d      s|j                  |       |dz  }<	 |j                  dd      \  }}d}t
        j                         D ]/  \  }}	|	d   }
|
dk(  r	||k(  s|}|j                  |d|
       s.|}1 ||j                  |       |dz  }t
        |   \  }}}|r>|<|dz  }|t        |      k\  s||   j                  d      rt        d| d      ||   }n|s|t        d| d	       || |       |dz  }|t        |      k  r"|S # t        $ r |d}}Y w xY w)
z;Pre-process options before full config parsing has started.r   r      =Nrl   zOption z expects a valuez doesn't expect a value)lenrd   re   split
ValueErrorrn   rH   r   )rM   argsprocessed_argsr:   argumentoptionrI   matched_optionoption_namedatato_matchtakeargcbr^   s                 r2   _preprocess_optionsr      s    "N	A
c$i-7""3'!!(+FA	+$NN32MFE !7!=!=!? 	-KAwH1}[(%0N"";y#9:!,	- !!!(+FA/?Qu}FACI~a!3!3C!8076(BR1STTGEU.,wvh>U-VWW
3	QK c$i-N =  	+$dEF	+s   D8 8EE)r0   r.   r1   zdict[str, Any]returnz{_StoreArgument | _StoreTrueArgument | _CallableArgument | _StoreOldNamesArgument | _StoreNewNamesArgument | _ExtendArgument)rI   r   r   r.   )rM   r   rI   z
str | Noner   None)rM   r   ru   zSequence[str]r   z	list[str])'__doc__
__future__r   rD   collections.abcr   r   pathlibr   typingr   r   pylintr	   r
   pylint.config.argumentr   r   r   r   r   r   pylint.config.callback_actionsr   pylint.config.exceptionsr   pylint.lint.runr   r3   r8   rN   rQ   rU   rY   r\   rh   rn   __annotations__r   r>   r4   r2   <module>r      s   
 8 " 	 .  % $  ; ?#e	e%eeP2
4* *a({A&{A&\1-*A.#Q
' %'=qA)   6,r4   