� ��^i�"����ddlZddlZddlZddlmZddlmZmZmZddl m Z ddl m Z m Z ddlmZmZmZmZddlmZddlmZdd lmZmZeje��ZGd �d e ��ZdS) �N)�Values)�Any�List�Optional)�Command)�ERROR�SUCCESS)� Configuration�Kind�get_configuration_files�kinds)�PipError)� indent_log)�get_prog� write_outputc�v�eZdZdZdZdZdd�Zdedee de fd �Z ded e de efd �Zdedee ddfd �Zdedee ddfd �Zdedee ddfd�Zdedee ddfd�Zdedee ddfd�Zdeddfd�Zdd�Zdedee ddfd�Zdee de de defd�Zdd�Zdede fd�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 [] list %prog [] [--editor ] edit %prog [] get name %prog [] set name value %prog [] unset name %prog [] debug �returnNc�>�|j�ddddd���|j�dddd d ���|j�d d dd d ���|j�dddd d���|j�d|j��dS)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��selfs ��/builddir/build/BUILDROOT/alt-python311-pip-21.3.1-4.el8.x86_64/opt/alt/python311/lib/python3.11/site-packages/pip/_internal/commands/configuration.py� add_optionsz ConfigurationCommand.add_options4s��� � � � � ����9� !� � � � � � � � ����>� !� � � � � � � � ����7� !� � � � � � � � ����F� !� � � � � �'�'��4�=�9�9�9�9�9��options�argsc���|j|j|j|j|j|jd�}|r |d|vrBt �dd�t|������tS|d} |� ||dv���}nC#t$r6}t �|j d��tcYd}~Sd}~wwxYwt|j|���|_|j��� ||||dd���nC#t$r6}t �|j d��tcYd}~Sd}~wwxYwt$S) N)�list�edit�get�set�unset�debugrzNeed an action (%s) to perform.z, )r.r/r0r-)� 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_filerr*r � isolated_mode� configuration�loadr )r%r)r*�handlersrr4�es r&�runzConfigurationCommand.runZs����$��'��=��&��_��,�  � ��� �t�A�w�h�.�.� �L�L�1�� � �&��*�*�+�+� � � ��L��a��� ��,�,��V�/N�%N�-���I�I��� � � � �L�L����� #� #� #��L�L�L�L�L�L����� ���� +��*�i� � � ��� ����!�!�!� � �H�V� �W�d�1�2�2�h� /� /� /� /��� � � � �L�L����� #� #� #��L�L�L�L�L�L����� �����s<�?B� C�#+C�C�C�D,�, E,�6+E'�!E,�'E,r2c��d�tj|jftj|jftj|jffD��}|sQ|sdStd�t��tjD����r tjStjSt|��dkr|dStd���)Nc��g|] \}}|�|�� S�rI)�.0�key�values r&� z8ConfigurationCommand._determine_file..�s4�� � � ���U� � � � � � r(c3�TK�|]#}tj�|��V��$dS)N)�os�path�exists)rJ�site_config_files r&� z7ConfigurationCommand._determine_file..�sE������$�����/�0�0������r(r5rzLNeed exactly one file to operate upon (--user, --site, --global) to perform.) r �USERr�GLOBALr�SITEr�anyr �lenr)r%r)r2� file_optionss r&r@z$ConfigurationCommand._determine_file�s��� � ���W�.�/���w�2�3���W�.�/�� � � � �� #�� "��t����(?�(A�(A�%�*�(M������ "��z�!��z�!� �� � �!� #� #���?� "�� 5� � � r(c��|�|dd���t|j�����D]\}}t d||���dS)Nr,r��n�%s=%r)� _get_n_argsr?rB�itemsr�r%r)r*rKrLs r&r6z ConfigurationCommand.list_values�sf�� ����v���+�+�+� ��!3�!9�!9�!;�!;�<�<� .� .�J�C�� ��#�u� -� -� -� -� .� .r(c��|�|dd���}|j�|��}td|��dS)Nz get [name]r5r[z%s)r^rB� get_valuerr`s r&r8zConfigurationCommand.get_name�sH�����t�\�Q��7�7���"�,�,�S�1�1���T�5�!�!�!�!�!r(c��|�|dd���\}}|j�||��|���dS)Nzset [name] [value]�r[)r^rB� set_value�_save_configurationr`s r&r9z#ConfigurationCommand.set_name_value�sR���%�%�d�,@�A�%�F�F� ��U� ��$�$�S�%�0�0�0� � � �"�"�"�"�"r(c��|�|dd���}|j�|��|���dS)Nz unset [name]r5r[)r^rB� unset_valuerf)r%r)r*rKs r&r:zConfigurationCommand.unset_name�sK�����t�^�q��9�9�� ��&�&�s�+�+�+� � � �"�"�"�"�"r(c��|�|dd���|���t|j�����D]�\}}t d|��|D]o}t ��5tj� |��}t d||��|r|� |��ddd��n #1swxYwY�p��dS)z9List config key-value pairs across different config filesr1rr[�%s:z%s, exists: %rN) r^�print_env_var_valuesr?rB�iter_config_filesrrrOrPrQ�print_config_file_values)r%r)r*�variant�files�fname� file_existss r&r;z'ConfigurationCommand.list_config_values�s+�� ����w�!��,�,�,� �!�!�#�#�#�%�T�%7�%I�%I�%K�%K�L�L� ?� ?�N�G�U� ��� (� (� (�� ?� ?���\�\�?�?�"$�'�.�.��"7�"7�K� �!1�5�+�F�F�F�"�?��5�5�g�>�>�>� ?�?�?�?�?�?�?�?�?�?�?����?�?�?�?�� ?� ?� ?s�:AC�C �C rnc���|j�|�����D]<\}}t��5t d||��ddd��n #1swxYwY�=dS)z.Get key-value pairs from the file of a variantz%s: %sN)rB�get_values_in_configr_rr)r%rn�namerLs r&rmz-ConfigurationCommand.print_config_file_values�s����-�B�B�7�K�K�Q�Q�S�S� 4� 4�K�D�%���� 4� 4��X�t�U�3�3�3� 4� 4� 4� 4� 4� 4� 4� 4� 4� 4� 4���� 4� 4� 4� 4�� 4� 4s�A�A" �%A" c��tdd��t��5t|j�����D]-\}}d|�����}td||���. ddd��dS#1swxYwYdS)z5Get key-values pairs present as environment variablesrj�env_var�PIP_r]N)rrr?rB�get_environ_vars�upper)r%rKrLrvs r&rkz)ConfigurationCommand.print_env_var_values�s����U�I�&�&�&� �\�\� 6� 6�$�T�%7�%H�%H�%J�%J�K�K� 6� 6� ��U�.������.�.���W�g�u�5�5�5�5� 6� 6� 6� 6� 6� 6� 6� 6� 6� 6� 6� 6� 6���� 6� 6� 6� 6� 6� 6s�AB�B� Bc�.�|�|��}|j���}|�td��� t j||g��dS#tj$r,}td�|j�����d}~wwxYw)Nz%Could not determine appropriate file.z*Editor Subprocess exited with exit code {}) �_determine_editorrB�get_file_to_editr� subprocess� check_call�CalledProcessError�format� returncode)r%r)r*rrprEs r&r7z#ConfigurationCommand.open_in_editor�s����'�'��0�0���"�3�3�5�5�� �=��B�C�C� C� � � !�6�5�/� 2� 2� 2� 2� 2���,� � � ��<�C�C�A�L�Q�Q��� ����� ���s�A�B�('B�B�exampler\c��t|��|kr2d�|t��|��}t|���|dkr|dS|S)zAHelper to make sure the command got the right number of argumentszJGot unexpected number of arguments, expected {}. (example: "{} config {}")r5r)rXr�rr)r%r*r�r\�msgs r&r^z ConfigurationCommand._get_n_args�sU�� �t�9�9��>�>�,��f�Q�� � �G�,�,� ��3�-�-� � ��6�6���7�N��Kr(c�� |j���dS#t$r*t�d��t d���wxYw)Nz:Unable to save configuration. Please report this as a bug.zInternal Error.)rB�save� Exceptionr<� exceptionrr$s r&rfz(ConfigurationCommand._save_configuration�si�� .� � � #� #� %� %� %� %� %��� .� .� .� � � �L� � � ��,�-�-� -�  .���s ��4Ac��|j�|jSdtjvrtjdSdtjvrtjdStd���)N�VISUAL�EDITORz"Could not determine editor to use.)rrO�environr)r%r)s r&r{z&ConfigurationCommand._determine_editorsU�� �>� %��>� !� ��� #� #��:�h�'� '� ��� #� #��:�h�'� '��?�@�@� @r()rN)�__name__� __module__� __qualname__�__doc__�ignore_require_venv�usager'rr�str�intrF�boolrr r@r6r8r9r:r;rmrkr7rr^rfr{rIr(r&rrsS��������$�� �E�$:�$:�$:�$:�L+�6�+��c��+�s�+�+�+�+�Z �v� �4� �H�T�N� � � � �<.�6�.��c��.�t�.�.�.�.� "��"�d�3�i�"�D�"�"�"�"� #�f�#�D��I�#�$�#�#�#�#� #�&�#��S� �#�d�#�#�#�#� ?�&�?��S� �?�d�?�?�?�?� 4��4��4�4�4�4� 6�6�6�6� �f� �D��I� �$� � � � � ��S� � �C� �C� �C� � � � � .� .� .� .�A��A�C�A�A�A�A�A�Ar(r)�loggingrOr}�optparser�typingrrr�pip._internal.cli.base_commandr�pip._internal.cli.status_codesrr �pip._internal.configurationr r r r �pip._internal.exceptionsr�pip._internal.utils.loggingr�pip._internal.utils.miscrr� getLoggerr�r<rrIr(r&�r�sQ������ � � � �����������&�&�&�&�&�&�&�&�&�&�2�2�2�2�2�2�9�9�9�9�9�9�9�9������������� .�-�-�-�-�-�2�2�2�2�2�2�;�;�;�;�;�;�;�;� �� �8� $� $��tA�tA�tA�tA�tA�7�tA�tA�tA�tA�tAr(