
    c                    F   d 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	 ej
        dk    rddlmZ nddlmZ ej
        d	k    rdd
lmZ ndd
lmZ  ed          Z e	dee          Zh dZh dZ G d de          Zd dZed!d            Zed"d            Zd#dZd$dZdS )%z&Utils for the 'pylint-config' command.    )annotationsN)Callable)Path)TypeVar)      )Literal)r   
   )	ParamSpec_P_ReturnValueT>   itinitoml>   nynoyesc                  $     e Zd ZdZd
 fd	Z xZS )InvalidUserInputz(Raised whenever a user input is invalid.valid_inputstrinput_valueargsobjectreturnNonec                P    || _         || _         t                      j        |  d S )N)validinputsuper__init__)selfr   r   r   	__class__s       Blib/python3.11/site-packages/pylint/config/_pylint_config/utils.pyr#   zInvalidUserInput.__init__"   s+     
 
$    )r   r   r   r   r   r   r   r   )__name__
__module____qualname____doc__r#   __classcell__)r%   s   @r&   r   r      sC        22                   r'   r   funcCallable[_P, _ReturnValueT]r   c                     d fd}|S )	z?Decorator that handles InvalidUserInput exceptions and retries.r   _P.argskwargs	_P.kwargsr   r   c                     d}	 	  | i |S # t           $ rb}|r-|j        dk    r"t          d           t          j                     t          d|j         d           t          d           d}Y d }~nd }~ww xY wy)NFTzexit()zStopping 'pylint-config'.zAnswer should be one of .z.Type 'exit()' if you want to exit the program.)r   r!   printsysexitr    )r   r1   called_onceexcr-   s       r&   inner_functionz8should_retry_after_invalid_input.<locals>.inner_function-   s    		##tT,V,,,# # # # 39#8 5666HJJJ====>>>FGGG"#		#s    
A:AA55A:)r   r0   r1   r2   r   r    )r-   r:   s   ` r&    should_retry_after_invalid_inputr<   (   s)    
# # # # # # r'   Literal['toml', 'ini']c                     t          d                                          } | t          vr5t          d                    t          t                              |           |                     d          rdS dS )z9Make sure that the output format is either .toml or .ini.zCPlease choose the format of configuration, (T)oml or (I)ni (.cfg): , r   r   r   )r!   lowerSUPPORTED_FORMATSr   joinsorted
startswith)format_types    r&   get_and_validate_formatrF   =   sx     M egg  ++ Rtyy0A)B)BCC[QQQc"" v5r'   questionr   defaultLiteral['yes', 'no'] | Noneboolc                   |  d} |r	| d| dz  } t          |                                           }|s|r|}|t          vr5t          d                    t          t                              |          |                    d          S )z,Validate that a yes or no answer is correct.z (y)es or (n)o z
 (default=z) r?   r   )r!   r@   YES_NO_ANSWERSr   rB   rC   rD   )rG   rH   answers      r&   validate_yes_norN   M   s     +++H -,,,,,8__""$$F g ^# Jtyy)?)?@@&IIIS!!!r'   c                 "    t          dd          S )z5Ask the user if they want to use the minimal setting.zGDo you want a minimal configuration without comments or default values?r   )rN   r;   r'   r&   get_minimal_settingrP   _   s    QSW  r'   tuple[bool, Path]c                     t          dd          } | sdt                      fS t          t          d                    }|                                rt          | dd          }|sd|fS d|fS d|fS )z*Make sure that the output file is correct.z*Do you want to write the output to a file?r   Fz What should the file be called: z4 already exists. Are you sure you want to overwrite?T)rN   r   r!   exists)to_file	file_name	overwrites      r&   get_and_validate_output_filerW   f   s    JDQQG dff} U=>>??I #NNNPT
 
	  	$)##Y?r'   )r-   r.   r   r.   )r   r=   )rG   r   rH   rI   r   rJ   )r   rJ   )r   rQ   )r+   
__future__r   r6   collections.abcr   pathlibr   typingr   version_infor	   typing_extensionsr   r   rJ   r   r   rA   rL   	Exceptionr   r<   rF   rN   rP   rW   r;   r'   r&   <module>r_      s  
 - , " " " " " " 



 $ $ $ $ $ $            v *))))))w ,       ++++++Yt__s33--- (((         y         * "   "! "" " " "!""        r'   