
    yIf                        d Z ddlm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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 ee
eef         ee         f         Z G d	 d
          Z G d d          ZdS )z Configuration file parser class.    )annotationsN)Path)TYPE_CHECKINGDictListTuple)_parse_rich_type_value)      )PyLinterc                  r    e Zd ZdZedd            Zedd            Zedd	            Zedd            ZdS )_RawConfParser6Class to parse various formats of configuration files.	file_pathr   returnPylintConfigFileDatac                   t          j        d          }t          | d          5 }|                    |           ddd           n# 1 swxY w Y   i }g }t                              |           }|                                D ]I}|r|                    d          s||                                         D ]\  }}|||<   |d| |gz  }J||fS )zfParse and handle errors of an ini configuration file.

        Raises ``configparser.Error``.
        )#;)inline_comment_prefixes	utf_8_sig)encodingNpylint--)	configparserConfigParseropen	read_filer   _ini_file_with_sectionssections
startswithitems)	r   parserfpconfig_contentoptionsini_file_with_sectionssectionoptionvalues	            T/var/www/piapp/venv/lib/python3.11/site-packages/pylint/config/config_file_parser.pyparse_ini_filez_RawConfParser.parse_ini_file   s?    *:NNN)k222 	!bR   	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! *,!/!G!G	!R!R(( 	2 	2G% g.@.@.J.J !'!6!6!8!8 2 2).v&MMM5112 w&&s   A		AAboolc                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   z&_RawConfParser._ini_file_with_sections5   s-     )/))4	''4u    c                   t          | d          5 }t          j        |          }ddd           n# 1 swxY w Y   	 |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 )zkParse and handle errors of a toml configuration file.

        Raises ``tomllib.TOMLDecodeError``.
        rb)modeNtoolr   r   )r   tomllibloadKeyErrorr"   
isinstancedictr	   )
r   r$   contentsections_valuesr%   r&   optvaluesconfigr*   s
             r+   parse_toml_filez_RawConfParser.parse_toml_file>   s{    )$''' 	'2l2&&G	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	'	%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&&s   377A AAPath | Noneverbosec                   | !|rt          dt          j                   i g fS t          t          j                            |                                                     } |                                 st          d|  d          |rt          d|  t          j                   | j
        dk    rt                              |           S t                              |           S )z{Parse a config file and return str-str pairs.

        Raises ``tomllib.TOMLDecodeError``, ``configparser.Error``.
        Nz1No config file found, using default configuration)filezThe config file z doesn't exist!zUsing config file z.toml)printsysstderrr   ospath
expandvars
expanduserexistsOSErrorsuffixr   r?   r,   )r   rA   s     r+   parse_config_filez _RawConfParser.parse_config_fileY   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w&&!11)<<<,,Y777r0   N)r   r   r   r   )r   r   r   r-   )r   r@   rA   r-   r   r   )	__name__
__module____qualname____doc__staticmethodr,   r   r?   rN    r0   r+   r   r      s        @@' ' ' \'*    \ ' ' ' \'4 8 8 8 \8 8 8r0   r   c                  "    e Zd ZdZddZddZdS )_ConfigurationFileParserr   rA   r-   linterr   r   Nonec                "    || _         || _        d S )N)verbose_moderW   )selfrA   rW   s      r+   __init__z!_ConfigurationFileParser.__init__w   s    #r0   r   r@   r   c                    	 t                               || j                  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.zconfig-parse-errorr   )lineargsN)
r   rN   rZ   r   Errorr5   TOMLDecodeErrorrW   add_messagestr)r[   r   es      r+   rN   z*_ConfigurationFileParser.parse_config_file{   s    	!33It?PQQQ"G$;< 	 	 	K##$8qs1vv#NNNr6MMMMMM	s   " A5-A0*A50A5N)rA   r-   rW   r   r   rX   )r   r@   r   r   )rO   rP   rQ   rR   r\   rN   rT   r0   r+   rV   rV   t   sB        @@        r0   rV   )rR   
__future__r   r   rG   rE   pathlibr   typingr   r   r   r   pylint.config.utilsr	   version_infor5   tomlipylint.lintr   rc   r   r   rV   rT   r0   r+   <module>rl      sC  
 ' & " " " " " "     				 



       3 3 3 3 3 3 3 3 3 3 3 3 6 6 6 6 6 6wNNNN %$$$$$$T#s(^T#Y67 U8 U8 U8 U8 U8 U8 U8 U8p         r0   