
    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
 ddlmZ ddlmZ  ej        e          Zd dZd!dZddd"dZ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                F    t          j        |           }|j        |j        fS )N)osstatst_inost_dev)r   sts     I/var/www/piapp/venv/lib/python3.11/site-packages/flake8/options/config.py	_stat_keyr      s    	B9bi    path
str | Nonec                p   t           j                            d          }	 |dk    rt          |          nd }n# t          $ r d }Y nw xY wt          |           }	 dD ]}t          j                    }t           j                            | |          }	 |                    |d           d|v sd|v r|c S Z# t          t
          j
        f$ r&}t                              d||           Y d }~d }~ww xY wt           j                            |           }t          |          }	|	|k    s|	|k    rn|} |	}d S )	N~T)z	setup.cfgztox.iniz.flake8UTF-8encodingflake8zflake8:local-pluginsz"ignoring unparseable config %s: %s)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_stats
             r   _find_config_filer1      s   7c""D'+s{{IdOOO		   			 H$< 
	$ 
	$I.00Cw||D)44H$G444
 s??&<&C&C#OOO 'D	 '(AB O O O@(ANNNNNNNNO 7??4(( **8##|y'@'@D#H'$, 4s'   9 AAB77C3C..C3F)isolatedconfigextra	list[str]r2   bool(tuple[configparser.RawConfigParser, str]c                  t           j                            d          }|rt          j                    |fS | t          |          } t          j                    }| N|                    | d          st          j        d|            t           j        	                    |           }n|}|D ]0}|                    |d          st          j        d|           1||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    r1   r"   r   ExecutionErrorr'   )r3   r4   r2   pwdr,   cfg_dirfilenames          r   load_configr?   8   s    '//#

C 3+--s22~"3''

&
(
(Cxxx11 	+EVEE   '//&))   xx7x33 	+GXGG  	
 <r   option_managerr   r,   configparser.RawConfigParserr=   dict[str, Any]c           
     t   d|vri S i }|d         D ]%}| j                             |          }|t                              d|           ;|j        t
          u s|j        dk    r|                    d|          }n6|j        dv r|                    d|          }n|                    d|          }t                              d||           |	                    ||          }|dv r;|D ]8}t          j        |          s"t          d|d	|d
t          j                  9|j        J |||j        <   '|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,   r=   config_dictoption_nameoptionvaluefinal_value
error_codes	            r   parse_configr\   b   s    s	K8} 6 6377DD>II@+NNN ;#'!9!9JJx55EE];;;NN8[99EEGGHk22E		2KGGG&&ug66555)  
(.z:: $Hj H H'2H H*;*CH H   !---*5F&''r   )r   r	   r
   r   )r   r	   r
   r   )r3   r   r4   r5   r2   r6   r
   r7   )r@   r   r,   rA   r=   r	   r
   rB   )__doc__
__future__r   r   loggingos.pathr   typingr   r   r   flake8.defaultsr   flake8.options.managerr   	getLogger__name__r%   r   r1   r?   r\    r   r   <module>rg      s    ' ' " " " " " "                   - - - - - - 0 0 0 0 0 0g!!          L 	' ' ' ' ' 'T* * * * * *r   