R`i6dZddlZddlZddlZddlZddlmZmZmZm Z m Z m Z m Z ddl mZmZddlmZddlmZddlmZddlmZmZej2Ze d eZerd nd Zd Zed ddddZej>ej@ejBejDejFfZ$ej@ej>ejBfZ%ee&Z'dedefdZ(dede efdZ)deee effdZ*GddZ+y)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_VARnamereturncr|jjdd}|jdr|dd}|S)zAMake a name consistent regardless of source (environment or file)_-z--N)lowerreplace startswith)rs /builddir/build/BUILDROOT/alt-python312-pip-23.3.1-3.el8.x86_64/opt/alt/python312/lib/python3.12/site-packages/pip/_internal/configuration.py_normalize_namer'2s6 ::<  S )D tABx Kcfd|vrdj|}t||jddS)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/:s: $ = &, !// ::c1 r(cdtjdDcgc]&}tjj |t (}}tjj t jt }tjj tjjdtrdndt }tjj tjdt }tj|tj|gtj||giScc}w)Npip~z.pip)r site_config_dirsospathjoinCONFIG_BASENAMEsysprefix expanduserr user_config_dirkindsrrr)r5global_config_filessite_config_filelegacy_config_filenew_config_files r&get_configuration_filesrADs8?8P8PQV8W8W T?+8Www||CJJ@ 3f ggll7#:#:5#A?SO ) %& '9 s+D-ceZdZdZd"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 Rt||C|tvr;tdj dj t tt||_||_ tDcic]}|gc}|_ tDcic]}|ic}|_ g|_ ycc}wcc}w)Nz5Got invalid value for load_only - should be one of {}z, )super__init__VALID_LOAD_ONLYr r,r6mapreprrDrEOVERRIDE_ORDER_parsers_config_modified_parsers)selfrDrEvariant __class__s r&rHzConfiguration.__init__es   Yo%E$GNNIIc$89  ! "(6H '5GGRK~H  (64 '5GGRK~4  EG H 4 s + B B$c^|j|js|jyy)z>2 2$~hZ%@A A224 v  ,S1MGT""7+0D0DWd0S)J <<(%%g.  " "5& 1 LL ( -r(cr|j|jD]j\}}tjd|t t j j| t|d5}|j|dddly#1swY xYw#t$r}td|d|d}~wwxYw)z!Save the current in-memory state.z Writing to %swNz:An error occurred while writing to the configuration file z: ) rgrOloggerinforr4r5dirnameopenwriteOSErrorr )rPrlrmferrors r&savezConfiguration.saves ##%!33ME6 KK / rwwu- . %%LLO&4&% (PgRw( s0" B.B B B B B6 B11B6cr|j tdtjd|jy)Nz'Needed a specific file to be modifying.z$Will be working with %s variant only)rEr rvdebugrVs r&rgz$Configuration._ensure_have_load_onlys+ >> !$%NO O ;T^^Lr(c\i}tD] }|j|j|"|S)z3A dictionary representing the loaded configuration.)rLupdaterN)rPretvalrQs r&r]zConfiguration._dictionarys/ %G MM$,,w/ 0& r(ct|j}|tjddtj gk(rt jdy|jD]q\}}|D]g}|j'||jk7rt jd||6|j||}|j|j||fisy)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<rr4devnullrvrr^rE _load_filerMappend)rP config_filesrQfilesrlrms r&rTz Configuration._load_config_filessD2245  "1Q 'BJJ< 7 LLA  *002NGU>>-'T^^2KLL!CUGT%8 g&--ufo>3r(rQrlctjd|||j|}|jD]A}|j |}|j |j |j||C|S)Nz'For variant '%s', will try loading '%s')rvverbose_construct_parsersectionsr^rNr_normalized_keys)rPrQrlrmrnr^s r&rzConfiguration._load_file sm@'5Q''.(GLL)E LL ! ( ()>)>w)N O) r(cBtj}tjj |r+t j d} |j|||S|S#t$rtd|d|tj$r}t|d}~wwxYw)NF)encodingzcontains invalid z characters)reasonrl)r}) configparserRawConfigParserr4r5existslocalegetpreferredencodingreadUnicodeDecodeErrorr Error)rPrlrmlocale_encodingr}s r&rzConfiguration._construct_parsers--/ 77>>% $99%@O E EO < v & 7..?{K %% E7eDD Es A!!,B BBc|jtjj|j d|j y)z.Loads configuration from environment variablesz:env:N)rNr<rrrget_environ_varsrVs r&rUz$Configuration._load_environment_vars*s6 U]]#**  ! !'4+@+@+B C r(rnr^cJi}|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')rPrnr^ normalizedrvalr_s r&rzConfiguration._normalized_keys0s; ID#C-/$"77C!JsOr(c#KtjjD]9\}}|jds|ddj }|t vs4||f;yw)z@Returns a generator with all environmental vars with prefix PIP_PIP_N)r4environr^r%r#ENV_NAMES_IGNORED)rPr_rrs r&rzConfiguration.get_environ_vars>sP ((*HC~~f%12w}}00)O +s6AA Ac#Ktjjdd}|tj|gfntjgft }tj |tj f|j xr$|xrtjj| }|r%tj|tjftj|tjfyw)zYields variant and configuration files associated with it. This should be treated like items of a dictionary. PIP_CONFIG_FILEN) r4rgetr<rrArrDr5rrr)rP config_filershould_load_user_configs r&rzConfiguration.iter_config_filesGsjjnn%6=  "))k]* *))R- .0 llL666'+mm"3#  7BGGNN;79  #**l5::66 6jj,uzz222sCc |j|S)z#Get values present in a config file)rN)rPrQs r&get_values_in_configz"Configuration.get_values_in_configes||G$$r(ct|jsJ|j|j}|s td|dS)Nz4Fatal Internal error [id=2]. Please report as a bug.)rErMr )rPparserss r&rYz#Configuration._get_parser_to_modifyis?~~~--/$F  r{r(rmc`||f}||jvr|jj|yyN)rOr)rPrlrmfile_parser_tuples r&rkzConfiguration._mark_as_modifiedws4"FO D$:$: :  " " ) )*; < ;r(cN|jjd|jdS)N())rR__name__r]rVs r&__repr__zConfiguration.__repr__|s'..))*!D,<,<+?qAAr(r)rN)%r __module__ __qualname____doc__boolrrrHrWstrr[rr rr^rdrorsr~rgpropertyrr]rTrrrrUrrrrrrYrkr __classcell__)rRs@r&rCrCWs GG(4.GDG** (3-(xc3h0( BS BS B.S...&.s.t.:0M  T#s(^  ?.$ss*  #+E#s(O#<  c3h $(5c?";$38E$S /,B#C3<%D%T#s(^% uS/-A'B =s=O== B#Br(rC),rrrr4r8typingrrrrrrr pip._internal.exceptionsr r pip._internal.utilsr pip._internal.utils.compatr pip._internal.utils.loggingrpip._internal.utils.miscrrrrrr7rr<rrrrrrLrIrrvr'r/rArCr(r&rs  FFF(.15..vs&)J%      uzz5::uyy%--O**ellEJJ6 8 ##349dDIo!6&fBfBr(