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/lib/python3.9/site-packages/pip/_internal/commands/__pycache__/configuration.cpython-39.pyc
a

?�f�$�@s�ddlZddlZddlZddlmZddlmZmZddlm	Z	m
Z
mZddlm
Z
ddlmZddlmZmZddlmZer�dd	lmZmZmZdd
lmZddlmZe�e�ZGdd
�d
e�ZdS)�N)�Command)�ERROR�SUCCESS)�
Configuration�get_configuration_files�kinds)�PipError)�
indent_log)�get_prog�write_output)�MYPY_CHECK_RUNNING)�List�Any�Optional)�Values)�Kindc@s�eZdZdZdZdZdd�Zdd�Zdd	�Zd
d�Z	dd
�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zdd�Zd S)!�ConfigurationCommandah
    Manage local and global configuration.

    Subcommands:

    - list: List the active configuration (or from the file specified)
    - edit: Edit the configuration file in an editor
    - get: Get the value associated with name
    - set: Set the name=value
    - unset: Unset the value associated with name
    - debug: List the configuration files and values defined under them

    If none of --user, --global and --site are passed, a virtual
    environment configuration file is used if one is active and the file
    exists. Otherwise, all modifications happen on the to the user file by
    default.
    Ta
        %prog [<file-option>] list
        %prog [<file-option>] [--editor <editor-path>] edit

        %prog [<file-option>] get name
        %prog [<file-option>] set name value
        %prog [<file-option>] unset name
        %prog [<file-option>] debug
    cCsl|jjdddddd�|jjdddd	d
d�|jjdddd	d
d�|jjdddd	dd�|j�d|j�dS)Nz--editor�editorZstorez\Editor to use to edit the file. Uses VISUAL or EDITOR environment variables if not provided.)�dest�action�default�helpz--global�global_file�
store_trueFz+Use the system-wide configuration file onlyz--user�	user_filez$Use the user configuration file onlyz--site�	site_filez3Use the current environment configuration file onlyr)Zcmd_optsZ
add_option�parserZinsert_option_group��self�r�H/usr/lib/python3.9/site-packages/pip/_internal/commands/configuration.py�add_options8s:����z ConfigurationCommand.add_optionsc
Cs|j|j|j|j|j|jd�}|r.|d|vrHt�dd�t	|���t
S|d}z|j||dvd�}Wn8ty�}z t�|j
d�t
WYd}~Sd}~00t|j|d�|_|j��z||||dd��Wn:t�y}z t�|j
d�t
WYd}~Sd}~00tS)	N)�list�edit�get�set�unset�debugrzNeed an action (%s) to perform.z, )r$r%r&r#)�
need_value)�isolated�	load_only�)�list_values�open_in_editor�get_name�set_name_value�
unset_name�list_config_values�logger�error�join�sortedr�_determine_filer�argsrZ
isolated_mode�
configuration�loadr)r�optionsr7�handlersrr*�errr �run_s>�
��
�
zConfigurationCommand.runcCs�dd�tj|jftj|jftj|jffD�}|s`|s8dStdd�t�tjD��rXtjStjSnt	|�dkrt|dSt
d��dS)NcSsg|]\}}|r|�qSrr)�.0�key�valuerrr �
<listcomp>�s�z8ConfigurationCommand._determine_file.<locals>.<listcomp>css|]}tj�|�VqdS)N)�os�path�exists)r>Zsite_config_filerrr �	<genexpr>�s�z7ConfigurationCommand._determine_file.<locals>.<genexpr>r+rzLNeed exactly one file to operate upon (--user, --site, --global) to perform.)rZUSERrZGLOBALrZSITEr�anyr�lenr)rr:r(Zfile_optionsrrr r6�s$


�
��z$ConfigurationCommand._determine_filecCs8|j|ddd�t|j���D]\}}td||�qdS)Nr"r��n�%s=%r)�_get_n_argsr5r8�itemsr�rr:r7r?r@rrr r,�sz ConfigurationCommand.list_valuescCs*|j|ddd�}|j�|�}td|�dS)Nz
get [name]r+rHz%s)rKr8Z	get_valuerrMrrr r.�szConfigurationCommand.get_namecCs.|j|ddd�\}}|j�||�|��dS)Nzset [name] [value]�rH)rKr8Z	set_value�_save_configurationrMrrr r/�sz#ConfigurationCommand.set_name_valuecCs(|j|ddd�}|j�|�|��dS)Nzunset [name]r+rH)rKr8Zunset_valuerO)rr:r7r?rrr r0�szConfigurationCommand.unset_namec
Cs�|j|ddd�|��t|j���D]h\}}td|�|D]P}t��6tj�	|�}td||�|rn|�
|�Wd�q<1s�0Yq<q&dS)z9List config key-value pairs across different config filesr'rrH�%s:z%s, exists: %rN)rK�print_env_var_valuesr5r8Ziter_config_filesrr	rBrCrD�print_config_file_values)rr:r7�variant�files�fnameZfile_existsrrr r1�s
�z'ConfigurationCommand.list_config_valuesc	CsP|j�|���D]:\}}t��td||�Wd�q1s@0YqdS)z.Get key-value pairs from the file of a variantz%s: %sN)r8Zget_values_in_configrLr	r)rrS�namer@rrr rR�s
�z-ConfigurationCommand.print_config_file_valuescCsftdd�t��Bt|j���D]"\}}d�|���}td||�q Wd�n1sX0YdS)z5Get key-values pairs present as environment variablesrP�env_varzPIP_{}rJN)rr	r5r8Zget_environ_vars�format�upper)rr?r@rWrrr rQ�s

z)ConfigurationCommand.print_env_var_valuesc
Csr|�|�}|j��}|dur$td��zt�||g�Wn6tjyl}ztd�|j���WYd}~n
d}~00dS)Nz%Could not determine appropriate file.z*Editor Subprocess exited with exit code {})	�_determine_editorr8Zget_file_to_editr�
subprocessZ
check_callZCalledProcessErrorrX�
returncode)rr:r7rrUr<rrr r-�s

��z#ConfigurationCommand.open_in_editorcCs<t|�|kr$d�|t�|�}t|��|dkr4|dS|SdS)zJHelper to make sure the command got the right number of arguments
        zJGot unexpected number of arguments, expected {}. (example: "{} config {}")r+rN)rGrXr
r)rr7ZexamplerI�msgrrr rK�s��z ConfigurationCommand._get_n_argscCs8z|j��Wn$ty2t�d�td��Yn0dS)Nz:Unable to save configuration. Please report this as a bug.zInternal Error.)r8Zsave�	Exceptionr2�	exceptionrrrrr rOs�z(ConfigurationCommand._save_configurationcCsD|jdur|jSdtjvr$tjdSdtjvr8tjdStd��dS)NZVISUALZEDITORz"Could not determine editor to use.)rrB�environr)rr:rrr rZs




z&ConfigurationCommand._determine_editorN)�__name__�
__module__�__qualname__�__doc__Zignore_require_venvZusager!r=r6r,r.r/r0r1rRrQr-rKrOrZrrrr rs"
'.	r) ZloggingrBr[Zpip._internal.cli.base_commandrZpip._internal.cli.status_codesrrZpip._internal.configurationrrrZpip._internal.exceptionsrZpip._internal.utils.loggingr	Zpip._internal.utils.miscr
rZpip._internal.utils.typingr�typingr
rrZoptparserrZ	getLoggerrar2rrrrr �<module>s