
    4Քh8                       S r SSKJr  SSKrSSKrSSKrSSKrSSKJr  SSK	J
r
Jr  SSKJrJr  SSKJr  SSKJr  SS	KJr  SS
KJrJr  \R0                  r\" S\5      r\(       a  SOSrSr\" SSSSSS9r\R<                  \R>                  \R@                  \RB                  \RD                  4r#\R>                  \R<                  \R@                  4r$\" \%5      r&SS jr'SS jr(SS jr) " S S5      r*g)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
    )annotationsN)Iterable)AnyNewType)ConfigurationError!ConfigurationFileCouldNotBeLoaded)appdirs)WINDOWS)	getLogger)
ensure_direnumKindzpip.inizpip.conf)versionhelpuserglobalsiteenvzenv-var)USERGLOBALSITEENVENV_VARc                |    U R                  5       R                  SS5      n U R                  S5      (       a  U SS n U $ )zAMake a name consistent regardless of source (environment or file)_-z--   N)lowerreplace
startswith)names    S/var/www/auris/envauris/lib/python3.13/site-packages/pip/_internal/configuration.py_normalize_namer#   5   s9    ::<S)DtABxK    c                T    SU ;  a  SU  S3n[        U5      eU R                  SS5      $ )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>    
$115jB 	 !//::c1r$   c                 v   [         R                  " S5       V s/ s H'  n [        R                  R	                  U [
        5      PM)     nn [        R                  R	                  [        R                  [
        5      n[        R                  R	                  [        R                  R                  S5      [        (       a  SOS[
        5      n[        R                  R	                  [         R                  " S5      [
        5      n[        R                  U[        R                  U/[        R                  X4/0$ s  sn f )Npip~z.pip)r	   site_config_dirsospathjoinCONFIG_BASENAMEsysprefix
expanduserr
   user_config_dirkindsr   r   r   )r0   global_config_filessite_config_filelegacy_config_filenew_config_files        r"   get_configuration_filesr<   G   s    8?8P8PQV8W8WT?+8W   ww||CJJ@
3f
 ggll7#:#:5#A?SO)

%&

'9 s   .D6c                    ^  \ rS rSrSrSSU 4S jjjrSS jrSS jrSS jrSS jr	SS jr
S S	 jrSS
 jrSS jr\S!S j5       rSS jrS"S jrS#S jrSS jr      S$S jrS%S jrS&S jrS'S jrS(S jrS)S jrS*S jrSrU =r$ )+ConfigurationZ   a  Handles 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.
c           
     \  > [         TU ]  5         UbE  U[        ;  a;  [        SR	                  SR                  [        [        [        5      5      5      5      eXl        X l	        [         Vs0 s H  o3/ _M     snU l        [         Vs0 s H  o30 _M     snU l        / U l        g s  snf s  snf )Nz5Got invalid value for load_only - should be one of {}z, )super__init__VALID_LOAD_ONLYr   formatr1   mapreprisolated	load_onlyOVERRIDE_ORDER_parsers_config_modified_parsers)selfrG   rH   variant	__class__s       r"   rB   Configuration.__init__h   s     Yo%E$GNNIIc$89 
 !" (6H
'5GRK~H
 (6?
'5GRK~?
 EGH
?
s   ,B$B)c                h    U R                  5         U R                  (       d  U R                  5         gg)z<Loads configuration from configuration files and environmentN)_load_config_filesrG   _load_environment_varsrM   s    r"   loadConfiguration.load}   s&    !}}'') r$   c                r    U R                   c   S5       e U R                  5       S   $ ! [         a     gf = f)z7Returns the file with highest priority in configurationNz)Need to be specified a file to be editingr   )rH   _get_parser_to_modify
IndexErrorrT   s    r"   get_file_to_editConfiguration.get_file_to_edit   sC    ~~)V+VV)	--/22 		s   ) 
66c                6    U R                   R                  5       $ )zPReturns key-value pairs like dict.items() representing the loaded
configuration
)_dictionaryitemsrT   s    r"   r^   Configuration.items   s     %%''r$   c                    Un[        U5      n 0 nU R                  R                  5        H  nUR                  U5        M     X1   $ ! [         a    [        U5        [        SU 35      ef = f)z#Get a value from the configuration.No such key - )r#   r]   valuesupdateKeyErrorr*   r   )rM   keyorig_keyclean_configfile_valuess        r"   	get_valueConfiguration.get_value   sy    c"		B+-L#//668##K0  9$$ 	B S!$~hZ%@AA		Bs   7A $A+c                   [        U5      nU R                  5         U R                  (       d   eU R                  5       u  p4UbF  [	        U5      u  pVUR                  U5      (       d  UR                  U5        UR                  XVU5        U R                  U R                     R                  U0 5        X R                  U R                     U   U'   U R                  X45        g)z$Modify a value in the configuration.N)r#   _ensure_have_load_onlyrH   rX   r*   has_sectionadd_sectionsetrK   
setdefault_mark_as_modified)rM   re   valuefnameparsersectionr!   s          r"   	set_valueConfiguration.set_value   s    c"##%~~~224,S1MG %%g..""7+JJwe,T^^$//r:38T^^$U+C0u-r$   c                   Un[        U5      nU R                  5         U R                  (       d   eU R                  5       u  p4XR                  U R                     U   ;  a*  XR                  U R                     ;  a  [        SU 35      eUb|  [        U5      u  pVUR                  U5      (       a  UR                  XV5      (       d  [        S5      eUR                  U5      (       d  UR                  U5        U R                  X45         U R                  U R                     U   U	 g! [         a    U R                  U R                     U	  gf = f)z#Unset a value in the configuration.ra   Nz4Fatal Internal error [id=1]. Please report as a bug.)r#   rl   rH   rX   rK   r   r*   rm   remove_optionr^   remove_sectionrq   rd   )rM   re   rf   rs   rt   ru   r!   s          r"   unset_valueConfiguration.unset_value   s-   c"##%~~~224 ||DNN3E::<<77$~hZ%@AA,S1MG""7++0D0DW0S0S )J 
 <<((%%g.""51	2T^^,U3C8 	2T^^,S1	2s   D* *$EEc                   U R                  5         U R                   Hj  u  p[        R                  SU5        [	        [
        R                  R                  U5      5         [        US5       nUR                  U5        SSS5        Ml     g! , (       d  f       M~  = f! [         a  n[        SU SU 35      eSnAff = f)z!Save the current in-memory state.zWriting to %swNz:An error occurred while writing to the configuration file z: )rl   rL   loggerinfor   r/   r0   dirnameopenwriteOSErrorr   )rM   rs   rt   ferrors        r"   saveConfiguration.save   s    ##%!33MEKK/ rwwu-.%%LLO &% 4 &% (PgRw( s6   !B-B?B
B	BB
B>(B99B>c                t    U R                   c  [        S5      e[        R                  SU R                   5        g )Nz'Needed a specific file to be modifying.z$Will be working with %s variant only)rH   r   r   debugrT   s    r"   rl   $Configuration._ensure_have_load_only   s+    >>!$%NOO;T^^Lr$   c                `    0 n[          H!  nUR                  U R                  U   5        M#     U$ )z3A dictionary representing the loaded configuration.)rI   rc   rK   )rM   retvalrN   s      r"   r]   Configuration._dictionary   s/    
 %GMM$,,w/0 & r$   c                   [        U R                  5       5      nU[        R                     SS [        R
                  /:X  a  [        R                  S5        gUR                  5        Hr  u  p#U Hg  nU R                  b'  X R                  :w  a  [        R                  SXB5        M7  U R                  X$5      nU R                  U   R                  XE45        Mi     Mt     g)z,Loads configuration from configuration filesr   r'   zZSkipping loading configuration files due to environment's PIP_CONFIG_FILE being os.devnullNz Skipping file '%s' (variant: %s))dictiter_config_filesr7   r   r/   devnullr   r   r^   rH   
_load_filerJ   append)rM   config_filesrN   filesrs   rt   s         r"   rR    Configuration._load_config_files   s    D2245		"1Q'BJJ<7LLA *002NG >>-'^^2KLL!CUT8 g&--uo>  3r$   c                B   [         R                  SX5        U R                  U5      nUR                  5        Hc  nUR	                  U5      nU R
                  U   R                  U0 5        U R
                  U   U   R                  U R                  XE5      5        Me     U$ )Nz'For variant '%s', will try loading '%s')	r   verbose_construct_parsersectionsr^   rK   rp   rc   _normalized_keys)rM   rN   rs   rt   ru   r^   s         r"   r   Configuration._load_file  s    @'Q''.(GLL)ELL!,,UB7LL!%(//0E0Eg0UV )
 r$   c                @   [         R                  " 5       n[        R                  R	                  U5      (       a(  [
        R                  " S5      n UR                  XS9  U$ U$ ! [         a    [        SU S3US9e[         R                   a  n[        US9eS nAff = f)NF)encodingzcontains invalid z characters)reasonrs   )r   )configparserRawConfigParserr/   r0   existslocalegetpreferredencodingreadUnicodeDecodeErrorr   Error)rM   rs   rt   locale_encodingr   s        r"   r   Configuration._construct_parser"  s    --/
 77>>%  $99%@O
EE< v & 7..?{K   %% E7eDDEs   A$ $+B	BBc                    U R                   [        R                     R                  S0 5        U R                   [        R                     S   R	                  U R                  SU R                  5       5      5        g)z.Loads configuration from environment variablesz:env:N)rK   r7   r   rp   rc   r   get_environ_varsrT   s    r"   rS   $Configuration._load_environment_vars7  sX    U]]#..w;U]]#G,33!!'4+@+@+BC	
r$   c                J    0 nU H  u  pEUS-   [        U5      -   nXSU'   M     U$ )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#   )rM   ru   r^   
normalizedr!   valre   s          r"   r   Configuration._normalized_keys>  s7     
IDC-/$"77C!sO  r$   c              #     #    [         R                  R                  5        HA  u  pUR                  S5      (       d  M  USS R	                  5       nU[
        ;  d  M<  X24v   MC     g7f)z@Returns a generator with all environmental vars with prefix PIP_PIP_   N)r/   environr^   r    r   ENV_NAMES_IGNORED)rM   re   r   r!   s       r"   r   Configuration.get_environ_varsL  sN     

((*HC~~f%%12w}}00)O	 +s   8A'A'
A'c              #  0  #    [         R                  R                  SS5      n[        5       n[        R
                  U[        R
                     4v   U R                  (       + =(       a-    U=(       a    [         R                  R                  U5      (       + nU(       a%  [        R                  U[        R                     4v   [        R                  U[        R                     4v   Ub  [        R                  U/4v   g[        R                  / 4v   g7f)a`  Yields 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 ergonomic to display
things in the same order as OVERRIDE_ORDER
PIP_CONFIG_FILEN)r/   r   getr<   r7   r   rG   r0   r   r   r   r   )rM   env_config_filer   should_load_user_configs       r"   r   Configuration.iter_config_filesU  s      **..):DA.0llL666 '+mm"3 #
? ?9
 #**l5::666 jj,uzz222&))o...))R-s   DDc                     U R                   U   $ )z#Get values present in a config file)rK   )rM   rN   s     r"   get_values_in_config"Configuration.get_values_in_configu  s    ||G$$r$   c                    U R                   (       d   eU R                  U R                      nU(       d  [        S5      eUS   $ )Nz4Fatal Internal error [id=2]. Please report as a bug.)rH   rJ   r   )rM   parserss     r"   rX   #Configuration._get_parser_to_modifyy  s?    ~~~--/$F 
 r{r$   c                `    X4nX0R                   ;  a  U R                   R                  U5        g g N)rL   r   )rM   rs   rt   file_parser_tuples       r"   rq   Configuration._mark_as_modified  s0    "O$:$::""))*;< ;r$   c                P    U R                   R                   SU R                  < S3$ )N())rO   __name__r]   rT   s    r"   __repr__Configuration.__repr__  s'    ..))*!D,<,<+?qAAr$   )rK   rL   rJ   rG   rH   r   )rG   boolrH   zKind | NonereturnNone)r   r   )r   z
str | None)r   Iterable[tuple[str, Any]])re   strr   r   )re   r   rr   r   r   r   )re   r   r   r   )r   zdict[str, dict[str, Any]])rN   r   rs   r   r   r   )rs   r   r   r   )ru   r   r^   r   r   dict[str, Any])r   zIterable[tuple[str, str]])r   z Iterable[tuple[Kind, list[str]]])rN   r   r   r   )r   ztuple[str, RawConfigParser])rs   r   rt   r   r   r   )r   r   )r   
__module____qualname____firstlineno____doc__rB   rU   rZ   r^   ri   rv   r{   r   rl   propertyr]   rR   r   r   rS   r   r   r   r   rX   rq   r   __static_attributes____classcell__)rO   s   @r"   r>   r>   Z   s    G G**(B.( 2D0M
 	 	?.	*
#<	$ @%=
B Br$   r>   )r!   r   r   r   )r!   r   r   z	list[str])r   zdict[Kind, list[str]])+r   
__future__r   r   r   r/   r3   collections.abcr   typingr   r   pip._internal.exceptionsr   r   pip._internal.utilsr	   pip._internal.utils.compatr
   pip._internal.utils.loggingr   pip._internal.utils.miscr   r   r   r   r   r2   r   r7   r   r   r   r   r   rI   rC   r   r   r#   r*   r<   r>    r$   r"   <module>r      s    #   	 
 $  ( . 1 5..vs&)J%  				 uzz5::uyy%--O**ellEJJ6	8	&sB sBr$   