Ë
    »ÿæiè8  ã                  óÜ  — d Z ddlmZ ddlZddlZddlZddlZddlmZ ddl	m
Z
mZ ddlmZmZ ddlmZ ddlmZ dd	lmZ dd
lmZmZ ej0                  Z ede«      ZerdndZdZ eddddd¬«      Zej<                  ej>                  ej@                  ejB                  ejD                  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«      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)Ú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                óh   — | j                  «       j                  dd«      } | j                  d«      } | S )zAMake a name consistent regardless of source (environment or file)Ú_Ú-z--)ÚlowerÚreplaceÚremoveprefix)Únames    úp/Volumes/fast/ai/experiments/voice-extract-mac/.venv/lib/python3.12/site-packages/pip/_internal/configuration.pyÚ_normalize_namer"   5   s/   € à�:‰:‹<×Ñ  SÓ)€DØ×Ñ˜TÓ"€DØ€Kó    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_keyr)   <   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_dirÚkindsr   r   r   )r/   Úglobal_config_filesÚsite_config_fileÚlegacy_config_fileÚnew_config_files        r!   Úget_configuration_filesr;   F   sÚ   € ä8?×8PÑ8PÐQVÔ8WóÙ8W°Œ�‰�‰�Tœ?Õ+Ð8Wð ð ô —w‘w—|‘|¤C§J¡J´Ó@ÐÜŸ™Ÿ™Ü
�‰×Ñ˜3ÓÝ‰˜fÜóÐô
 —g‘g—l‘l¤7×#:Ñ#:¸5Ó#AÄ?ÓS€Oä�‰Ð)Ü�
‰
Ð%Ð&Ü�
‰
Ð'¨Ð9ðð ùòs   ˜+D-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„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           
     óR  •— 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 | _        y c c}w c c}w )Nz5Got invalid value for load_only - should be one of {}z, )ÚsuperÚ__init__ÚVALID_LOAD_ONLYr   Úformatr0   ÚmapÚreprÚisolatedÚ	load_onlyÚOVERRIDE_ORDERÚ_parsersÚ_configÚ_modified_parsers)ÚselfrE   rF   ÚvariantÚ	__class__s       €r!   r@   zConfiguration.__init__g   s´   ø€ Ü‰ÑÔàÐ  Y´oÑ%EÜ$ØG×NÑNØ—I‘Iœc¤$¬Ó8Ó9óóð ð
 !ˆŒØ"ˆŒõ (6óH
Ù'5˜GˆG�R‰K ~ñH
ˆŒõ (6ó?
Ù'5˜Gˆ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_filesrE   Ú_load_environment_vars©rK   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   )rF   Ú_get_parser_to_modifyÚ
IndexErrorrQ   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ÚitemsrQ   s    r!   rY   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"   rX   ÚvaluesÚupdateÚKeyErrorr)   r   )rK   ÚkeyÚorig_keyÚclean_configÚfile_valuess        r!   Ú	get_valuezConfiguration.get_value‘   s{   € àˆÜ˜cÓ"ˆð		BØ+-ˆLØ#×/Ñ/×6Ñ6Ö8�Ø×#Ñ# KÕ0ð  9à Ñ$Ð$øÜò 	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_onlyrF   rT   r)   Úhas_sectionÚadd_sectionÚsetrI   Ú
setdefaultÚ_mark_as_modified)rK   r_   Ú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                  | j                     |   vr)|| j                  | j                     vrt        d|› �«      ‚|�pt        |«      \  }}|j                  |«      r|j                  ||«      st        d«      ‚|j                  |«      s|j                  |«       | j                  ||«       	 | j                  | j                     |   |= y# t        $ r | j                  | j                     |= Y yw xY w)z#Unset a value in the configuration.r[   Nz4Fatal Internal error [id=1]. Please report as a bug.)r"   re   rF   rT   rI   r   r)   rf   Úremove_optionrY   Úremove_sectionrj   r^   )rK   r_   r`   rl   rm   rn   r    s          r!   Úunset_valuezConfiguration.unset_value´   s0  € àˆÜ˜cÓ"ˆØ×#Ñ#Ô%à�~Š~Ðˆ~Ø×2Ñ2Ó4‰ˆˆvð �t—|‘| D§N¡NÑ3°EÑ:Ñ:Ø˜4Ÿ<™<¨¯©Ñ7Ñ7ä$ ~°h°ZÐ%@ÓAÐAàÐÜ,¨SÓ1‰MˆG�Tà×"Ñ" 7Ô+°×0DÑ0DÀWÈdÔ0Sô )ØJóð ð
 —<‘< Ô(Ø×%Ñ% gÔ.Ø×"Ñ" 5¨&Ô1ð	2Ø—‘˜TŸ^™^Ñ,¨UÑ3°CÑ8øÜò 	2Ø—‘˜TŸ^™^Ñ,¨SÒ1ð	2ús   Ã9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: )re   rJ   ÚloggerÚinfor   r.   r/   ÚdirnameÚopenÚwriteÚOSErrorr   )rK   rl   rm   ÚfÚerrors        r!   ÚsavezConfiguration.saveÖ   s¡   € à×#Ñ#Ô%à!×3Ô3‰MˆE�6Ü�K‰K˜¨Ô/ô ”r—w‘w—‘ uÓ-Ô.ðÜ˜% Ô%¨Ø—L‘L ”O÷ &øñ 4÷ &Ð%ûäò Ü(Ø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)rF   r   rv   ÚdebugrQ   s    r!   re   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.)rG   r]   rI   )rK   ÚretvalrL   s      r!   rX   zConfiguration._dictionaryó   s/   € ð
 ˆç%ˆGØ�M‰M˜$Ÿ,™, wÑ/Õ0ð &ð ˆr#   c                óº  — t        | j                  «       «      }|t        j                     dd t        j
                  gk(  rt        j                  d«       y|j                  «       D ]q  \  }}|D ]g  }| j                  �'|| j                  k7  rt        j                  d||«       Œ6| j                  ||«      }| j                  |   j                  ||f«       Œi Œs y)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_filesr6   r   r.   Údevnullrv   r€   rY   rF   Ú
_load_filerH   Úappend)rK   Úconfig_filesrL   Úfilesrl   rm   s         r!   rO   z Configuration._load_config_filesÿ   sÃ   € ä˜D×2Ñ2Ó4Ó5ˆØœŸ	™	Ñ" 1 QÐ'¬B¯J©J¨<Ò7Ü�L‰LðAôð à*×0Ñ0Ö2‰NˆG�UÛ�ð —>‘>Ð-°'¸T¿^¹^Ò2KÜ—L‘LÐ!CÀUÈGÔTØàŸ™¨°%Ó8�ð —‘˜gÑ&×-Ñ-¨u°f¨oÕ>ñ ñ 3r#   c                óB  — t         j                  d||«       | j                  |«      }|j                  «       D ]c  }|j	                  |«      }| j
                  |   j                  |i «       | j
                  |   |   j                  | j                  ||«      «       Œe |S )Nz'For variant '%s', will try loading '%s')	rv   ÚverboseÚ_construct_parserÚsectionsrY   rI   ri   r]   Ú_normalized_keys)rK   rL   rl   rm   rn   rY   s         r!   r‡   zConfiguration._load_file  s‹   € Ü�‰Ð@À'È5ÔQØ×'Ñ'¨Ó.ˆà—‘Ö(ˆGØ—L‘L Ó)ˆEØ�L‰L˜Ñ!×,Ñ,¨U°BÔ7Ø�L‰L˜Ñ! %Ñ(×/Ñ/°×0EÑ0EÀgÈuÓ0UÕVð )ð
 ˆr#   c                óB  — t        j                  «       }t        j                  j	                  |«      r+t        j                  d«      }	 |j                  ||¬«       |S |S # t        $ r t        d|› d�|¬«      ‚t         j                  $ r}t        |¬«      ‚d }~ww xY w)NF)Úencodingzcontains invalid z characters)Úreasonrl   )r}   )ÚconfigparserÚRawConfigParserr.   r/   ÚexistsÚlocaleÚgetpreferredencodingÚreadÚUnicodeDecodeErrorr   ÚError)rK   rl   rm   Úlocale_encodingr}   s        r!   r�   zConfiguration._construct_parser!  sŸ   € Ü×-Ñ-Ó/ˆô
 �7‰7�>‰>˜%Ô Ü$×9Ñ9¸%Ó@ˆOð
EØ—‘˜E¨O�Ô<ð ˆˆvˆøô &ò ä7Ø.¨Ð.?¸{ÐKØôð ô  ×%Ñ%ò 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)rI   r6   r   ri   r]   r�   Úget_environ_varsrQ   s    r!   rP   z$Configuration._load_environment_vars6  sX   € à�‰”U—]‘]Ñ#×.Ñ.¨w¸Ô;Ø�‰”U—]‘]Ñ# GÑ,×3Ñ3Ø×!Ñ! '¨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%   )r"   )rK   rn   rY   Ú
normalizedr    Úvalr_   s          r!   r�   zConfiguration._normalized_keys=  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)r.   ÚenvironrY   Ú
startswithr   ÚENV_NAMES_IGNORED)rK   r_   r    r    s       r!   r�   zConfiguration.get_environ_varsK  sP   è ø€ äŸ
™
×(Ñ(Ö*‰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
        ÚPIP_CONFIG_FILEN)r.   r¤   Úgetr;   r6   r   rE   r/   r•   r   r   r   )rK   Úenv_config_filer‰   Úshould_load_user_configs       r!   r…   zConfiguration.iter_config_filesT  sÈ   è ø€ ô Ÿ*™*Ÿ.™.Ð):¸DÓAˆÜ.Ó0ˆä�l‰l˜L¬¯©Ñ6Ð6Ò6ð '+§m¡mÐ"3ò #
ØÒ?¤§¡§¡¨Ó ?ð9
Ðñ #ä—*‘*˜l¬5¯:©:Ñ6Ð6Ò6ô �j‰j˜,¤u§z¡zÑ2Ð2Ò2àÐ&Ü—)‘)˜oÐ.Ð.Ó.ä—)‘)˜R�-Óùs   ‚C<C>c                ó    — | j                   |   S )z#Get values present in a config file)rI   )rK   rL   s     r!   Úget_values_in_configz"Configuration.get_values_in_configt  s   € à�|‰|˜GÑ$Ð$r#   c                ót   — | j                   sJ ‚| j                  | j                      }|st        d«      ‚|d   S )Nz4Fatal Internal error [id=2]. Please report as a bug.éÿÿÿÿ)rF   rH   r   )rK   Úparserss     r!   rT   z#Configuration._get_parser_to_modifyx  s?   € à�~Š~Ðˆ~Ø—-‘- §¡Ñ/ˆÙä$ØFóð ð
 �r‰{Ðr#   c                ó`   — ||f}|| j                   vr| j                   j                  |«       y y ©N)rJ   rˆ   )rK   rl   rm   Úfile_parser_tuples       r!   rj   zConfiguration._mark_as_modified†  s4   € Ø" F˜OÐØ D×$:Ñ$:Ñ:Ø×"Ñ"×)Ñ)Ð*;Õ<ð ;r#   c                óN   — | j                   j                  › d| j                  ›d�S )NÚ(Ú))rM   Ú__name__rX   rQ   s    r!   Ú__repr__zConfiguration.__repr__‹  s'   € Ø—.‘.×)Ñ)Ð*¨!¨D×,<Ñ,<Ð+?¸qÐAÐAr#   r²   )rE   ÚboolrF   zKind | NoneÚreturnÚNone)rº   r»   )rº   z
str | None)rº   úIterable[tuple[str, Any]])r_   Ústrrº   r   )r_   r½   rk   r   rº   r»   )r_   r½   rº   r»   )rº   zdict[str, dict[str, Any]])rL   r   rl   r½   rº   r”   )rl   r½   rº   r”   )rn   r½   rY   r¼   rº   údict[str, Any])rº   zIterable[tuple[str, str]])rº   z Iterable[tuple[Kind, list[str]]])rL   r   rº   r¾   )rº   ztuple[str, RawConfigParser])rl   r½   rm   r”   rº   r»   )rº   r½   )r·   Ú
__module__Ú__qualname__Ú__doc__r@   rR   rV   rY   rc   ro   rs   r~   re   ÚpropertyrX   rO   r‡   r�   rP   r�   r�   r…   r­   rT   rj   r¸   Ú__classcell__)rM   s   @r!   r=   r=   Y   sž   ø„ ñöGó**óó(óBó.ó( 2óDó0Mð
 ò	ó ð	ó?ó.	óó*
ðØðØ#<ðà	óó$ó ó@%óó=÷
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.   r2   Ú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   r1   r¦   r6   r   r   r   r   r   rG   rA   r·   rv   r"   r)   r;   r=   © r#   r!   Ú<module>rÍ      sÚ   ðñõ #ã Û Û 	Û 
Ý $ß ÷õ (Ý .Ý 1ß 5à×.Ñ.€Ùˆv�sÓ€á&‘)¨J€Ø%Ð ñ 	Ø	ØØ	ØØô	€ð —‘˜uŸz™z¨5¯:©:°u·y±yÀ%Ç-Á-ÐO€Ø—*‘*˜eŸl™l¨E¯J©JÐ6€á	�8Ó	€óóó÷&sBò sBr#   