HEX
Server: LiteSpeed
System: Linux php-prod-1.spaceapp.ru 5.15.0-157-generic #167-Ubuntu SMP Wed Sep 17 21:35:53 UTC 2025 x86_64
User: sport3497 (1034)
PHP: 8.1.33
Disabled: NONE
Upload Files
File: //usr/local/lib/python3.10/dist-packages/pip/_internal/__pycache__/configuration.cpython-310.pyc
o

��h�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�r|dd�}|S)zAMake a name consistent regardless of source (environment or file)�_�-z--�N)�lower�replace�
startswith)r�r"�F/usr/local/lib/python3.10/dist-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>Hs�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_filesGs�

�
�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"�r0�variantr"r"r#�
<dictcomp>u��z*Configuration.__init__.<locals>.<dictcomp>cSsi|]}|i�qSr"r"rEr"r"r#rGxrH)�super�__init__�VALID_LOAD_ONLYr�formatr.�map�reprr@rB�OVERRIDE_ORDER�_parsers�_config�_modified_parsers)�selfr@rB��	__class__r"r#rJhs 
����
zConfiguration.__init__cCs|��|js
|��dSdS)z<Loads configuration from configuration files and environmentN)�_load_config_filesr@�_load_environment_vars�rSr"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)rB�_get_parser_to_modify�
IndexErrorrXr"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�itemsrXr"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)rSra�orig_key�clean_config�file_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_onlyrBr[r*�has_section�add_section�setrQ�
setdefault�_mark_as_modified)rSrarj�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.rbNz4Fatal Internal error [id=1]. Please report as a bug.)
r$rkrBr[rQrr*rl�
remove_optionr`�remove_sectionrpre)rSrarfrqrrrsrr"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: )rkrR�logger�inforr,r-�dirname�open�write�OSErrorr)rSrqrr�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)rBrry�debugrXr"r"r#rk�s
z$Configuration._ensure_have_load_only�dict[str, dict[str, Any]]cCs"i}tD]
}|�|j|�q|S)z3A dictionary representing the loaded configuration.)rOrdrQ)rS�retvalrFr"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_filesr9rr,�devnullryr�r`rB�
_load_filerP�append)rS�config_filesrF�filesrqrrr"r"r#rVs���z Configuration._load_config_filesrFr
rq�RawConfigParsercCsbt�d||�|�|�}|��D]}|�|�}|j|�|i�|j||�|�||��q|S)Nz'For variant '%s', will try loading '%s')	ry�verbose�_construct_parser�sectionsr`rQrord�_normalized_keys)rSrFrqrrrsr`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)�reasonrq)r�)�configparserr�r,r-�exists�locale�getpreferredencoding�read�UnicodeDecodeErrorr�Error)rSrqrr�locale_encodingr�r"r"r#r�"s 

�
�
��zConfiguration._construct_parsercCs:|jtj�di�|jtjd�|�d|����dS)z.Loads configuration from environment variablesz:env:N)rQr9rrordr��get_environ_varsrXr"r"r#rW7s�z$Configuration._load_environment_varsrsr`�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$)rSrsr`�
normalizedr�valrar"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`r!r�ENV_NAMES_IGNORED)rSrar�rr"r"r#r�Ls�

��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>r9rr@r-r�rrr)rS�env_config_filer��should_load_user_configr"r"r#r�Us��zConfiguration.iter_config_filescCs
|j|S)z#Get values present in a config file)rQ)rSrFr"r"r#�get_values_in_configus
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.���)rBrPr)rS�parsersr"r"r#r[ys
�z#Configuration._get_parser_to_modifyrrcCs&||f}||jvr|j�|�dSdS�N)rRr�)rSrqrr�file_parser_tupler"r"r#rp�s
�zConfiguration._mark_as_modifiedcCs|jj�d|j�d�S)N�(�))rU�__name__r_rXr"r"r#�__repr__�szConfiguration.__repr__r�)r@rArBrCrrD)rrD)rrZ)rr^)rarrr)rarrjrrrD)rarrrD)rr�)rFr
rqrrr�)rqrrr�)rsrr`r^rr�)rr�)rr�)rFr
rr�)rr�)rqrrrr�rrD)rr)r��
__module__�__qualname__�__doc__rJrYr]r`rirtrwr�rk�propertyr_rVr�r�rWr�r�r�r�r[rpr��
__classcell__r"r"rTr#r?Zs0


	



"







	
 

r?)rrrr)rrrr%)rr+)+r��
__future__rr�r�r,r5�collections.abcr�typingrr�pip._internal.exceptionsrr�pip._internal.utilsr�pip._internal.utils.compatr	�pip._internal.utils.loggingr
�pip._internal.utils.miscrrr�rr
r/r�r9rrrrrrOrKr�ryr$r*r>r?r"r"r"r#�<module>s>

�