o
    h                     @  s   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
 ddlmZ ddlmZ eeZd$ddZd%ddZddd&ddZd'd"d#ZdS )(z!Config handling logic for Flake8.    )annotationsN)Any)
exceptions)VALID_CODE_PREFIX)OptionManagersstrreturntuple[int, int]c                 C  s   t | }|j|jfS )N)osstatst_inost_dev)r   st r   K/var/www/html/ai/venv/lib/python3.10/site-packages/flake8/options/config.py	_stat_key   s   
r   path
str | Nonec           
      C  s   t jd}z|dkrt|nd }W n ty   d }Y nw t| }	 dD ]?}t }t j| |}z	|j|dd W n t	tj
fyW } ztd|| W Y d }~q%d }~ww d|v s`d|v rd|  S q%t j| }t|}	|	|ksw|	|krz	 d S |} |	}q#)	N~T)z	setup.cfgztox.iniz.flake8UTF-8encodingz"ignoring unparseable config %s: %sflake8zflake8:local-plugins)r   r   
expanduserr   OSErrorconfigparserRawConfigParserjoinreadUnicodeDecodeErrorParsingErrorLOGwarningdirname)
r   home	home_statdir_stat	candidatecfgcfg_pathenew_pathnew_dir_statr   r   r   _find_config_file   s8   r.   F)isolatedconfigextra	list[str]r/   bool(tuple[configparser.RawConfigParser, str]c                C  s   t jd}|rt |fS | du rt|} t }| dur4|j| dds-td|  t j	| }n|}|D ]}|j|ddsItd| q8||fS )a@  Load the configuration given the user options.

    - in ``isolated`` mode, return an empty configuration
    - if a config file is given in ``config`` use that, otherwise attempt to
      discover a configuration using ``tox.ini`` / ``setup.cfg`` / ``.flake8``
    - finally, load any ``extra`` configuration files
    .Nr   r   z*The specified config file does not exist: )
r   r   abspathr   r   r.   r   r   ExecutionErrorr$   )r0   r1   r/   pwdr)   cfg_dirfilenamer   r   r   load_config8   s(   r;   option_managerr   r)   configparser.RawConfigParserr9   dict[str, Any]c           	   	   C  s   d|vri S i }|d D ]k}| j |}|du rtd| q|jtu s)|jdkr0|d|}n|jdv r<|d|}n|d|}td|| |	||}|dv rk|D ]}t
|sjtd|d	|d
t
jqU|jdusrJ |||j< q|S )z4Parse and normalize the typed configuration options.r   Nz(Option "%s" is not registered. Ignoring.count>   
store_truestore_falsezOption "%s" returned value: %r>   extend-ignoreignorezError code z supplied to z option does not match )config_options_dictgetr"   debugtypeintactiongetint
getboolean	normalizer   match
ValueErrorpatternconfig_name)	r<   r)   r9   config_dictoption_nameoptionvaluefinal_value
error_coder   r   r   parse_configb   s:   

rW   )r   r   r	   r
   )r   r   r	   r   )r0   r   r1   r2   r/   r3   r	   r4   )r<   r   r)   r=   r9   r   r	   r>   )__doc__
__future__r   r   loggingos.pathr   typingr   r   r   flake8.defaultsr   flake8.options.managerr   	getLogger__name__r"   r   r.   r;   rW   r   r   r   r   <module>   s    


&*