
    g                        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y)z!Config handling logic for Flake8.    )annotationsN)Any)
exceptions)VALID_CODE_PREFIX)OptionManagerc                \    t        j                  |       }|j                  |j                  fS )N)osstatst_inost_dev)ssts     X/var/www/html/brdwt/brdwt/brdwtenv/lib/python3.12/site-packages/flake8/options/config.py	_stat_keyr      s"    	B99bii    c                F   t         j                  j                  d      }	 |dk7  rt        |      nd }t        |       }	 dD ]V  }t        j                         }t         j                  j                  | |      }	 |j                  |d       d|v sd|v sT|c S  t         j                  j                  |       }t        |      }	|	|k(  s|	|k(  r	 y |} |	}# t        $ r d }Y w xY w# t        t
        j                  f$ r!}t        j                  d||       Y d }~d }~ww xY w)N~)z	setup.cfgztox.iniz.flake8UTF-8encodingflake8zflake8:local-pluginsz"ignoring unparseable config %s: %s)r	   path
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_filer-      s$   77c"D'+s{IdO	 H
< 
	$I..0Cww||D)4H$G4
 s?&<&C#O
	$ 77??4( *8#|y'@ 	 D#H' 	  	 '(A(AB O@(ANNOs)   C 9C&C#"C#&D ?DD F)isolatedc                  t         j                  j                  d      }|rt        j                         |fS | t        |      } t        j                         }| K|j                  | d      st        j                  d|        t         j                  j                  |       }n|}|D ]-  }|j                  |d      rt        j                  d|        ||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
    .r   r   z*The specified config file does not exist: )
r	   r   abspathr   r   r-   r   r   ExecutionErrorr#   )configextrar.   pwdr(   cfg_dirfilenames          r   load_configr8   8   s     ''//#
C++-s22~"3'

&
&
(Cxxx1++<VHE  ''//&)  xx7x3++<XJG  <r   c           
     t   d|vri S i }|d   D ]&  }| j                   j                  |      }|t        j                  d|       8|j                  t
        u s|j                  dk(  r|j                  d|      }n3|j                  dv r|j                  d|      }n|j                  d|      }t        j                  d||       |j                  ||      }|dv r>|D ]9  }t        j                  |      rt        d|d|d	t        j                         |j                  J |||j                  <   ) |S )
z4Parse and normalize the typed configuration options.r   z(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)	option_managerr(   r6   config_dictoption_nameoptionvaluefinal_value
error_codes	            r   parse_configrS   b   sV    s	K8} 63377D>II@+N ;;#'!9JJx5E]];;NN8[9EGGHk2E		2KG&&ug655) 
(..z:$%j^ 4''2o 6**;*C*C)FH  !!---*5F&&';6> r   )r   strreturnztuple[int, int])r   rT   rU   
str | None)r3   rV   r4   z	list[str]r.   boolrU   z(tuple[configparser.RawConfigParser, str])rL   r   r(   zconfigparser.RawConfigParserr6   rT   rU   zdict[str, Any])__doc__
__future__r   r   loggingos.pathr	   typingr   r   r   flake8.defaultsr   flake8.options.managerr   	getLogger__name__r!   r   r-   r8   rS    r   r   <module>rb      s    ' "      - 0g! L 	''' 	'
 .'T*!*	%* * 	*r   