HEX
Server: Apache
System: Linux zacp120.webway.host 4.18.0-553.50.1.lve.el8.x86_64 #1 SMP Thu Apr 17 19:10:24 UTC 2025 x86_64
User: govancoz (1003)
PHP: 8.3.26
Disabled: exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Upload Files
File: //usr/local/lib/python3.7/site-packages/pip/_internal/__pycache__/configuration.cpython-37.pyc
B

L��g�6�@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-hv55ucu3/pip/_internal/configuration.py�_normalize_name2s
r&cCs(d|krd|�d�}t|��|�dd�S)N�.zVKey does not contain dot separated section and key. Perhaps you wanted to use 'global.z
' instead?�)r	�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>Fsz+get_configuration_files.<locals>.<listcomp>�pip�~z.pip)r�site_config_dirsr,r-r.�sys�prefixr/�
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$)r0�variantr$r$r%�
<dictcomp>rsz*Configuration.__init__.<locals>.<dictcomp>cSsi|]
}i|�qSr$r$)r0rBr$r$r%rCus)�super�__init__�VALID_LOAD_ONLYr	�formatr.�map�reprr@rA�OVERRIDE_ORDER�_parsers�_config�_modified_parsers)�selfr@rA)�	__class__r$r%rEes


zConfiguration.__init__)rcCs|��|js|��dS)z<Loads configuration from configuration files and environmentN)�_load_config_filesr@�_load_environment_vars)rNr$r$r%�loadzszConfiguration.loadcCs8|jdk	std��y|��dStk
r2dSXdS)z7Returns the file with highest priority in configurationNz)Need to be specified a file to be editingr)rA�AssertionError�_get_parser_to_modify�
IndexError)rNr$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�items)rNr$r$r%rX�szConfiguration.items)�keyrcCsF|}t|�}y
|j|Stk
r@t|�td|����YnXdS)z#Get a value from the configuration.zNo such key - N)r&rW�KeyErrorr+r	)rNrY�orig_keyr$r$r%�	get_value�s
zConfiguration.get_value)rY�valuercCs|t|�}|��|jst�|��\}}|dk	r\t|�\}}|�|�sN|�|�|�|||�||j	|j|<|�
||�dS)z$Modify a value in the configuration.N)r&�_ensure_have_load_onlyrArSrTr+�has_section�add_section�setrL�_mark_as_modified)rNrYr]�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.zNo such key - Nz4Fatal Internal error [id=1]. Please report as a bug.)
r&r^rArSrLr	rTr+r_�
remove_optionrX�remove_sectionrb)rNrYr[rcrdrerr$r$r%�unset_value�s 


zConfiguration.unset_valuecCs�|��x�|jD]�\}}t�d|�ttj�|��y$t|d��}|�	|�WdQRXWqt
k
r�}ztd|�d|����Wdd}~XYqXqWdS)z!Save the current in-memory state.z
Writing to %s�wNz:An error occurred while writing to the configuration file z: )r^rM�logger�inforr,r-�dirname�open�write�OSErrorr	)rNrcrd�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)rAr	rk�debug)rNr$r$r%r^�s
z$Configuration._ensure_have_load_onlycCs&i}xtD]}|�|j|�q
W|S)z3A dictionary representing the loaded configuration.)rJ�updaterL)rN�retvalrBr$r$r%rW�s
zConfiguration._dictionarycCs�t|���}|tjdd�tjgkr4t�d�dSxf|��D]Z\}}xP|D]H}|j	dk	rt||j	krtt�d||�qL|�
||�}|j|�||f�qLWq>WdS)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_filesr9rr,�devnullrkrtrXrA�
_load_filerK�append)rN�config_filesrB�filesrcrdr$r$r%rP�s
z Configuration._load_config_files)rBrcrcCsPt�d||�|�|�}x2|��D]&}|�|�}|j|�|�||��q"W|S)Nz'For variant '%s', will try loading '%s')rk�verbose�_construct_parser�sectionsrXrLru�_normalized_keys)rNrBrcrdrerXr$r$r%rzs

zConfiguration._load_file)rcrc
Cs�t��}tj�|�r�t�d�}y|j||d�WnTtk
rXt	d|�d�|d��Yn.tj
k
r�}zt	|d��Wdd}~XYnX|S)NF)�encodingzcontains invalid z characters)�reasonrc)rr)�configparser�RawConfigParserr,r-�exists�locale�getpreferredencoding�read�UnicodeDecodeErrorr
�Error)rNrcrdZlocale_encodingrrr$r$r%rs

zConfiguration._construct_parsercCs"|jtj�|�d|����dS)z.Loads configuration from environment variablesz:env:N)rLr9rrur��get_environ_vars)rNr$r$r%rQ*sz$Configuration._load_environment_vars)rerXrcCs2i}x(|D] \}}|dt|�}|||<q
W|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&)rNrerX�
normalizedr�valrYr$r$r%r�0s
zConfiguration._normalized_keysccsHxBtj��D]4\}}|�d�r|dd���}|tkr||fVqWdS)z@Returns a generator with all environmental vars with prefix PIP_�PIP_�N)r,�environrXr#r!�ENV_NAMES_IGNORED)rNrYr�rr$r$r%r�>s

zConfiguration.get_environ_varsccs�tj�dd�}t�}tj|tjfV|jo>|o<tj�|�}|rVtj	|tj	fVtj
|tj
fV|dk	r�tj|gfVntjgfVdS)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 ergononmic to display
        things in the same order as OVERRIDE_ORDER
        �PIP_CONFIG_FILEN)r,r��getr>r9rr@r-r�rrr)rNZenv_config_filer|�should_load_user_configr$r$r%rxGszConfiguration.iter_config_files)rBrcCs
|j|S)z#Get values present in a config file)rL)rNrBr$r$r%�get_values_in_configgsz"Configuration.get_values_in_configcCs*|js
t�|j|j}|s"td��|dS)Nz4Fatal Internal error [id=2]. Please report as a bug.���)rArSrKr	)rN�parsersr$r$r%rTks
z#Configuration._get_parser_to_modify)rcrdrcCs"||f}||jkr|j�|�dS)N)rMr{)rNrcrd�file_parser_tupler$r$r%rbys
zConfiguration._mark_as_modifiedcCs|jj�d|j�d�S)N�(�))rO�__name__rW)rNr$r$r%�__repr__~szConfiguration.__repr__)N)%r��
__module__�__qualname__�__doc__�boolrrrErR�strrVrrrrXr\rfrirsr^�propertyrrWrPr�rzrrQr�r�rrxr�rTrbr��
__classcell__r$r$)rOr%r?Ws0	
	 r?),r�r�r�r,r5�typingrrrrrrr�pip._internal.exceptionsr	r
Zpip._internal.utilsr�pip._internal.utils.compatr�pip._internal.utils.loggingr
�pip._internal.utils.miscrrr�r�rr/r�r9rrrrrrJrFr�rkr&r+r>r?r$r$r$r%�<module>s6$