OwlCyberSecurity - MANAGER
Edit File: configuration.cpython-310.pyc
o ����ƚRe�"����������������������@���s����d�dl�Z�d�dlZd�dlZd�dlmZ�d�dlmZmZmZ�d�dl m Z �d�dlmZm Z �d�dlmZmZmZmZ�d�dlmZ�d�dlmZ�d�d lmZmZ�e��e�ZG�d d��de �ZdS�)�����N)�Values)�Any�List�Optional)�Command)�ERROR�SUCCESS)� Configuration�Kind�get_configuration_files�kinds)�PipError)� indent_log)�get_prog�write_outputc�������������������@���sH��e�Zd�ZdZdZdZd(dd�Zded ee �de fd d�Zdedede e�fd d�Zded ee �ddfdd�Zded ee �ddfdd�Zded ee �ddfdd�Zded ee �ddfdd�Zded ee �ddfdd�Zdeddfdd�Zd(dd�Zded ee �ddfdd�Zd ee �d e d!e defd"d#�Zd(d$d%�Zdede fd&d'�ZdS�))�ConfigurationCommandaa�� 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 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 �returnNc�����������������C���sl���|�j�jdddd�dd��|�j�jdddd d d��|�j�jdddd d d��|�j�jdddd dd��|�j�d|�j���d�S�)Nz--editor�editor�storez\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���)�cmd_opts� add_option�parser�insert_option_group��self��r#�����/builddir/build/BUILDROOT/alt-python310-pip-21.3.1-3.el8.x86_64/opt/alt/python310/lib/python3.10/site-packages/pip/_internal/commands/configuration.py�add_options4���s:�������z ConfigurationCommand.add_options�options�argsc�������������� ���C���s��|�j�|�j|�j|�j|�j|�jd�}|r|d�|vr$t�dd�t |����t S�|d�}z|�j||dv�d�}W�n�tyO�}�zt�|j d���t W��Y�d�}~S�d�}~ww�t|j|d�|�_|�j����z||�||dd�����W�tS��ty��}�zt�|j d���t W��Y�d�}~S�d�}~ww�) N)�list�edit�get�set�unset�debugr���zNeed 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 ���r'���r ���� isolated_mode� configuration�loadr���)r"���r&���r'����handlersr���r0����er#���r#���r$����runZ���sF���� � ���� ���zConfigurationCommand.runr.���c�����������������C���sz���dd��t�j|jft�j|jft�j|jffD��}|s/|sd�S�tdd��t��t�j�D���r,t�jS�t�jS�t |�dkr9|d�S�t d��)Nc�����������������S���s���g�|�]\}}|r|�qS�r#���r#���)�.0�key�valuer#���r#���r$���� <listcomp>����s������z8ConfigurationCommand._determine_file.<locals>.<listcomp>c�����������������s���s�����|�] }t�j�|�V��qd�S�)N)�os�path�exists)rC����site_config_filer#���r#���r$���� <genexpr>����s ����� � �z7ConfigurationCommand._determine_file.<locals>.<genexpr>r1���r���zLNeed exactly one file to operate upon (--user, --site, --global) to perform.)r����USERr����GLOBALr����SITEr����anyr����lenr ���)r"���r&���r.���Zfile_optionsr#���r#���r$���r<�������s&��� �� ��z$ConfigurationCommand._determine_filec�����������������C���s8���|�j�|ddd��t|�j����D�] \}}td||��qd�S�)Nr(���r�����n�%s=%r)�_get_n_argsr;���r>����itemsr����r"���r&���r'���rD���rE���r#���r#���r$���r2�������s����z ConfigurationCommand.list_valuesc�����������������C���s*���|�j�|ddd�}|�j�|�}td|��d�S�)Nz get [name]r1���rQ���z%s)rT���r>���� get_valuer���rV���r#���r#���r$���r4�������s���zConfigurationCommand.get_namec�����������������C���s.���|�j�|ddd�\}}|�j�||��|�����d�S�)Nzset [name] [value]����rQ���)rT���r>���� set_value�_save_configurationrV���r#���r#���r$���r5�������s���z#ConfigurationCommand.set_name_valuec�����������������C���s(���|�j�|ddd�}|�j�|��|�����d�S�)Nzunset [name]r1���rQ���)rT���r>����unset_valuerZ���)r"���r&���r'���rD���r#���r#���r$���r6�������s���zConfigurationCommand.unset_namec�������������� ���C���s����|�j�|ddd��|�����t|�j����D�]4\}}td|��|D�](}t����tj� |�}td||��|r7|�� |��W�d����n1�sAw���Y��qqdS�)z9List config key-value pairs across different config filesr-���r���rQ����%s:z%s, exists: %rN)rT����print_env_var_valuesr;���r>����iter_config_filesr���r���rG���rH���rI����print_config_file_values)r"���r&���r'����variant�files�fnameZfile_existsr#���r#���r$���r7�������s��� �����z'ConfigurationCommand.list_config_valuesr`���c�������������� ���C���sP���|�j��|����D�]\}}t����td||��W�d����n1�s w���Y��qdS�)z.Get key-value pairs from the file of a variantz%s: %sN)r>����get_values_in_configrU���r���r���)r"���r`����namerE���r#���r#���r$���r_�������s������z-ConfigurationCommand.print_config_file_valuesc�����������������C���sh���t�dd��t���"�t|�j����D�]\}}d|������}t�d||��qW�d����dS�1�s-w���Y��dS�)z5Get key-values pairs present as environment variablesr\����env_var�PIP_rS���N)r���r���r;���r>����get_environ_vars�upper)r"���rD���rE���re���r#���r#���r$���r]�������s��� �"�z)ConfigurationCommand.print_env_var_valuesc�������������� ���C���sd���|���|�}|�j���}|d�u�rtd��z t�||g��W�d�S��tjy1�}�ztd�|j���d�}~ww�)Nz%Could not determine appropriate file.z*Editor Subprocess exited with exit code {}) �_determine_editorr>����get_file_to_editr ���� subprocess� check_call�CalledProcessError�format� returncode)r"���r&���r'���r���rb���rA���r#���r#���r$���r3�������s��� ���z#ConfigurationCommand.open_in_editor�examplerR���c�����������������C���s8���t�|�|krd�|t��|�}t|��|dkr|d�S�|S�)zAHelper to make sure the command got the right number of argumentszJGot unexpected number of arguments, expected {}. (example: "{} config {}")r1���r���)rP���rn���r���r ���)r"���r'���rp���rR����msgr#���r#���r$���rT�������s����z ConfigurationCommand._get_n_argsc�����������������C���s2���z|�j�����W�d�S��ty���t�d��td��w�)Nz:Unable to save configuration. Please report this as a bug.zInternal Error.)r>����save� Exceptionr8���� exceptionr ���r!���r#���r#���r$���rZ�������s�����z(ConfigurationCommand._save_configurationc�����������������C���s@���|j�d�ur|j�S�dtjv�rtjd�S�dtjv�rtjd�S�td��)NZVISUALZEDITORz"Could not determine editor to use.)r���rG����environr ���)r"���r&���r#���r#���r$���ri�����s��� z&ConfigurationCommand._determine_editor)r���N)�__name__� __module__�__qualname__�__doc__�ignore_require_venv�usager%���r���r����str�intrB����boolr���r ���r<���r2���r4���r5���r6���r7���r_���r]���r3���r���rT���rZ���ri���r#���r#���r#���r$���r������s$���� &- r���)�loggingrG���rk����optparser����typingr���r���r����pip._internal.cli.base_commandr����pip._internal.cli.status_codesr���r����pip._internal.configurationr ���r ���r���r����pip._internal.exceptionsr ����pip._internal.utils.loggingr����pip._internal.utils.miscr���r���� getLoggerrv���r8���r���r#���r#���r#���r$����<module>���s����