HEX
Server: Apache
System: Linux p3plzcpnl506847.prod.phx3.secureserver.net 4.18.0-553.54.1.lve.el8.x86_64 #1 SMP Wed Jun 4 13:01:13 UTC 2025 x86_64
User: slfopp7cb1df (5698090)
PHP: 8.1.34
Disabled: NONE
Upload Files
File: //opt/python38/lib/python3.8/site-packages/pip/_internal/__pycache__/configuration.cpython-38.pyc
U

�{�e6�@s>dZddlZddlZddlZddlZddlmZmZmZm	Z	m
Z
mZmZddl
mZmZddlmZddlmZddlmZddlmZmZejZe
d	e�Zer�d
ndZdZed
ddddd�Zejej ej!ej"ej#fZ$ej ejej!fZ%ee&�Z'eed�dd�Z(ee	ed�dd�Z)eee	efd�dd�Z*Gdd�d�Z+dS)aConfiguration 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)�Any�Dict�Iterable�List�NewType�Optional�Tuple)�ConfigurationError�!ConfigurationFileCouldNotBeLoaded)�appdirs)�WINDOWS)�	getLogger)�
ensure_dir�enum�Kindzpip.inizpip.conf)�version�help�user�global�site�envzenv-var)�USER�GLOBAL�SITE�ENV�ENV_VAR)�name�returncCs*|���dd�}|�d�r&|dd�}|S)zAMake a name consistent regardless of source (environment or file)�_�-z--�N)�lower�replace�
startswith)r�r$�?/tmp/pip-unpacked-wheel-_0scjqea/pip/_internal/configuration.py�_normalize_name2s
r&cCs&d|krd�|�}t|��|�dd�S)N�.zbKey does not contain dot separated section and key. Perhaps you wanted to use 'global.{}' instead?�)�formatr	�split)r�
error_messager$r$r%�_disassemble_key:s��r,�rcCstdd�t�d�D�}tj�tjt�}tj�tj�d�t	r<dndt�}tj�t�
d�t�}tj|tj
|gtj||giS)NcSsg|]}tj�|t��qSr$)�os�path�join�CONFIG_BASENAME)�.0r/r$r$r%�
<listcomp>Esz+get_configuration_files.<locals>.<listcomp>�pip�~z.pip)r�site_config_dirsr.r/r0�sys�prefixr1�
expanduserr�user_config_dir�kindsrrr)�global_config_files�site_config_file�legacy_config_file�new_config_filer$r$r%�get_configuration_filesDs"�

��r@cs�eZdZdZd6eeedd��fdd�
Zdd�dd�Zee	d�d	d
�Z
eee	e
fd�dd�Ze	e
d
�dd�Ze	e
dd�dd�Ze	dd
�dd�Zdd�dd�Zdd�dd�Zeee	e
fd�dd��Zdd�dd�Zee	ed�dd�Ze	ed �d!d"�Zdd�d#d$�Ze	eee	e
fee	e
fd%�d&d'�Zeee	e	fd�d(d)�Zeeeee	fd�d*d+�Zeee	e
fd,�d-d.�Z ee	efd�d/d0�Z!e	edd1�d2d3�Z"e	d�d4d5�Z#�Z$S)7�
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.
    N)�isolated�	load_onlyrcsjt���|dk	r4|tkr4td�d�ttt�����||_||_	dd�t
D�|_dd�t
D�|_g|_
dS)Nz5Got invalid value for load_only - should be one of {}z, cSsi|]
}|g�qSr$r$�r2�variantr$r$r%�
<dictcomp>rsz*Configuration.__init__.<locals>.<dictcomp>cSsi|]
}|i�qSr$r$rDr$r$r%rFus)�super�__init__�VALID_LOAD_ONLYr	r)r0�map�reprrBrC�OVERRIDE_ORDER�_parsers�_config�_modified_parsers)�selfrBrC��	__class__r$r%rHes 
����zConfiguration.__init__r-cCs|��|js|��dS)z<Loads configuration from configuration files and environmentN)�_load_config_filesrB�_load_environment_vars�rPr$r$r%�loadzszConfiguration.loadcCs<|jdk	std��z|��dWStk
r6YdSXdS)z7Returns the file with highest priority in configurationNz)Need to be specified a file to be editingr)rC�AssertionError�_get_parser_to_modify�
IndexErrorrUr$r$r%�get_file_to_edit�s
zConfiguration.get_file_to_editcCs
|j��S)z`Returns key-value pairs like dict.items() representing the loaded
        configuration
        )�_dictionary�itemsrUr$r$r%r\�szConfiguration.items)�keyrcCsH|}t|�}z|j|WStk
rBt|�td|����YnXdS)z#Get a value from the configuration.�No such key - N)r&r[�KeyErrorr,r	)rPr]�orig_keyr$r$r%�	get_value�szConfiguration.get_value)r]�valuercCs|t|�}|��|jst�|��\}}|dk	r\t|�\}}|�|�sN|�|�|�|||�||j	|j|<|�
||�dS)z$Modify a value in the configuration.N)r&�_ensure_have_load_onlyrCrWrXr,�has_section�add_section�setrN�_mark_as_modified)rPr]rb�fname�parser�sectionrr$r$r%�	set_value�s


zConfiguration.set_valuecCs�|}t|�}|��|jst�||j|jkr<td|����|��\}}|dk	r�t|�\}}|�|�rr|�	||�sztd��|�
|�s�|�|�|�||�|j|j|=dS)z#Unset a value in the configuration.r^Nz4Fatal Internal error [id=1]. Please report as a bug.)
r&rcrCrWrNr	rXr,rd�
remove_optionr\�remove_sectionrg)rPr]r`rhrirjrr$r$r%�unset_value�s(
�
��

zConfiguration.unset_valuecCs�|��|jD]�\}}t�d|�ttj�|��z$t|d��}|�	|�W5QRXWqt
k
r�}ztd|�d|����W5d}~XYqXqdS)z!Save the current in-memory state.z
Writing to %s�wz:An error occurred while writing to the configuration file z: N)rcrO�logger�inforr.r/�dirname�open�write�OSErrorr	)rPrhri�f�errorr$r$r%�save�s�zConfiguration.savecCs$|jdkrtd��t�d|j�dS)Nz'Needed a specific file to be modifying.z$Will be working with %s variant only)rCr	rp�debugrUr$r$r%rc�s
z$Configuration._ensure_have_load_onlycCs"i}tD]}|�|j|�q|S)z3A dictionary representing the loaded configuration.)rL�updaterN)rP�retvalrEr$r$r%r[�szConfiguration._dictionarycCs�t|���}|tjdd�tjgkr4t�d�dS|��D]V\}}|D]H}|j	dk	rp||j	krpt�d||�qH|�
||�}|j|�||f�qHq<dS)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))
�dict�iter_config_filesr;rr.�devnullrpryr\rC�
_load_filerM�append)rP�config_filesrE�filesrhrir$r$r%rS�s�z Configuration._load_config_files)rErhrcCsLt�d||�|�|�}|��D]&}|�|�}|j|�|�||��q |S)Nz'For variant '%s', will try loading '%s')rp�verbose�_construct_parser�sectionsr\rNrz�_normalized_keys)rPrErhrirjr\r$r$r%rs

zConfiguration._load_file)rhrc
Cs�t��}tj�|�r�t�d�}z|j||d�WnTtk
rXt	d|�d�|d��Yn.tj
k
r�}zt	|d��W5d}~XYnX|S)NF)�encodingzcontains invalid z characters)�reasonrh)rw)�configparser�RawConfigParserr.r/�exists�locale�getpreferredencoding�read�UnicodeDecodeErrorr
�Error)rPrhriZlocale_encodingrwr$r$r%r�s

�
zConfiguration._construct_parsercCs"|jtj�|�d|����dS)z.Loads configuration from environment variablesz:env:N)rNr;rrzr��get_environ_varsrUr$r$r%rT*s�z$Configuration._load_environment_vars)rjr\rcCs.i}|D] \}}|dt|�}|||<q|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&)rPrjr\�
normalizedr�valr]r$r$r%r�0s

zConfiguration._normalized_keysccsDtj��D]4\}}|�d�r
|dd���}|tkr
||fVq
dS)z@Returns a generator with all environmental vars with prefix PIP_�PIP_�N)r.�environr\r#r!�ENV_NAMES_IGNORED)rPr]r�rr$r$r%r�>s

zConfiguration.get_environ_varsccs�tj�dd�}|dk	r&tj|gfVntjgfVt�}tj|tjfV|job|o`tj�	|�}|rztj
|tj
fVtj|tjfVdS)zYields variant and configuration files associated with it.

        This should be treated like items of a dictionary.
        �PIP_CONFIG_FILEN)r.r��getr;rr@rrBr/r�rr)rP�config_filer��should_load_user_configr$r$r%r}Gs�zConfiguration.iter_config_files)rErcCs
|j|S)z#Get values present in a config file)rN)rPrEr$r$r%�get_values_in_configesz"Configuration.get_values_in_configcCs*|js
t�|j|j}|s"td��|dS)Nz4Fatal Internal error [id=2]. Please report as a bug.���)rCrWrMr	)rP�parsersr$r$r%rXis
�z#Configuration._get_parser_to_modify)rhrircCs"||f}||jkr|j�|�dS)N)rOr�)rPrhri�file_parser_tupler$r$r%rgws
zConfiguration._mark_as_modifiedcCs|jj�d|j�d�S)N�(�))rR�__name__r[rUr$r$r%�__repr__|szConfiguration.__repr__)N)%r��
__module__�__qualname__�__doc__�boolrrrHrV�strrZrrrr\rarkrnrxrc�propertyrr[rSr�rr�rTr�r�rr}r�rXrgr��
__classcell__r$r$rQr%rAWs4
	

�	rA),r�r�r�r.r7�typingrrrrrrr�pip._internal.exceptionsr	r
Zpip._internal.utilsr�pip._internal.utils.compatr�pip._internal.utils.loggingr
�pip._internal.utils.miscrrr�r�rr1r�r;rrrrrrLrIr�rpr&r,r@rAr$r$r$r%�<module>s8
$
�