Sindbad~EG File Manager

Current Path : /usr/local/lib/python3.11/site-packages/pip/_internal/__pycache__/
Upload File :
Current File : //usr/local/lib/python3.11/site-packages/pip/_internal/__pycache__/configuration.cpython-311.pyc

�

�@�e�6����dZddlZddlZddlZddlZddlmZmZmZm	Z	m
Z
mZmZddl
mZmZddlmZddlmZddlmZddlmZmZejZe
d	e��Zerd
ndZdZed
dddd���Zejej ej!ej"ej#fZ$ej ejej!fZ%ee&��Z'dedefd�Z(dede	efd�Z)deee	effd�Z*Gd�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
�N)�Any�Dict�Iterable�List�NewType�Optional�Tuple)�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�returnc��|����dd��}|�d��r
|dd�}|S)zAMake a name consistent regardless of source (environment or file)�_�-z--�N)�lower�replace�
startswith)rs �F/usr/local/lib/python3.11/site-packages/pip/_internal/configuration.py�_normalize_namer'2sE���:�:�<�<����S�)�)�D����t�����A�B�B�x���K�c�`�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_messages  r&�_disassemble_keyr.:sO��
�$���
B�15�
B�
B�
B�	�!��/�/�/��:�:�c�1���r(c���d�tjd��D��}tj�t
jt��}tj�tj�d��trdndt��}tj�tj
d��t��}tj|tj
|gtj||giS)Nc�X�g|]'}tj�|t����(S�)�os�path�join�CONFIG_BASENAME)�.0r3s  r&�
<listcomp>z+get_configuration_files.<locals>.<listcomp>Es5�����04�����T�?�+�+���r(�pip�~z.pip)r�site_config_dirsr2r3r4�sys�prefixr5�
expanduserr
�user_config_dir�kindsrrr)�global_config_files�site_config_file�legacy_config_file�new_config_files    r&�get_configuration_filesrDDs�����8?�8P�QV�8W�8W������w�|�|�C�J��@�@������
����3����$���f�����
�g�l�l�7�#:�5�#A�#A�?�S�S�O�
��)�
�
�%�&�
�
�'��9��r(c�"��eZdZdZd"dedeeddf�fd�
Zd#d�Zdee	fd�Z
deee	e
ffd	�Zd
e	de
fd�Zd
e	de
ddfd
�Zd
e	ddfd�Zd#d�Zd#d�Zedee	e
ffd���Zd#d�Zdede	defd�Zde	defd�Zd#d�Zde	deee	e
fdee	e
ffd�Zdeee	e	ffd�Zdeeeee	ffd�Zdedee	e
ffd�Z dee	effd�Z!de	deddfd �Z"de	fd!�Z#�xZ$S)$�
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�	load_onlyrc
�z��t�����|�V|tvrMtd�d�t
tt���������||_||_	d�tD��|_d�tD��|_g|_
dS)Nz5Got invalid value for load_only - should be one of {}z, c��i|]}|g��Sr1r1�r6�variants  r&�
<dictcomp>z*Configuration.__init__.<locals>.<dictcomp>rs-��H
�H
�H
�#�G�R�H
�H
�H
r(c��i|]}|i��Sr1r1rKs  r&rMz*Configuration.__init__.<locals>.<dictcomp>us'��4
�4
�4
�#�G�R�4
�4
�4
r()�super�__init__�VALID_LOAD_ONLYr
�formatr4�map�reprrGrH�OVERRIDE_ORDER�_parsers�_config�_modified_parsers)�selfrGrH�	__class__s   �r&rPzConfiguration.__init__es����
��������� �Y�o�%E�%E�$�G�N�N��I�I�c�$��8�8�9�9�����
�
!��
�"���H
�H
�'5�H
�H
�H
��
�4
�4
�'5�4
�4
�4
���EG����r(c�h�|���|js|���dSdS)z<Loads configuration from configuration files and environmentN)�_load_config_filesrG�_load_environment_vars�rYs r&�loadzConfiguration.loadzs@�����!�!�!��}�	*��'�'�)�)�)�)�)�	*�	*r(c�|�|j�
Jd���	|���dS#t$rYdSwxYw)z7Returns the file with highest priority in configurationNz)Need to be specified a file to be editingr)rH�_get_parser_to_modify�
IndexErrorr^s r&�get_file_to_editzConfiguration.get_file_to_edit�sW���~�)�)�+V�)�)�)�	��-�-�/�/��2�2���	�	�	��4�4�	���s�-�
;�;c�4�|j���S)z`Returns key-value pairs like dict.items() representing the loaded
        configuration
        )�_dictionary�itemsr^s r&rfzConfiguration.items�s����%�%�'�'�'r(�keyc��|}t|��}	|j|S#t$r"t|��t	d|�����wxYw)z#Get a value from the configuration.�No such key - )r're�KeyErrorr.r
)rYrg�orig_keys   r&�	get_valuezConfiguration.get_value�sn�����c�"�"��	B��#�C�(�(���	B�	B�	B�
�S�!�!�!�$�%@�h�%@�%@�A�A�A�		B���s	� �,A�valuec��t|��}|���|jsJ�|���\}}|�St	|��\}}|�|��s|�|��|�|||��||j|j|<|�	||��dS)z$Modify a value in the configuration.N)
r'�_ensure_have_load_onlyrHrar.�has_section�add_section�setrW�_mark_as_modified)rYrgrm�fname�parser�sectionrs       r&�	set_valuezConfiguration.set_value�s����c�"�"���#�#�%�%�%��~�����2�2�4�4�
��v���,�S�1�1�M�G�T��%�%�g�.�.�
,��"�"�7�+�+�+��J�J�w��e�,�,�,�,1���T�^�$�S�)����u�f�-�-�-�-�-r(c��|}t|��}|���|jsJ�||j|jvrt	d|�����|���\}}|��t
|��\}}|�|��r|�||��st	d���|�	|��s|�
|��|�||��|j|j|=dS)z#Unset a value in the configuration.riNz4Fatal Internal error [id=1]. Please report as a bug.)r'rorHrWr
rar.rp�
remove_optionrf�remove_sectionrs)rYrgrkrtrurvrs       r&�unset_valuezConfiguration.unset_value�s'�����c�"�"���#�#�%�%�%��~�����d�l�4�>�2�2�2�$�%@�h�%@�%@�A�A�A��2�2�4�4�
��v���,�S�1�1�M�G�T��"�"�7�+�+�
�06�0D�0D�W�d�0S�0S�
�)�J����
�<�<��(�(�
/��%�%�g�.�.�.��"�"�5�&�1�1�1��L���(��-�-�-r(c��|���|jD]�\}}t�d|��t	t
j�|����	t|d��5}|�	|��ddd��n#1swxYwY��#t$r}td|�d|�����d}~wwxYwdS)z!Save the current in-memory state.z
Writing to %s�wNz:An error occurred while writing to the configuration file z: )rorX�logger�inforr2r3�dirname�open�write�OSErrorr
)rYrtru�f�errors     r&�savezConfiguration.save�s-���#�#�%�%�%�!�3�	�	�M�E�6��K�K���/�/�/�
�r�w���u�-�-�.�.�.�
��%��%�%�$���L�L��O�O�O�$�$�$�$�$�$�$�$�$�$�$����$�$�$�$����
�
�
�(�(��(�(� %�(�(��������
����	�	s<�)B'�9B�B'�B	�B'�"B	�#B'�'
C�1C�Cc�r�|j�td���t�d|j��dS)Nz'Needed a specific file to be modifying.z$Will be working with %s variant only)rHr
r~�debugr^s r&roz$Configuration._ensure_have_load_only�s6���>�!�$�%N�O�O�O����;�T�^�L�L�L�L�Lr(c�^�i}tD]"}|�|j|���#|S)z3A dictionary representing the loaded configuration.)rU�updaterW)rY�retvalrLs   r&rezConfiguration._dictionary�s9��
��%�	1�	1�G��M�M�$�,�w�/�0�0�0�0��
r(c���t|�����}|tjdd�tjgkrt�d��dS|���D]q\}}|D]i}|j	�(||j	krt�d||���1|�
||��}|j|�||f���j�rdS)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_filesr?rr2�devnullr~r�rfrH�
_load_filerV�append)rY�config_filesrL�filesrtrus      r&r\z Configuration._load_config_files�s���D�2�2�4�4�5�5����	�"�1�Q�3�'�B�J�<�7�7��L�L�A�
�
�
�
�F�*�0�0�2�2�	?�	?�N�G�U��

?�

?���>�-�'�T�^�2K�2K��L�L�!C�U�G�T�T�T������%�8�8���
�g�&�-�-�u�f�o�>�>�>�>�

?�	?�	?r(rLrtc�(�t�d||��|�|��}|���D]K}|�|��}|j|�|�||�����L|S)Nz'For variant '%s', will try loading '%s')r~�verbose�_construct_parser�sectionsrfrWr��_normalized_keys)rYrLrtrurvrfs      r&r�zConfiguration._load_files������@�'�5�Q�Q�Q��'�'��.�.�����(�(�	P�	P�G��L�L��)�)�E��L��!�(�(��)>�)>�w��)N�)N�O�O�O�O��
r(c�N�tj��}tj�|��rrtjd��}	|�||���nE#t$rtd|�d�|����tj
$r}t|����d}~wwxYw|S)NF)�encodingzcontains invalid z characters)�reasonrt)r�)�configparser�RawConfigParserr2r3�exists�locale�getpreferredencoding�read�UnicodeDecodeErrorr�Error)rYrtru�locale_encodingr�s     r&r�zConfiguration._construct_parsers����-�/�/��
�7�>�>�%� � �	E�$�9�%�@�@�O�

E����E�O��<�<�<�<��%�
�
�
�7�K��K�K�K������ �%�
E�
E�
E�7�e�D�D�D�D�����
E�����
s�A � -B"�
B�B"c��|jtj�|�d|�������dS)z.Loads configuration from environment variablesz:env:N)rWr?rr�r��get_environ_varsr^s r&r]z$Configuration._load_environment_vars*sL����U�]�#�*�*��!�!�'�4�+@�+@�+B�+B�C�C�	
�	
�	
�	
�	
r(rvrfc�N�i}|D]\}}|dzt|��z}|||<� |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')rYrvrf�
normalizedr�valrgs       r&r�zConfiguration._normalized_keys0sC���
��	"�	"�I�D�#��C�-�/�$�"7�"7�7�C�!�J�s�O�O��r(c#��K�tj���D]E\}}|�d��r+|dd����}|t
vr||fV��FdS)z@Returns a generator with all environmental vars with prefix PIP_�PIP_�N)r2�environrfr%r#�ENV_NAMES_IGNORED)rYrgr�rs    r&r�zConfiguration.get_environ_vars>st�����
�(�(�*�*�	$�	$�H�C���~�~�f�%�%�
$��1�2�2�w�}�}�����0�0�0���)�O�O�O��		$�	$r(c#��K�tj�dd��}t��}tj|tjfV�|jo!|otj�|��}|r tj	|tj	fV�tj
|tj
fV�|�tj|gfV�dStjgfV�dS)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 ergononmic to display
        things in the same order as OVERRIDE_ORDER
        �PIP_CONFIG_FILEN)r2r��getrDr?rrGr3r�rrr)rY�env_config_filer��should_load_user_configs    r&r�zConfiguration.iter_config_filesGs������*�.�.�):�D�A�A��.�0�0���l�L���6�6�6�6�6�'+�m�"3�#
��?������ ?� ?�9
��#�	7��*�l�5�:�6�6�6�6�6��j�,�u�z�2�2�2�2�2��&��)�o�.�.�.�.�.�.�.��)�R�-�����r(c��|j|S)z#Get values present in a config file)rW)rYrLs  r&�get_values_in_configz"Configuration.get_values_in_configgs���|�G�$�$r(c�j�|jsJ�|j|j}|std���|dS)Nz4Fatal Internal error [id=2]. Please report as a bug.���)rHrVr
)rY�parserss  r&raz#Configuration._get_parser_to_modifyksG���~�����-���/���	�$�F���
�
�r�{�r(ruc�X�||f}||jvr|j�|��dSdS�N)rXr�)rYrtru�file_parser_tuples    r&rszConfiguration._mark_as_modifiedys@��"�F�O���D�$:�:�:��"�)�)�*;�<�<�<�<�<�;�:r(c�0�|jj�d|j�d�S)N�(�))rZ�__name__rer^s r&�__repr__zConfiguration.__repr__~s!���.�)�A�A�D�,<�A�A�A�Ar(r�)rN)%r��
__module__�__qualname__�__doc__�boolrrrPr_�strrcrr	rrfrlrwr{r�ro�propertyrrer\r�r�r�r]r�r�rr�r�rarsr��
__classcell__)rZs@r&rFrFWs>���������G�G��G�(�4�.�G�D�G�G�G�G�G�G�**�*�*�*��(�3�-�����(�x��c�3�h��0�(�(�(�(�
B�S�
B�S�
B�
B�
B�
B�.�S�.��.��.�.�.�.�&.�s�.�t�.�.�.�.�:����0M�M�M�M�
�	�T�#�s�(�^�	�	�	��X�	�?�?�?�?�.�$��s��������s�������*
�
�
�
����#+�E�#�s�(�O�#<��	
�c�3�h������$�(�5��c��?�";�$�$�$�$� �8�E�$��S�	�/�,B�#C� � � � �@%�D�%�T�#�s�(�^�%�%�%�%��u�S�/�-A�'B�����=�s�=�O�=��=�=�=�=�
B�#�B�B�B�B�B�B�B�Br(rF),r�r�r�r2r;�typingrrrrrrr	�pip._internal.exceptionsr
r�pip._internal.utilsr�pip._internal.utils.compatr
�pip._internal.utils.loggingr�pip._internal.utils.miscrrr�r�rr5r�r?rrrrrrUrQr�r~r'r.rDrFr1r(r&�<module>r�s-��������
�
�
�
�	�	�	�	�
�
�
�
�F�F�F�F�F�F�F�F�F�F�F�F�F�F�F�F�F�F���������(�'�'�'�'�'�.�.�.�.�.�.�1�1�1�1�1�1�5�5�5�5�5�5�5�5��.���w�v�s����&�6�)�)�J��%��	
��	��	�
��	�	�	����u�z�5�:�u�y�%�-�O���*�e�l�E�J�6��	��8�	�	���#��#������3��4��9�������d�D��I�o�!6�����&hB�hB�hB�hB�hB�hB�hB�hB�hB�hBr(

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists