
    yIfN                       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	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)LiteralTypeVar)   
   )	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       V/var/www/piapp/venv/lib/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   r0   called_onceexcr,   s       r%   inner_functionz8should_retry_after_invalid_input.<locals>.inner_function(   s    		##tT,V,,,# # # # 39#8#85666HJJJ====>>>FGGG"#		#s    
A:AA55A:)r   r/   r0   r1   r   r    )r,   r9   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_formatrE   8   su     M egg  +++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   rA   rB   rC   )rF   rG   answers      r%   validate_yes_norM   H   s     +++H -,,,,,8__""$$F g ^##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   )rM   r:   r&   r%   get_minimal_settingrO   Z   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)rM   r   r    exists)to_file	file_name	overwrites      r%   get_and_validate_output_filerV   a   s    JDQQG dff} U=>>??I #NNNPT
 
	  	$)##Y?r&   )r,   r-   r   r-   )r   r<   )rF   r   rG   rH   r   rI   )r   rI   )r   rP   )r*   
__future__r   r5   collections.abcr   pathlibr   typingr   r   version_infor
   typing_extensionsr   rI   r   r   r@   rK   	Exceptionr   r;   rE   rM   rO   rV   r:   r&   r%   <module>r^      s  
 - , " " " " " " 



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