Ë
    ‹¤ëjO@  ã                  óò  — 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mZ ddlmZ dd	lmZ dd
lmZmZ ddlmZ ej0                  ZerdndZdZ G d„ dee	«      Zej:                  ej<                  ej>                  ej@                  ejB                  fZ"ej<                  ej:                  ej>                  fZ# ee$«      Z%dd„Z&dd„Z'dd„Z( G d„ dej0                  «      Z) G d„ d«      Z*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
é    )ÚannotationsN)ÚIterable)ÚEnum)ÚAny)ÚConfigurationErrorÚ!ConfigurationFileCouldNotBeLoaded)Úappdirs)Ú	getLogger)ÚWINDOWSÚget_locale_encoding)Ú
ensure_dirzpip.inizpip.conf)ÚversionÚhelpc                  óT   — e Zd ZdZdZdZdZdZdZe	j                  Z
e	j                  Zy)ÚKindzAConfiguration sources, including files and environment variables.ÚuserÚglobalÚsiteÚenvzenv-varN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__ÚUSERÚGLOBALÚSITEÚENVÚENV_VARÚstrÚ__str__Ú__repr__© ó    úh/home/oem/CyberBrain26-unified/dev-env/.venv/lib/python3.12/site-packages/pip/_internal/configuration.pyr   r   (   s0   „ ÙKà€DØ€FØ€DØ
€CØ€Gà�k‰k€GØ�|‰|�Hr#   r   c                óh   — | j                  «       j                  dd«      } | j                  d«      } | S )zAMake a name consistent regardless of source (environment or file)Ú_ú-z--)ÚlowerÚreplaceÚremoveprefix)Únames    r$   Ú_normalize_namer,   <   s/   € à�:‰:‹<×Ñ  SÓ)€DØ×Ñ˜TÓ"€DØ€Kr#   c                óP   — d| vrd| › d�}t        |«      ‚| j                  dd«      S )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_keyr2   C   s>   € Ø
�$�ð1Ø15°°jðBð 	ô ! Ó/Ð/Ø�:‰:�c˜1ÓÐr#   c                 ód  — t        j                  d«      D � cg c]&  } t        j                  j	                  | t
        «      ‘Œ( }} t        j                  j	                  t        j                  t
        «      }t        j                  j	                  t        j                  j                  d«      t        rdndt
        «      }t        j                  j	                  t        j                  d«      t
        «      }t        j                  |t        j                  |gt        j                  ||giS c c} w )NÚpipú~z.pip)r	   Úsite_config_dirsÚosÚpathÚjoinÚCONFIG_BASENAMEÚsysÚprefixÚ
expanduserr   Úuser_config_dirr   r   r   r   )r8   Úglobal_config_filesÚsite_config_fileÚlegacy_config_fileÚnew_config_files        r$   Úget_configuration_filesrC   M   sØ   € ä8?×8PÑ8PÐQVÓ8WöØ04Œ�‰�‰�Tœ?Õ+ðÐð ô —w‘w—|‘|¤C§J¡J´Ó@ÐÜŸ™Ÿ™Ü
�‰×Ñ˜3ÓÝ‰˜fÜóÐô
 —g‘g—l‘l¤7×#:Ñ#:¸5Ó#AÄ?ÓS€Oä�‰Ð(Ü�	‰	Ð$Ð%Ü�	‰	Ð&¨Ð8ðð ùòs   ˜+D-c                  ó   — e Zd ZdZdd„Zy)Ú_RawConfigParserz*RawConfigParser with normalized key names.c                ó   — t        |«      S ©N©r,   )ÚselfÚ	optionstrs     r$   Úoptionxformz_RawConfigParser.optionxformc   s   € Ü˜yÓ)Ð)r#   N)rJ   r   Úreturnr   )r   r   r   r   rK   r"   r#   r$   rE   rE   `   s
   „ Ù4ô*r#   rE   c                  óæ   ‡ — e Zd ZdZddˆ fd„Zdd„Zdd„Zdd„Zdd„Zdd„Z	dd„Z
dd	„Zdd
„Zedd„«       Zdd„Zd d„Zd!d„Zdd„Z	 	 	 	 	 	 d"d„Zd#d„Zd$d„Zd%d„Z	 d	 	 	 d&d„Zd'd„Zd(d„Zˆ xZS ))ÚConfigurationaâ  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         ‰| �  «        |�C|t        vr;t        dj	                  dj                  t        t        t        «      «      «      «      ‚|| _        || _	        t        D �ci c]  }|g “Œ c}| _        t        D �ci c]  }|i “Œ c}| _        g | _        d| _        y c c}w c c}w )Nz5Got invalid value for load_only - should be one of {}z, F)ÚsuperÚ__init__ÚVALID_LOAD_ONLYr   Úformatr9   ÚmapÚreprÚisolatedÚ	load_onlyÚOVERRIDE_ORDERÚ_parsersÚ_configÚ_modified_parsersÚ_use_env)rI   rV   rW   ÚvariantÚ	__class__s       €r$   rQ   zConfiguration.__init__u   s³   ø€ Ü‰ÑÔàÐ  Y´oÑ%EÜ$ØG×NÑNØ—I‘Iœc¤$¬Ó8Ó9óóð ð
 !ˆŒØ"ˆŒô (6öH
Ø#ˆG�R‰KòH
ˆŒô (6ö?
Ø#ˆG�R‰Kò?
ˆŒð EGˆÔØˆ�ùòH
ùò?
s   Á+
B&Â
B+c                ó^   — | j                  «        | j                  s| j                  «        yy)z<Loads configuration from configuration files and environmentN)Ú_load_config_filesrV   Ú_load_environment_vars©rI   s    r$   ÚloadzConfiguration.load‹   s&   € à×ÑÔ!Ø�}Š}Ø×'Ñ'Õ)ð r#   c                ón   — | j                   €J d«       ‚	 | j                  «       d   S # t        $ r Y yw xY w)z7Returns the file with highest priority in configurationNz)Need to be specified a file to be editingr   )rW   Ú_get_parser_to_modifyr   rb   s    r$   Úget_file_to_editzConfiguration.get_file_to_edit‘   sC   € à�~‰~Ð)ÐVÐ+VÓVÐ)ð	Ø×-Ñ-Ó/°Ñ2Ð2øÜ!ò 	Ùð	ús   •( ¨	4³4c                ó6   — | j                   j                  «       S )z`Returns key-value pairs like dict.items() representing the loaded
        configuration
        )Ú_dictionaryÚitemsrb   s    r$   ri   zConfiguration.itemsš   s   € ð ×Ñ×%Ñ%Ó'Ð'r#   c                óØ   — |}t        |«      }	 i }| j                  j                  «       D ]  }|j                  |«       Œ ||   S # t        $ r t        |«       t        d|› �«      ‚w xY w)z#Get a value from the configuration.úNo such key - )r,   rh   ÚvaluesÚupdateÚKeyErrorr2   r   )rI   ÚkeyÚorig_keyÚclean_configÚfile_valuess        r$   Ú	get_valuezConfiguration.get_value    s€   € àˆÜ˜cÓ"ˆð		BØ+-ˆLØ#×/Ñ/×6Ñ6Ó8ò 1�Ø×#Ñ# KÕ0ð1à Ñ$Ð$øÜò 	Bô ˜SÔ!Ü$ ~°h°ZÐ%@ÓAÐAð		Bús   �6A Á#A)c                óº  — t        |«      }| j                  «        | j                  sJ ‚| j                  «       \  }}|�Ct	        |«      \  }}|j                  |«      s|j                  |«       |j                  |||«       | j                  | j                     j                  |i «       || j                  | j                     |   |<   | j                  ||«       y)z$Modify a value in the configuration.N)r,   Ú_ensure_have_load_onlyrW   re   r2   Úhas_sectionÚadd_sectionÚsetrZ   Ú
setdefaultÚ_mark_as_modified)rI   ro   ÚvalueÚfnameÚparserÚsectionr+   s          r$   Ú	set_valuezConfiguration.set_value¯   sÁ   € ä˜cÓ"ˆØ×#Ñ#Ô%à�~Š~Ðˆ~Ø×2Ñ2Ó4‰ˆˆvàÐÜ,¨SÓ1‰MˆG�Tð ×%Ñ% gÔ.Ø×"Ñ" 7Ô+Ø�J‰J�w  eÔ,à�‰�T—^‘^Ñ$×/Ñ/°°rÔ:Ø38ˆ�‰�T—^‘^Ñ$ UÑ+¨CÑ0Ø×Ñ˜u fÕ-r#   c                ó~  — |}t        |«      }| j                  «        | j                  sJ ‚| j                  |«      \  }}| j                  rt
        j                  n| j                  }| j                  |   j                  |i «      }||vrt        d|› �«      ‚|�pt        |«      \  }}|j                  |«      r|j                  ||«      st        d«      ‚|j                  |«      s|j                  |«       | j                  ||«       	 | j                  |   |   |= y# t         $ r | j                  |   |= Y yw xY w)z#Unset a value in the configuration.rk   Nz4Fatal Internal error [id=1]. Please report as a bug.)r,   ru   rW   re   r\   r   r   rZ   Úgetr   r2   rv   Úremove_optionri   Úremove_sectionrz   rn   )	rI   ro   rp   r|   r}   Úload_configÚfile_configr~   r+   s	            r$   Úunset_valuezConfiguration.unset_valueÃ   s1  € àˆÜ˜cÓ"ˆØ×#Ñ#Ô%à�~Š~Ðˆ~Ø×2Ñ2°3Ó7‰ˆˆvØ"&§-¢-”d—h’h°T·^±^ˆØ—l‘l ;Ñ/×3Ñ3°E¸2Ó>ˆØ�kÑ!Ü$ ~°h°ZÐ%@ÓAÐAàÐÜ,¨SÓ1‰MˆG�Tà×"Ñ" 7Ô+°×0DÑ0DÀWÈdÔ0Sô )ØJóð ð
 —<‘< Ô(Ø×%Ñ% gÔ.Ø×"Ñ" 5¨&Ô1ð	/Ø—‘˜[Ñ)¨%Ñ0°Ñ5øÜò 	/Ø—‘˜[Ñ)¨#Ò.ð	/ús   ÄD  Ä D<Ä;D<c                ór  — | j                  «        | j                  D ]j  \  }}t        j                  d|«       t	        t
        j                  j                  |«      «       	 t        |d«      5 }|j                  |«       ddd«       Œl y# 1 sw Y   ŒxY w# t        $ r}t        d|› d|› �«      ‚d}~ww xY w)z!Save the current in-memory state.zWriting to %sÚwNz:An error occurred while writing to the configuration file z: )ru   r[   ÚloggerÚinfor   r7   r8   ÚdirnameÚopenÚwriteÚOSErrorr   )rI   r|   r}   ÚfÚerrors        r$   ÚsavezConfiguration.saveã   s­   € à×#Ñ#Ô%à!×3Ñ3ò 	‰MˆE�6Ü�K‰K˜¨Ô/ô ”r—w‘w—‘ uÓ-Ô.ðÜ˜% Ó%ð $¨Ø—L‘L ”O÷$øñ	÷$ð $ûäò Ü(ØPØ�g˜R ˜wð(óð ûðús0   Á"BÁ.BÂ BÂB	ÂBÂ	B6Â B1Â1B6c                ór   — | j                   €t        d«      ‚t        j                  d| j                   «       y )Nz'Needed a specific file to be modifying.z$Will be working with %s variant only)rW   r   r‰   Údebugrb   s    r$   ru   z$Configuration._ensure_have_load_onlyû   s+   € Ø�>‰>Ð!Ü$Ð%NÓOÐOÜ�‰Ð;¸T¿^¹^ÕLr#   c                ó\   — i }t         D ]   }|j                  | j                  |   «       Œ" |S )z3A dictionary representing the loaded configuration.)rX   rm   rZ   )rI   Úretvalr]   s      r$   rh   zConfiguration._dictionary   s4   € ð
 ˆä%ò 	1ˆGØ�M‰M˜$Ÿ,™, wÑ/Õ0ð	1ð ˆr#   c                ón  — t        | j                  «       «      }|t        j                     dd t        j
                  gk(  rt        j                  d«       yt        j                  j                  d«      }|j                  «       D ]¬  \  }}|D ]¢  }| j                  �b|| j                  k7  rS|t        j                  k(  xr$ ||k(  xr | j                  t        j                  k(  }|st        j                  d||«       Œq| j                  ||«      }| j                  |   j                  ||f«       Œ¤ Œ® y)z,Loads configuration from configuration filesr   r/   zZSkipping loading configuration files due to environment's PIP_CONFIG_FILE being os.devnullNÚPIP_CONFIG_FILEz Skipping file '%s' (variant: %s))ÚdictÚiter_config_filesr   r   r7   Údevnullr‰   r“   Úenvironr�   ri   rW   r   Ú
_load_filerY   Úappend)rI   Úconfig_filesÚenv_config_filer]   Úfilesr|   Úis_env_redirectr}   s           r$   r`   z Configuration._load_config_files  s  € ä˜D×2Ñ2Ó4Ó5ˆØœŸ™Ñ! ! AÐ&¬2¯:©:¨,Ò6Ü�L‰LðAôð äŸ*™*Ÿ.™.Ð):Ó;ˆØ*×0Ñ0Ó2ò 	?‰NˆG�UØò ?�ð —>‘>Ð-°'¸T¿^¹^Ò2Kà¤4§8¡8Ñ+ò 8Ø! _Ñ4ò8à ŸN™N¬d¯i©iÑ7ð $ñ
 +ÜŸ™Ð%GÈÐPWÔXØ àŸ™¨°%Ó8�ð —‘˜gÑ&×-Ñ-¨u°f¨oÕ>ñ!?ñ	?r#   c                óB  — t         j                  d||«       | j                  |«      }| j                  |   j	                  |i «       |j                  «       D ]D  }|j                  |«      }| j                  |   |   j                  | j                  ||«      «       ŒF |S )Nz'For variant '%s', will try loading '%s')	r‰   ÚverboseÚ_construct_parserrZ   ry   Úsectionsri   rm   Ú_normalized_keys)rI   r]   r|   r}   r~   ri   s         r$   rœ   zConfiguration._load_file*  s’   € Ü�‰Ð@À'È5ÔQØ×'Ñ'¨Ó.ˆà�‰�WÑ×(Ñ(¨°Ô3Ø—‘Ó(ò 	WˆGØ—L‘L Ó)ˆEØ�L‰L˜Ñ! %Ñ(×/Ñ/°×0EÑ0EÀgÈuÓ0UÕVð	Wð ˆr#   c                óP  — t        «       }t        j                  j                  |«      r<t        j
                  j                  rdn	t        «       }	 |j                  ||¬«       |S |S # t        $ r t        d|› d�|¬«      ‚t        j                  $ r}t        |¬«      ‚d }~ww xY w)Nzutf-8)Úencodingzcontains invalid z characters)Úreasonr|   )r�   )rE   r7   r8   Úexistsr;   ÚflagsÚ	utf8_moder   ÚreadÚUnicodeDecodeErrorr   ÚconfigparserÚError)rI   r|   r}   r¨   r�   s        r$   r¤   zConfiguration._construct_parser5  sŸ   € Ü!Ó#ˆô
 �7‰7�>‰>˜%Ô Ü"%§)¡)×"5Ò"5‘wÔ;NÓ;PˆHð
EØ—‘˜E¨H�Ô5ð ˆˆvˆøô &ò ä7Ø.¨x¨j¸ÐDØôð ô  ×%Ñ%ò Eä7¸eÔDÐDûðEús   ÁA( Á(,B%ÂB Â B%c                óø   — | j                   t        j                     j                  di «       | j                   t        j                     d   j	                  | j                  d| j                  «       «      «       y)z.Loads configuration from environment variablesz:env:N)rZ   r   r   ry   rm   r¦   Úget_environ_varsrb   s    r$   ra   z$Configuration._load_environment_varsJ  sX   € à�‰”T—\‘\Ñ"×-Ñ-¨g°rÔ:Ø�‰”T—\‘\Ñ" 7Ñ+×2Ñ2Ø×!Ñ! '¨4×+@Ñ+@Ó+BÓCõ	
r#   c                óJ   — i }|D ]  \  }}|dz   t        |«      z   }|||<   Œ |S )z×Normalizes 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.   rH   )rI   r~   ri   Ú
normalizedr+   Úvalro   s          r$   r¦   zConfiguration._normalized_keysQ  s@   € ð ˆ
Øò 	"‰IˆD�#Ø˜C‘-¤/°$Ó"7Ñ7ˆCØ!ˆJ�sŠOð	"ð Ðr#   c              #  óÀ   K  — t         j                  j                  «       D ]9  \  }}|j                  d«      sŒ|dd j	                  «       }|t
        vsŒ4||f–— Œ; y­w)z@Returns a generator with all environmental vars with prefix PIP_ÚPIP_é   N)r7   r›   ri   Ú
startswithr(   ÚENV_NAMES_IGNORED)rI   ro   rµ   r+   s       r$   r²   zConfiguration.get_environ_vars_  sU   è ø€ äŸ
™
×(Ñ(Ó*ò 	$‰HˆC�Ø�~‰~˜fÕ%Ø˜1˜2�w—}‘}“�ØÔ0Ò0Ø ˜)“Oñ		$ùs   ‚6A¹AÁ	Ac              #  ó   K  — t         j                  j                  dd«      }t        «       }t        j
                  |t        j
                     f–— | j                   xr$ |xr t         j                  j                  |«       }|r%t        j                  |t        j                     f–— t        j                  |t        j                     f–— |�t        j                  |gf–— yt        j                  g f–— y­w)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
        r—   N)r7   r›   r�   rC   r   r   rV   r8   rª   r   r   r   )rI   rŸ   rž   Úshould_load_user_configs       r$   r™   zConfiguration.iter_config_filesh  sÈ   è ø€ ô Ÿ*™*Ÿ.™.Ð):¸DÓAˆÜ.Ó0ˆä�k‰k˜<¬¯©Ñ4Ð4Ò4ð '+§m¡mÐ"3ò #
ØÒ?¤§¡§¡¨Ó ?ð9
Ðñ #ä—)‘)˜\¬$¯)©)Ñ4Ð4Ò4ô �i‰i˜¤d§i¡iÑ0Ð0Ò0àÐ&Ü—(‘(˜_Ð-Ð-Ó-ä—(‘(˜B�,Óùs   ‚C<C>c                ó    — | j                   |   S )z#Get values present in a config file)rZ   )rI   r]   s     r$   Úget_values_in_configz"Configuration.get_values_in_configˆ  s   € à�|‰|˜GÑ$Ð$r#   c                óÂ  — | j                   sJ ‚| j                  | j                      }|sàt        j                  j	                  d«      }|t        j
                  k(  rt        d|› �«      ‚|r“| j                   t        j                  t        j                  fv rg| j                  |«      }| j                  | j                      j                  ||f«       d| _        t        j                  d|| j                   «       ||fS t        d«      ‚|€|d   S t        |«      \  }}t!        |«      D ]/  \  }}|j#                  |«      sŒ|j%                  ||«      sŒ+||fc S  |d   S )Nr—   z3Cannot write to PIP_CONFIG_VALUE when it is set to Tz€Because PIP_CONFIG_FILE is set, changes will be applied to '%s', not to '%s'. To restore normal behavior, unset PIP_CONFIG_FILE.z4Fatal Internal error [id=2]. Please report as a bug.éÿÿÿÿ)rW   rY   r7   r›   r�   rš   r   r   r   r   r¤   r�   r\   r‰   Úwarningr2   Úreversedrv   Ú
has_option)rI   ro   ÚparsersrŸ   r}   r~   r+   r|   s           r$   re   z#Configuration._get_parser_to_modifyŒ  sW  € ð �~Š~Ðˆ~Ø—-‘- §¡Ñ/ˆÙÜ Ÿj™jŸn™nÐ->Ó?ˆOØ¤"§*¡*Ò,Ü(ØIØ&Ð'ð)óð ñ  4§>¡>´d·i±iÄÇÁÐ5MÑ#MØ×/Ñ/°Ó@�Ø—‘˜dŸn™nÑ-×4Ñ4°oÀvÐ5NÔOØ $�”Ü—‘ð-ð $Ø—N‘Nôð '¨Ð.Ð.ä$ØFóð ð ˆ;Ø˜2‘;Ðä(¨Ó-‰ˆ�Ü% gÓ.ò 	%‰MˆE�6Ø×!Ñ! 'Õ*¨v×/@Ñ/@ÀÈ$Õ/OØ˜f�}Ò$ð	%ð
 �r‰{Ðr#   c                ó`   — ||f}|| j                   vr| j                   j                  |«       y y rG   )r[   r�   )rI   r|   r}   Úfile_parser_tuples       r$   rz   zConfiguration._mark_as_modified¶  s4   € Ø" F˜OÐØ D×$:Ñ$:Ñ:Ø×"Ñ"×)Ñ)Ð*;Õ<ð ;r#   c                óN   — | j                   j                  › d| j                  ›d�S )Nú(ú))r^   r   rh   rb   s    r$   r!   zConfiguration.__repr__»  s'   € Ø—.‘.×)Ñ)Ð*¨!¨D×,<Ñ,<Ð+?¸qÐAÐAr#   rG   )rV   ÚboolrW   zKind | NonerL   ÚNone)rL   rË   )rL   ú
str | None)rL   úIterable[tuple[str, Any]])ro   r   rL   r   )ro   r   r{   r   rL   rË   )ro   r   rL   rË   )rL   zdict[str, dict[str, Any]])r]   r   r|   r   rL   ÚRawConfigParser)r|   r   rL   rÎ   )r~   r   ri   rÍ   rL   údict[str, Any])rL   zIterable[tuple[str, str]])rL   z Iterable[tuple[Kind, list[str]]])r]   r   rL   rÏ   )ro   rÌ   rL   ztuple[str, RawConfigParser])r|   r   r}   rÎ   rL   rË   )rL   r   )r   r   r   r   rQ   rc   rf   ri   rs   r   r†   r‘   ru   Úpropertyrh   r`   rœ   r¤   ra   r¦   r²   r™   r¾   re   rz   r!   Ú__classcell__)r^   s   @r$   rN   rN   g   s³   ø„ ñöó,*óó(óBó.ó(/ó@ó0Mð
 ò	ó ð	ó?ó<	óó*
ðØðØ#<ðà	óó$óó@%ð
 !%ð'Øð'à	$ó'óT=÷
Br#   rN   )r+   r   rL   r   )r+   r   rL   z	list[str])rL   zdict[Kind, list[str]])+r   Ú
__future__r   r¯   r7   r;   Úcollections.abcr   Úenumr   Útypingr   Úpip._internal.exceptionsr   r   Úpip._internal.utilsr	   Úpip._internal.utils._logr
   Úpip._internal.utils.compatr   r   Úpip._internal.utils.miscr   rÎ   r:   rº   r   r   r   r   r   r   r   rX   rR   r   r‰   r,   r2   rC   rE   rN   r"   r#   r$   ú<module>rÛ      sÓ   ðñõ #ã Û 	Û 
Ý $Ý Ý ÷õ (Ý .ß CÝ /à×.Ñ.€á&‘)¨J€Ø%Ð ô

ˆ3�ô 
ð —‘˜dŸi™i¨¯©°D·H±H¸d¿l¹lÐJ€Ø—)‘)˜TŸ[™[¨$¯)©)Ð3€á	�8Ó	€óóóô&*�|×3Ñ3ô *÷UBò UBr#   