7i6dZddlZddlZddlZddlZddlmZmZmZm 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 d/mnt/ssd/data/python-lab/ChefSystem/venv/lib/python3.12/site-packages/pip/_internal/configuration.py_normalize_namer'2s6 ::<  S )D tABx KcPd|vrd|d}t||jddS)N.zVKey does not contain dot separated section and key. Perhaps you wanted to use 'global.z ' instead?)r split)r error_messages r&_disassemble_keyr.:s> $ 115j B !// ::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)r4global_config_filessite_config_filelegacy_config_filenew_config_files r&get_configuration_filesr@Ds8?8P8PQV8W04 T?+ww||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 formatr5mapreprrCrDOVERRIDE_ORDER_parsers_config_modified_parsers)selfrCrDvariant __class__s r&rGzConfiguration.__init__es   Yo%E$GNNIIc$89  ! "(6H #GRKH  (64 #GRK4  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: ) rgrOloggerinforr3r4dirnameopenwriteOSErrorr )rPrlrmferrors r&savezConfiguration.saves ##%!33 ME6 KK / rwwu- . %%$LLO$ $$ (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)rDr 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._dictionarys4 % 1G MM$,,w/ 0 1 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;rr3devnullrvrr^rD _load_filerMappend)rP config_filesrQfilesrlrms r&rTz Configuration._load_config_filessD2245  "1Q 'BJJ< 7 LLA  *002 ?NGU ?>>-'T^^2KLL!CUGT%8 g&--ufo> ? ?r(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 st@'5Q''.( PGLL)E LL ! ( ()>)>w)N O P 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}) configparserRawConfigParserr3r4existslocalegetpreferredencodingreadUnicodeDecodeErrorr 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!JsO "r(c#KtjjD]9\}}|jds|ddj }|t vs4||f;yw)z@Returns a generator with all environmental vars with prefix PIP_PIP_N)r3environr^r%r#ENV_NAMES_IGNORED)rPr_rrs r&rzConfiguration.get_environ_vars>sU ((* $HC~~f%12w}}00)O  $s6AA Ac#Ktjjdd}t}tj |tj f|j xr$|xrtjj| }|r%tj|tjftj|tjf|tj|gfytjgfyw)aYields variant and configuration files associated with it. This should be treated like items of a dictionary. The order here doesn't affect what gets overridden. That is controlled by OVERRIDE_ORDER. However this does control the order they are displayed to the user. It's probably most ergononmic to display things in the same order as OVERRIDE_ORDER PIP_CONFIG_FILEN) r3rgetr@r;rrCr4rrrr)rPenv_config_filershould_load_user_configs r&rzConfiguration.iter_config_filesGs**..):DA.0 llL666'+mm"3#  ? ?9  #**l5::66 6jj,uzz222  &))o.. .))R- sCc |j|S)z#Get values present in a config file)rN)rPrQs r&get_values_in_configz"Configuration.get_values_in_configgs||G$$r(ct|jsJ|j|j}|s td|dS)Nz4Fatal Internal error [id=2]. Please report as a bug.)rDrMr )rPparserss r&rYz#Configuration._get_parser_to_modifyks?~~~--/$F  r{r(rmc`||f}||jvr|jj|yyN)rOr)rPrlrmfile_parser_tuples r&rkzConfiguration._mark_as_modifiedys4"FO D$:$: :  " " ) )*; < ;r(cN|jjd|jdS)N())rR__name__r]rVs r&__repr__zConfiguration.__repr__~s'..))*!D,<,<+?qAAr(r)rN)%r __module__ __qualname____doc__boolrrrGrWstrr[rr rr^rdrorsr~rgpropertyrr]rTrrrrUrrrrrrYrkr __classcell__)rRs@r&rBrBWs GG(4.GDG** (3-(xc3h0( BS BS B.S...&.s.t.:0M  T#s(^  ?.$ss*  #+E#s(O#<  c3h $(5c?";$ 8E$S /,B#C @%D%T#s(^% uS/-A'B =s=O== B#Br(rB),rrrr3r7typingrrrrrrr pip._internal.exceptionsr r pip._internal.utilsr pip._internal.utils.compatr pip._internal.utils.loggingrpip._internal.utils.miscrrrrrr6rr;rrrrrrLrHrrvr'r.r@rBr(r&rs  FFF(.15..vs&)J%      uzz5::uyy%--O**ellEJJ6 8 ##349dDIo!6&hBhBr(