
    c                        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mZ ddl	m
Z
 ddl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 )z Configuration file parser class.    )annotationsN)Path)TYPE_CHECKING)_parse_rich_type_value)      )PyLinterc                  J    e Zd ZdZddZddZedd            ZddZddZ	dS )_ConfigurationFileParserz6Class to parse various formats of configuration files.verboseboollinterr	   returnNonec                "    || _         || _        d S )N)verbose_moder   )selfr   r   s      @lib/python3.11/site-packages/pylint/config/config_file_parser.py__init__z!_ConfigurationFileParser.__init__   s    #    	file_pathr    tuple[dict[str, str], list[str]]c                    t          j        d          }t          |d          5 }|                    |           ddd           n# 1 swxY w Y   i }g }|                                D ]}|                     |          rI|                    d          s4|                                dk    rt          j	        dt                     n`||                                         D ]\  }}|||<   |d	| |gz  }||fS )
z4Parse and handle errors of a ini configuration file.)#;)inline_comment_prefixes	utf_8_sig)encodingNpylintmasterzThe use of 'MASTER' or 'master' as configuration section for pylint has been deprecated, as it's bad practice to not start sections titles with the tool name. Please use 'pylint.main' instead.--)configparserConfigParseropen	read_filesections_ini_file_with_sections
startswithlowerwarningswarnUserWarningitems)	r   r   parserfpconfig_contentoptionssectionoptvalues	            r   _parse_ini_filez(_ConfigurationFileParser._parse_ini_file"   s}   *:NNN )k222 	!bR   	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! *,(( 	/ 	/G++I66 w?Q?Q@ @  ==??h. 	MG $	    $Wo3355 / /
U&+s#JJJ../ w&&s   A		AAc                2    d| j         v rdS d| j         v rdS dS )z&Return whether the file uses sections.z	setup.cfgTztox.iniF)parts)r   s    r   r'   z0_ConfigurationFileParser._ini_file_with_sections?   s1     )/) 	4	' 	4ur   c                x   	 t          |d          5 }t          j        |          }ddd           n# 1 swxY w Y   nJ# t          j        $ r8}| j                            ddt          |                     i g fcY d}~S d}~ww xY w	 |d         d         }n# t          $ r i g fcY S w xY wi }g }|                                D ]q\  }}	t          |	t                    r9|	                                D ]#\  }
}t          |          }|||
<   |d	|
 |gz  }$St          |	          }	|	||<   |d	| |	gz  }r||fS )
z5Parse and handle errors of a toml configuration file.rb)modeNconfig-parse-errorr   lineargstoolr   r!   )r$   tomllibloadTOMLDecodeErrorr   add_messagestrKeyErrorr-   
isinstancedictr   )r   r   r/   contentesections_valuesr0   r1   r3   valuesconfigr4   s               r   _parse_toml_filez)_ConfigurationFileParser._parse_toml_fileH   s   	id+++ +r!,r**+ + + + + + + + + + + + + + +& 	 	 	K##$8qs1vv#NNNr6MMMMMM		%foh7OO 	 	 	r6MMM	 *,*0022 		0 		0KC&$'' 0%+\\^^ 6 6MFE2599E-2N6*Vu55GG6
 077&,s#JJJ//w&&sJ   A  4A  8A  8A   B-B<BBB B+*B+Path | Nonec                ~   |&| j         rt          dt          j                   i g fS t	          t
          j                            |                                                    }|	                                st          d| d          | j         rt          d| t          j                   	 |j        dk    r|                     |          S |                     |          S # t          j        t           j        f$ r8}| j                            dd	t)          |          
           i g fcY d}~S d}~ww xY w)z-Parse a config file and return str-str pairs.Nz1No config file found, using default configuration)filezThe config file z doesn't exist!zUsing config file z.tomlr;   r   r<   )r   printsysstderrr   ospath
expandvars
expanduserexistsOSErrorsuffixrM   r5   r"   Errorr@   rB   r   rC   rD   )r   r   rI   s      r   parse_config_filez*_ConfigurationFileParser.parse_config_filed   s`     	  Gcj    r6M++I6677BBDD	!! 	IGYGGGHHH 	E2y22DDDD	7* 8,,Y777''	222"G$;< 	 	 	K##$8qs1vv#NNNr6MMMMMM	s$   4C) C) )D<-D71D<7D<N)r   r   r   r	   r   r   )r   r   r   r   )r   r   r   r   )r   rN   r   r   )
__name__
__module____qualname____doc__r   r5   staticmethodr'   rM   r\    r   r   r   r      s        @@   ' ' ' ':    \' ' ' '8     r   r   )r`   
__future__r   r"   rT   rR   r*   pathlibr   typingr   pylint.config.utilsr   version_infor@   tomlipylint.lintr	   r   rb   r   r   <module>rj      s   
 ' & " " " " " "     				 



                    6 6 6 6 6 6w NNNN %$$$$$$a a a a a a a a a ar   