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: //opt/osm/venv/lib/python3.10/site-packages/pip/_internal/__pycache__/configuration.cpython-310.pyc
o

5i�8�@s"dZddlmZddlZddlZddlZddlZddlmZddl	m
Z
mZddlm
Z
mZddlmZddlmZdd	lmZdd
lmZmZejZede�ZerTdnd
ZdZedddddd�Zejejej ej!ej"fZ#ejejej fZ$ee%�Z&d"dd�Z'd#dd�Z(d$dd�Z)Gd d!�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
�)�annotationsN)�Iterable)�Any�NewType)�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�str�returncCs|���dd�}|�d�}|S)zAMake a name consistent regardless of source (environment or file)�_�-z--)�lower�replace�removeprefix)r�r!�I/opt/osm/venv/lib/python3.10/site-packages/pip/_internal/configuration.py�_normalize_name5s
r#�	list[str]cCs(d|vrd|�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)�dict[Kind, list[str]]cCstdd�t�d�D�}tj�tjt�}tj�tj�d�t	rdndt�}tj�t�
d�t�}tj|tj
|gtj||giS)NcSsg|]	}tj�|t��qSr!)�os�path�join�CONFIG_BASENAME)�.0r,r!r!r"�
<listcomp>Gs�z+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_filesFs�

�
�r=cs�eZdZdZdEdF�fd	d
�
ZdGdd�ZdHdd�ZdIdd�ZdJdd�ZdKdd�Z	dLdd�Z
dGdd�ZdGdd �Ze
dMd"d#��ZdGd$d%�ZdNd*d+�ZdOd,d-�ZdGd.d/�ZdPd3d4�ZdQd6d7�ZdRd9d:�ZdSd;d<�ZdTd>d?�ZdUdAdB�ZdVdCdD�Z�ZS)W�
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�bool�	load_only�Kind | Noner�Nonecsjt���|dur|tvrtd�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!�r/�variantr!r!r"�
<dictcomp>t��z*Configuration.__init__.<locals>.<dictcomp>cSsi|]}|i�qSr!r!rDr!r!r"rFwrG)�super�__init__�VALID_LOAD_ONLYr�formatr-�map�reprr?rA�OVERRIDE_ORDER�_parsers�_config�_modified_parsers)�selfr?rA��	__class__r!r"rIgs 
����
zConfiguration.__init__cCs|��|js
|��dSdS)z<Loads configuration from configuration files and environmentN)�_load_config_filesr?�_load_environment_vars�rRr!r!r"�load|s�zConfiguration.load�
str | NonecCs6|jdus	Jd��z|��dWStyYdSw)z7Returns the file with highest priority in configurationNz)Need to be specified a file to be editingr)rA�_get_parser_to_modify�
IndexErrorrWr!r!r"�get_file_to_edit�s�zConfiguration.get_file_to_edit�Iterable[tuple[str, Any]]cCs
|j��S)z`Returns key-value pairs like dict.items() representing the loaded
        configuration
        )�_dictionary�itemsrWr!r!r"r_�s
zConfiguration.items�keyrrcCsZ|}t|�}zi}|j��D]}|�|�q||WSty,t|�td|����w)z#Get a value from the configuration.�No such key - )r#r^�values�update�KeyErrorr)r)rRr`�orig_keyZclean_configZfile_valuesr!r!r"�	get_value�s
�zConfiguration.get_value�valuecCs�t|�}|��|js
J�|��\}}|dur.t|�\}}|�|�s'|�|�|�|||�|j|j�	|i�||j|j||<|�
||�dS)z$Modify a value in the configuration.N)r#�_ensure_have_load_onlyrArZr)�has_section�add_section�setrP�
setdefault�_mark_as_modified)rRr`rg�fname�parser�sectionrr!r!r"�	set_value�s


zConfiguration.set_valuecCs�|}t|�}|��|jsJ�|��\}}||j|j|vr.||j|jvr.td|����|durWt|�\}}|�|�rC|�||�sGtd��|�	|�sQ|�
|�|�||�z|j|j||=WdStyt|j|j|=YdSw)z#Unset a value in the configuration.raNz4Fatal Internal error [id=1]. Please report as a bug.)
r#rhrArZrPrr)ri�
remove_optionr_�remove_sectionrmrd)rRr`rernrorprr!r!r"�unset_value�s2
�
��

�zConfiguration.unset_valuecCs�|��|jD]D\}}t�d|�ttj�|��zt|d��
}|�	|�Wd�n1s/wYWqt
yK}z
td|�d|����d}~wwdS)z!Save the current in-memory state.z
Writing to %s�wNz:An error occurred while writing to the configuration file z: )rhrQ�logger�inforr+r,�dirname�open�write�OSErrorr)rRrnro�f�errorr!r!r"�save�s(��������zConfiguration.savecCs$|jdur	td��t�d|j�dS)Nz'Needed a specific file to be modifying.z$Will be working with %s variant only)rArrv�debugrWr!r!r"rh�s
z$Configuration._ensure_have_load_only�dict[str, dict[str, Any]]cCs"i}tD]
}|�|j|�q|S)z3A dictionary representing the loaded configuration.)rNrcrP)rR�retvalrEr!r!r"r^�szConfiguration._dictionarycCs�t|���}|tjdd�tjgkrt�d�dS|��D]+\}}|D]$}|j	dur8||j	kr8t�d||�q$|�
||�}|j|�||f�q$qdS)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_filesr8rr+�devnullrvrr_rA�
_load_filerO�append)rR�config_filesrE�filesrnror!r!r"rU�s���z Configuration._load_config_filesrEr
rn�RawConfigParsercCsbt�d||�|�|�}|��D]}|�|�}|j|�|i�|j||�|�||��q|S)Nz'For variant '%s', will try loading '%s')	rv�verbose�_construct_parser�sectionsr_rPrlrc�_normalized_keys)rRrErnrorpr_r!r!r"r�s

zConfiguration._load_filec
Cs|t��}tj�|�r<t�d�}z
|j||d�W|Sty*t	d|�d�|d��tj
y;}zt	|d��d}~ww|S)NF)�encodingzcontains invalid z characters)�reasonrn)r})�configparserr�r+r,�exists�locale�getpreferredencoding�read�UnicodeDecodeErrorr�Error)rRrnro�locale_encodingr}r!r!r"r�!s 

�
�
��zConfiguration._construct_parsercCs:|jtj�di�|jtjd�|�d|����dS)z.Loads configuration from environment variablesz:env:N)rPr8rrlrcr��get_environ_varsrWr!r!r"rV6s�z$Configuration._load_environment_varsrpr_�dict[str, Any]cCs.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#)rRrpr_�
normalizedr�valr`r!r!r"r�=s

zConfiguration._normalized_keys�Iterable[tuple[str, str]]ccsF�tj��D]\}}|�d�r |dd���}|tvr ||fVqdS)z@Returns a generator with all environmental vars with prefix PIP_�PIP_�N)r+�environr_�
startswithr�ENV_NAMES_IGNORED)rRr`r�rr!r!r"r�Ks�

��zConfiguration.get_environ_vars� Iterable[tuple[Kind, list[str]]]ccs��tj�dd�}t�}tj|tjfV|jo |otj�|�}|r,tj	|tj	fVtj
|tj
fV|durBtj|gfVdStjgfVdS)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=r8rr?r,r�rrr)rRZenv_config_filer��should_load_user_configr!r!r"r�Ts��zConfiguration.iter_config_filescCs
|j|S)z#Get values present in a config file)rP)rRrEr!r!r"�get_values_in_configts
z"Configuration.get_values_in_config�tuple[str, RawConfigParser]cCs*|jsJ�|j|j}|std��|dS)Nz4Fatal Internal error [id=2]. Please report as a bug.���)rArOr)rR�parsersr!r!r"rZxs
�z#Configuration._get_parser_to_modifyrocCs&||f}||jvr|j�|�dSdS�N)rQr�)rRrnro�file_parser_tupler!r!r"rm�s
�zConfiguration._mark_as_modifiedcCs|jj�d|j�d�S)N�(�))rT�__name__r^rWr!r!r"�__repr__�szConfiguration.__repr__r�)r?r@rArBrrC)rrC)rrY)rr])r`rrr)r`rrgrrrC)r`rrrC)rr�)rEr
rnrrr�)rnrrr�)rprr_r]rr�)rr�)rr�)rEr
rr�)rr�)rnrror�rrC)rr)r��
__module__�__qualname__�__doc__rIrXr\r_rfrqrtr~rh�propertyr^rUr�r�rVr�r�r�r�rZrmr��
__classcell__r!r!rSr"r>Ys0


	



"







	
 

r>)rrrr)rrrr$)rr*)+r��
__future__rr�r�r+r4�collections.abcr�typingrr�pip._internal.exceptionsrrZpip._internal.utilsr�pip._internal.utils.compatr	�pip._internal.utils.loggingr
�pip._internal.utils.miscrrr�rr
r.r�r8rrrrrrNrJr�rvr#r)r=r>r!r!r!r"�<module>s>

�