"Jda3dZddlZddlZddlZddlZddlmZmZmZm Z m Z m Z m Z ddl mZmZddlmZddlmZddlmZddlmZmZejZe d eZerd nd Zd Zed ddddZejej ej!ej"ej#fZ$ej ejej!fZ%ee&Z'dedefdZ(dede efdZ)deee effdZ*GddZ+dS)a Configuration management setup Some terminology: - name As written in config files. - value Value associated with a name - key Name combined with it's section (section.name) - variant A single word describing where the configuration key-value pair came from N)AnyDictIterableListNewTypeOptionalTuple)ConfigurationError!ConfigurationFileCouldNotBeLoaded)appdirs)WINDOWS) getLogger) ensure_direnumKindzpip.inizpip.conf)versionhelpuserglobalsiteenvzenv-var)USERGLOBALSITEENVENV_VARnamereturnc|dd}|dr |dd}|S)zAMake a name consistent regardless of source (environment or file)_-z--N)lowerreplace startswith)rs N/opt/alt/python311/lib/python3.11/site-packages/pip/_internal/configuration.py_normalize_namer'2sE ::<<  S ) )D tABBx Kc~d|vr$d|}t||ddS)N.zbKey does not contain dot separated section and key. Perhaps you wanted to use 'global.{}' instead?)formatr split)r error_messages r&_disassemble_keyr/:sD $ = &,, !/// ::c1  r(cdtjdD}tjt jt}tjtjdtrdndt}tjtj dt}tj |tj |gtj||giS)NcXg|]'}tj|t(S)ospathjoinCONFIG_BASENAME).0r4s r& z+get_configuration_files..Es504 T?++r(pip~z.pip)r site_config_dirsr3r4r5sysprefixr6 expanduserr user_config_dirkindsrrr)global_config_filessite_config_filelegacy_config_filenew_config_files r&get_configuration_filesrEDs8?8PQV8W8Ww||CJ@@ 3$f gll7#:5#A#A?SSO ) %& '9 r(c"eZdZdZd"dedeeddffd Zd#dZdee fdZ de e e e ffd Zd e de fd Zd e d e ddfd Zd e ddfdZd#dZd#dZedee e ffdZd#dZdede defdZde defdZd#dZde de e e e fdee e ffdZde e e e ffdZde e eee ffdZdedee e ffdZ de e effdZ!de deddfd Z"de fd!Z#xZ$S)$ ConfigurationaHandles management of configuration. Provides an interface to accessing and managing configuration files. This class converts provides an API that takes "section.key-name" style keys and stores the value associated with it as "key-name" under the section "section". This allows for a clean interface wherein the both the section and the key-name are preserved in an easy to manage form in the configuration files and the data stored is also nice. Nisolated load_onlyrc zt|V|tvrMtddt tt||_||_ dtD|_ dtD|_ g|_ dS)Nz5Got invalid value for load_only - should be one of {}z, ci|]}|gSr2r2r7variants r& z*Configuration.__init__..rs-H H H #GRH H H r(ci|]}|iSr2r2rLs r&rNz*Configuration.__init__..us'4 4 4 #GR4 4 4 r()super__init__VALID_LOAD_ONLYr r,r5mapreprrHrIOVERRIDE_ORDER_parsers_config_modified_parsers)selfrHrI __class__s r&rQzConfiguration.__init__es   Yo%E%E$GNNIIc$8899  ! "H H '5H H H  4 4 '54 4 4  EGr(ch||js|dSdS)z2 2 2$%;c%;%;<< <2244 v  ,S11MGT""7++ 060D0DWd0S0S )J <<(( /%%g...  " "5& 1 1 1 L ( - - -r(cP||jD]\}}td|t t j|t|d5}| |dddn #1swxYwYdS)z!Save the current in-memory state.z Writing to %swN) rnrXloggerinforr3r4dirnameopenwrite)rYrsrtfs r&savezConfiguration.saves ##%%%!3  ME6 KK / / / rwu-- . . .eS!! Q Q                 s8BB !B cr|jtdtd|jdS)Nz'Needed a specific file to be modifying.z$Will be working with %s variant only)rIr r}debugr^s r&rnz$Configuration._ensure_have_load_onlys6 > !$%NOO O ;T^LLLLLr(c^i}tD]"}||j|#|S)z3A dictionary representing the loaded configuration.)rUupdaterW)rYretvalrMs r&rezConfiguration._dictionarys9 % 1 1G MM$,w/ 0 0 0 0 r(ct|}|tjddtjgkrt ddS|D]q\}}|D]i}|j (||j krt d||1| ||}|j | ||fjrdS)z,Loads configuration from configuration filesrr+zZSkipping loading configuration files due to environment's PIP_CONFIG_FILE being os.devnullNz Skipping file '%s' (variant: %s)) dictiter_config_filesr@rr3devnullr}rrfrI _load_filerVappend)rY config_filesrMfilesrsrts r&r\z Configuration._load_config_filessD224455  "1Q3 'BJ< 7 7 LLA    F*0022 ? ?NGU ? ?>-'T^2K2KLL!CUGTTT%88 g&--ufo>>>> ? ? ?r(rMrsc(td||||}|D]K}||}|j||||L|S)Nz'For variant '%s', will try loading '%s')r}verbose_construct_parsersectionsrfrWr_normalized_keys)rYrMrsrtrurfs r&rzConfiguration._load_files@'5QQQ''..(( P PGLL))E L ! ( ()>)>w)N)N O O O O r(cdtj}tj|r} ||nf#t $r7tdtj d|tj $r}t|d}~wwxYw|S)Nzcontains invalid {} charactersF)reasonrs)error) configparserRawConfigParserr3r4existsreadUnicodeDecodeErrorr r,localegetpreferredencodingError)rYrsrtrs r&rzConfiguration._construct_parsers-// 7>>% E E E""""%   7;BB3E::   % E E E7eDDDD E sA AB-B((B-c|jtj|d|dS)z.Loads configuration from environment variablesz:env:N)rWr@rrrget_environ_varsr^s r&r]z$Configuration._load_environment_varssL U]#**  ! !'4+@+@+B+B C C     r(rurfcNi}|D]\}}|dzt|z}|||< |S)zNormalizes items to construct a dictionary with normalized keys. This routine is where the names become keys and are made the same regardless of source - configuration files or environment. r*)r')rYrurf normalizedrvalrgs r&rzConfiguration._normalized_keys"sC  " "ID#C-/$"7"77C!JsOOr(c#KtjD]E\}}|dr+|dd}|t vr||fVFdS)z@Returns a generator with all environmental vars with prefix PIP_PIP_N)r3environrfr%r#ENV_NAMES_IGNORED)rYrgrrs r&rzConfiguration.get_environ_vars0st ((** $ $HC~~f%% $122w}}000)OOO  $ $r(c#Ktjdd}|tj|gfVntjgfVt }tj|tjfV|j o!|otj | }|r tj |tj fVtj |tj fVdS)zYields variant and configuration files associated with it. This should be treated like items of a dictionary. PIP_CONFIG_FILEN) r3rgetr@rrErrHr4rrr)rY config_filershould_load_user_configs r&rzConfiguration.iter_config_files9sjnn%6==  ")k]* * * * *)R-   .00 lL66666'+m"3#  7BGNN;779  # 7*l5:66 6 6 6j,uz2222222r(c|j|S)z#Get values present in a config file)rW)rYrMs r&get_values_in_configz"Configuration.get_values_in_configWs|G$$r(cX|j|j}|std|dS)Nz4Fatal Internal error [id=2]. Please report as a bug.)rVrIr )rYparserss r&raz#Configuration._get_parser_to_modify[s;-/ $F  r{r(rtcX||f}||jvr|j|dSdSN)rXr)rYrsrtfile_parser_tuples r&rrzConfiguration._mark_as_modifiedis@"FO D$: : :  " ) )*; < < < < < ; :r(c0|jjd|jdS)N())rZ__name__rer^s r&__repr__zConfiguration.__repr__ns!.)AAD,<AAAAr(r)rN)%r __module__ __qualname____doc__boolrrrQr_strrcrr rrfrkrvrzrrnpropertyrrer\rrrr]rrrrrrarrr __classcell__)rZs@r&rGrGWs7  GGG(4.GDGGGGGG***** (3-(xc3h0(((( =S=S====.S......$.s.t....6     "MMMM  T#s(^   X ????.$ss,     #+E#s(O#<  c3h    $(5c?";$$$$38E$S /,B#C3333<%D%T#s(^%%%% uS/-A'B    =s=O===== B#BBBBBBBBr(rG),rrrr3r<typingrrrrrrr pip._internal.exceptionsr r pip._internal.utilsr pip._internal.utils.compatr pip._internal.utils.loggingrpip._internal.utils.miscrrrrrr6rr@rrrrrrUrRrr}r'r/rErGr2r(r&rs-   FFFFFFFFFFFFFFFFFF('''''......11111155555555.wvs&6))J%         uz5:uy%-O*elEJ6 8  ##349dDIo!6&XBXBXBXBXBXBXBXBXBXBr(