????

Your IP : 3.143.203.221


Current Path : /opt/cloudlinux/venv/lib/python3.11/site-packages/isort/__pycache__/
Upload File :
Current File : //opt/cloudlinux/venv/lib/python3.11/site-packages/isort/__pycache__/api.cpython-311.pyc

�

�܋ff���dZddlZddlZddlZddlmZddlmZddlm	Z	ddl
mZddlm
Z
mZmZmZmZmZmZddlmZdd	lmZd
dlmZmZmZd
dlmZmZmZmZd
d
l m!Z!m"Z"m#Z#d
dlm$Z$m%Z%d
dl&m'Z(d
dl&m)Z*d
dl+m,Z,m-Z-m.Z.Gd�de��Z/de-dddfde0dee0de.deede1dee1efde
de0fd�Z2dde-ddfde0dee1efdee0de.deede1de
de1fd�Z3de-ddddfd ed!edee0de.deede1dee1efd"e1de
de1fd#�Z4dde-ddfd edee1efdee0de.deede1de
de1fd$�Z5de-dddfd%ee0efdee1efde.deede1dee0de
de1fd&�Z6d'e%defd(�Z7ej8deefd)���Z9ej8d%ee0efd'e%deefd*���Z:de-ddddddfd%ee0efdee0de.deede1d+e1dee1efd,e1d-eede
de1fd.�Z;e-dddfde0de.deed/ee1e/fd0e1de
deej<fd1�Z=e-ddddfd ede.deed/ee1e/fd0e1d2eee0de
deej<fd3�Z>e-dddfd%ee0efde.deed/ee1e/fd0e1de
deej<fd4�Z?e-dddfd5eee0efde.deed/ee1e/fd0e1de
deej<fd6�Z@de-fd7eede.de
de.fd8�ZAdS)9)
�	ImportKey�check_code_string�
check_file�check_stream�find_imports_in_code�find_imports_in_file�find_imports_in_paths�find_imports_in_stream�place_module�place_module_with_reason�sort_code_string�	sort_file�sort_stream�N)�Enum��StringIO)�chain)�Path)�Any�Iterator�Optional�Set�TextIO�Union�cast)�warn)�core�)�files�identify�io)�ExistingSyntaxErrors�FileSkipComment�FileSkipSetting�IntroducedSyntaxErrors)�$ask_whether_to_apply_changes_to_file�create_terminal_printer�show_unified_diff)�Empty�File)�module)�module_with_reason)�CYTHON_EXTENSIONS�DEFAULT_CONFIG�Configc�"�eZdZdZdZdZdZdZdS)ra�Defines how to key an individual import, generally for deduping.

    Import keys are defined from less to more specific:

    from x.y import z as a
    ______| |        |    |
       |    |        |    |
    PACKAGE |        |    |
    ________|        |    |
          |          |    |
        MODULE       |    |
    _________________|    |
              |           |
           ATTRIBUTE      |
    ______________________|
                  |
                ALIAS
    r���N)�__name__�
__module__�__qualname__�__doc__�PACKAGE�MODULE�	ATTRIBUTE�ALIAS���Z/builddir/build/BUILD/cloudlinux-venv-1.0.6/venv/lib/python3.11/site-packages/isort/api.pyrr+s.��������&�G�
�F��I�
�E�E�Er=rF�code�	extension�config�	file_path�disregard_skip�	show_diff�
config_kwargs�returnc	���t|��}t��}td||d�|��}t|||||||���|�d��|���S)a�Sorts any imports within the provided code string, returning a new string with them sorted.

    - **code**: The string of code with imports that need to be sorted.
    - **extension**: The file extension that contains imports. Defaults to filename extension or py.
    - **config**: The config object to use when sorting imports.
    - **file_path**: The disk location where the code string was pulled from.
    - **disregard_skip**: set to `True` if you want to ignore a skip set in config for this file.
    - **show_diff**: If `True` the changes that need to be done will be printed to stdout, if a
    TextIO stream is provided results will be written to it, otherwise no diff will be computed.
    - ****config_kwargs**: Any config modifications.
    ��pathrA)r@rArBrCrDrr<)r�_configr�seek�read)	r?r@rArBrCrDrE�input_stream�
output_streams	         r>rrEs���(�D�>�>�L��J�J�M�
�
D�)�F�
D�
D�m�
D�
D�F�������%���������q���������r=c�d�td||d�|��}tt|��|||||���S)a2Checks the order, format, and categorization of imports within the provided code string.
    Returns `True` if everything is correct, otherwise `False`.

    - **code**: The string of code with imports that need to be sorted.
    - **show_diff**: If `True` the changes that need to be done will be printed to stdout, if a
    TextIO stream is provided results will be written to it, otherwise no diff will be computed.
    - **extension**: The file extension that contains imports. Defaults to filename extension or py.
    - **config**: The config object to use when sorting imports.
    - **file_path**: The disk location where the code string was pulled from.
    - **disregard_skip**: set to `True` if you want to ignore a skip set in config for this file.
    - ****config_kwargs**: Any config modifications.
    rH�rDr@rArBrCr<)rJrr)r?rDr@rArBrCrEs       r>rrisM��*�
D�)�F�
D�
D�m�
D�
D�F����������%�
���r=TrMrN�
raise_on_skipc��|p|r|j�d��pd}|r�t��}	t|�����}
t	d
|
|	|||||d�|��}|	�d��|
�d��t
|
���|	���||dur|n||j���|Std
||d�|��}t|pd��}|s&|r$|�
|��rt|���|}
|jr�	|���}t||d	dd
��nA#t$r4|tvrt!|���|jrt%|�d���YnwxYwt|��}|���st��}
	t)j||
|||���}n#t,$rt-|���wxYw|jr�|
�d��	t|
���|d	dd
��|
�d��nA#t$r4|tvrt/|���|jrt%|�d���YnwxYw|
|kr'|�|
�����|S)a�Sorts any imports within the provided code stream, outputs to the provided output stream.
     Returns `True` if anything is modified from the original input stream, otherwise `False`.

    - **input_stream**: The stream of code with imports that need to be sorted.
    - **output_stream**: The stream where sorted imports should be written to.
    - **extension**: The file extension that contains imports. Defaults to filename extension or py.
    - **config**: The config object to use when sorting imports.
    - **file_path**: The disk location where the code string was pulled from.
    - **disregard_skip**: set to `True` if you want to ignore a skip set in config for this file.
    - **show_diff**: If `True` the changes that need to be done will be printed to stdout, if a
    TextIO stream is provided results will be written to it, otherwise no diff will be computed.
    - ****config_kwargs**: Any config modifications.
    �.�py)rMrNr@rArBrCrQrT��
file_input�file_outputrB�output�color_outputrHzPassed in content�execrz< Python AST errors found but ignored due to Cython extension)r@rArQr<)�suffix�lstriprrLrrKr(rYrJ�str�
is_skippedr$�atomic�compile�SyntaxErrorr-r"�verboser�readabler�processr#r%�write)rMrNr@rArBrCrDrQrE�_output_stream�
_input_stream�changed�content_source�_internal_output�file_contents               r>rr�s}��0�Q�i�H�I�,<�,C�,C�C�,H�,H�Q�T�I���!���� ��!2�!2�!4�!4�5�5�
��	
�&�(����)�'�	
�	
��	
�	
��	���A�������1�����$�)�)�+�+�&�+�+�-�-��$-��$5�$5�=�=�9��,�	
�	
�	
�	
���
�
D�)�F�
D�
D�m�
D�
D�F���9�&9�:�:�N��.�i�.�F�,=�,=�i�,H�,H�.��n�-�-�-�$��
�}�*�		�'�,�,�.�.�L��L�.�&�!�Q�?�?�?�?���	�	�	�� 1�1�1�*�>�:�:�:��~�
��%�c�c�c������		���� ��-�-���%�%�'�'�	*�'�z�z��	.��,�����'�
�
�
�����.�.�.��n�-�-�-�.�����}�
9����a� � � �		��$�)�)�+�+�^�V�Q��J�J�J��!�!�!�$�$�$�$���	�	�	�� 1�1�1�,�^�<�<�<��~�
��%�c�c�c������		�����}�,�,���� 0� 5� 5� 7� 7�8�8�8��Ns0�''E�;F
�F
�G�G6�:I�;J�Jc��td||d�|��}|r!t|�����}t|t||||���}t|j|j|j���}|s*|j	r!|j
s|�|pd�d���dS|�|pd�d���|r�t��}	|�
d��|���}
tt|
��|	||||���|	�
d��t|
|	���||durd	n||j�
��dS)
aEChecks any imports within the provided code stream, returning `False` if any unsorted or
    incorrectly imports are found or `True` if no problems are identified.

    - **input_stream**: The stream of code with imports that need to be sorted.
    - **show_diff**: If `True` the changes that need to be done will be printed to stdout, if a
    TextIO stream is provided results will be written to it, otherwise no diff will be computed.
    - **extension**: The file extension that contains imports. Defaults to filename extension or py.
    - **config**: The config object to use when sorting imports.
    - **file_path**: The disk location where the code string was pulled from.
    - **disregard_skip**: set to `True` if you want to ignore a skip set in config for this file.
    - ****config_kwargs**: Any config modifications.
    rH)rMrNr@rArBrC)�color�error�success�z Everything Looks Good!Tz1 Imports are incorrectly sorted and/or formatted.rNrUFr<)rJrrLrr)r'rY�format_error�format_successrb�
only_modifiedrornrKr()rMrDr@rArBrCrErh�printerrN�
file_contentss           r>rr�s���*�
D�)�F�
D�
D�m�
D�
D�F��5��� 1� 1� 3� 3�4�4���!�����%�
���G�&��!��)<�f�F[����G����>�	I�&�"6�	I��O�O�y��B�G�G�G�H�H�H��t��M�M�Y�_�"�W�W�W�X�X�X��
� �
�
�
����!����$�)�)�+�+�
��!�-�0�0�'����)�
	
�	
�	
�	
�	���1�����$�%�*�*�,�,��$��,�,�4�4�)��,�	
�	
�	
�	
��5r=�filenamec
�~�|}d|vr`|�dd��}|rH|�|��}	|jrt|	d�d|����t	di|	d��}t
j�|��5}
t|
j	f||||p|
j
|d�|��cddd��S#1swxYwYdS)a)Checks any imports within the provided file, returning `False` if any unsorted or
    incorrectly imports are found or `True` if no problems are identified.

    - **filename**: The name or Path of the file to check.
    - **show_diff**: If `True` the changes that need to be done will be printed to stdout, if a
    TextIO stream is provided results will be written to it, otherwise no diff will be computed.
    - **config**: The config object to use when sorting imports.
    - **file_path**: The disk location where the code string was pulled from.
    - **disregard_skip**: set to `True` if you want to ignore a skip set in config for this file.
    - **extension**: The file extension that contains imports. Defaults to filename extension or py.
    - ****config_kwargs**: Any config modifications.
    �config_trieNr� used for file rrPr<)�pop�searchrb�printr/r!r*rLr�streamrI)rvrDrArBrCr@rE�file_configrx�config_info�source_files           r>rr1s9��*!�K��
�%�%�#�'�'�
�t�<�<���	3�%�,�,�X�6�6�K��~�
D���Q��B�B��B�B�C�C�C� �2�2�;�q�>�2�2�K�	����h�	�	�	
�;����
�����3�;�#3�)�

�
��
�
�	
�	
�	
�	
�	
�	
�	
�	
�	
�	
�	
�	
����	
�	
�	
�	
�	
�	
s�B2�2B6�9B6r�c�P�|j�|jjdz��S)Nz.isorted)rI�with_suffixr[)r�s r>�	_tmp_filer�]s$����'�'��(8�(?�*�(L�M�M�Mr=c#�.K�td���V�dS)N)�newlinerr<r=r>� _in_memory_output_stream_contextr�as#����
�4�
 �
 �
 � � � � � r=c#��K�t|��}|�d|jd���5}tj||��|V�ddd��dS#1swxYwYdS)Nzw+rp)�encodingr�)r��openr��shutil�copymode)rvr��tmp_filerNs    r>�_file_output_stream_contextr�fs�������%�%�H�	���t�k�&:�B��	G�	G��=����(�+�+�+�������������������������s�A�A�A�ask_to_apply�write_to_stdoutrXc	�
	�|}
d|	vr`|	�dd��}|rH|�|��}|jrt|d�d|����t	di|d��}
t
j�|��5}
|p|
j}td||
d�|	��}d}	|r&t|
jtj
||||���}�n`|���	|jrt��}nt!||
��}|5}t|
j|||||���}|�d��|�ro|s|r�|
j�d��t%|
j���|���||d	urdnt't(|��|j�
��|s#|rvt-t/|
j����sU	ddd��	|js#t1|
��}|���n#t4$rYnwxYwddd��dS|
j���|jr\|�d��|
j�d��5}t;j||��ddd��n#1swxYwYddd��n#1swxYwY|rN|js)t1|
��}|�|
j��|j std|
j����	|js#t1|
��}|���n�#t4$rYn�wxYw#	|js$t1|
��}|���ww#t4$rYwwxYwxYwt|
j|||||���}|ry|rw|
j�d��|�d��t%|
j���|���||d	urdn||j�
��|
j���n?#tB$rtE|�d
���Yn!tF$rtE|�d���YnwxYw|cddd��S#1swxYwYdS)a:Sorts and formats any groups of imports imports within the provided file or Path.
     Returns `True` if the file has been changed, otherwise `False`.

    - **filename**: The name or Path of the file to format.
    - **extension**: The file extension that contains imports. Defaults to filename extension or py.
    - **config**: The config object to use when sorting imports.
    - **file_path**: The disk location where the code string was pulled from.
    - **disregard_skip**: set to `True` if you want to ignore a skip set in config for this file.
    - **ask_to_apply**: If `True`, prompt before applying any changes.
    - **show_diff**: If `True` the changes that need to be done will be printed to stdout, if a
    TextIO stream is provided results will be written to it, otherwise no diff will be computed.
    - **write_to_stdout**: If `True`, write to stdout instead of the input file.
    - **output**: If a TextIO is provided, results will be written there rather than replacing
    the original file content.
    - ****config_kwargs**: Any config modifications.
    rxNrryrrHF)rMrNrArBrCr@TrU�wzFixing z- unable to sort due to existing syntax errorsz5 unable to sort as isort introduces new syntax errorsr<)$rzr{rbr|r/r!r*rLrIrJrr}�sys�stdout�overwrite_in_placer�r�rKr(rrrYr&r]r��unlink�FileNotFoundError�closer�r��copyfileobj�replace�quietr"rr%)rvr@rArBrCr�rDr�rXrEr~rxrr��actual_file_pathrh�output_stream_contextrNr��fss                    r>r
r
ns���8!�K��
�%�%�#�'�'�
�t�<�<���	3�%�,�,�X�6�6�K��~�
D���Q��B�B��B�B�C�C�C� �2�2�;�q�>�2�2�K�	����h�	�	�`�;�$�8��(8���T�.�{�T�T�m�T�T����Z	]��T
/�%�!,�!3�"%�*�!�.�#1�'�
������>�5!�!�4��4T�4V�4V�1�1�4O� (�+�5�5�1�3�!N�m�&1�-8�-?�.;�'-�*:�/=�*3�
'�'�'�G�*�.�.�q�1�1�1�&�N�#,�!5��!5�$/�$6�$;�$;�A�$>�$>�$>�$5�3>�3E�3J�3J�3L�3L�4A�4F�4F�4H�4H�2B�+4��+<�+<�04�t�-1�&�)�-D�-D�5;�5H�%&�%&�%&�%&�(1�%5�(4�%5�0T�,/��0@�,A�,A�1*�1*�%5�05�9!N�!N�!N�!N�!N�!N�R!�#)�#<�2�+4�[�+A�+A�� (��� 1� 1� 1���0�!�!�!� �D�!����I`�`�`�`�`�`�`�`�h!,� 2� 8� 8� :� :� :�#)�#<�!N�$1�$6�$6�q�$9�$9�$9�)4�)9�)>�)>�s�)C�)C�%N�r�(.�(:�=�"�(M�(M�(M�%N�%N�%N�%N�%N�%N�%N�%N�%N�%N�%N����%N�%N�%N�%N�A!N�!N�!N�!N�!N�!N�!N�!N�!N�!N�!N����!N�!N�!N�!N�D#�D�#)�#<�C�+4�[�+A�+A�� (� 0� 0��1A� B� B� B�#)�<�D� %�&B��0@�&B�&B� C� C� C�!�#)�#<�2�+4�[�+A�+A�� (��� 1� 1� 1���0�!�!�!� �D�!�����	!�#)�#<�2�+4�[�+A�+A�� (��� 1� 1� 1� 1�2�� 1�!�!�!� �D�!�������*�%0�%7�&,�%�"2�'5�"+�
���G��	�9�	�#�*�/�/��2�2�2����A����)�'2�'9�'>�'>�'@�'@�(.���
�
�&6�+4��+<�+<�4�4�)�)/�)<����� �&�,�,�.�.�.���#�	U�	U�	U��$�S�S�S�T�T�T�T�T�%�	]�	]�	]��$�[�[�[�\�\�\�\�\�	]�����A`�`�`�`�`�`�`�`�`�`�`�`����`�`�`�`�`�`s�Q8�"+P+�(L;�6CJ$�L;�*G?�>P+�?
H�	P+�H�P+�AJ$�+J
�J$�
J�J$�J�J$�L;�$J(	�(L;�+J(	�,AL;�*L+�*P+�+
L8�5P+�7L8�8P+�;M9�=*M)�'M9�)
M6	�3M9�5M6	�6M9�9B1P+�*Q8�+Q'�Q8�	Q'�$Q8�&Q'�'Q8�8Q<�?Q<�unique�top_onlyc	+�TK�tdt|��||||d�|��Ed{V��dS)a�Finds and returns all imports within the provided code string.

    - **code**: The string of code with imports that need to be sorted.
    - **config**: The config object to use when sorting imports.
    - **file_path**: The disk location where the code string was pulled from.
    - **unique**: If True, only the first instance of an import is returned.
    - **top_only**: If True, only return imports that occur before the first function or class.
    - ****config_kwargs**: Any config modifications.
    �rMrArBr�r�Nr<)r	r)r?rArBr�r�rEs      r>rr�sk����"&���d�^�^��������
����������r=�_seenc+��K�tdd|i|��}tj||||���}|s|Ed{V��|�t��n|}|D]�}	|dtjfvr|	���}
nj|tjkr|	j�d|	j	��}
nH|tj
kr|	j}
n0|tjkr |	j�d��d}
|
r|
|vr|�
|
��|	V���dS)afFinds and returns all imports within the provided code stream.

    - **input_stream**: The stream of code with imports that need to be sorted.
    - **config**: The config object to use when sorting imports.
    - **file_path**: The disk location where the code string was pulled from.
    - **unique**: If True, only the first instance of an import is returned.
    - **top_only**: If True, only return imports that occur before the first function or class.
    - **_seen**: An optional set of imports already seen. Generally meant only for internal use.
    - ****config_kwargs**: Any config modifications.
    rA)rArBr�NTrSrr<)rJr �imports�setrr;�	statementr:r+�	attributer9r8�split�add)rMrArBr�r�r�rE�identified_imports�seen�identified_import�keys           r>r	r	sJ����&�
4�
4�F�
4�m�
4�
4�F�!�)��V�y�8������&�%�%�%�%�%�%�%�%�#�m�S�U�U�U��D�/�$�$���d�I�O�,�,�,�#�-�-�/�/�C�C�
�y�*�
*�
*�&�-�M�M�0A�0K�M�M�C�C�
�y�'�
'�
'�#�*�C�C�
�y�(�
(�
(�#�*�0�0��5�5�a�8�C��	$�3�d�?�?��H�H�S�M�M�M�#�#�#�#��$�$r=c
+��K�tj�|��5}td|j||p|j||d�|��Ed{V��ddd��dS#1swxYwYdS)acFinds and returns all imports within the provided source file.

    - **filename**: The name or Path of the file to look for imports in.
    - **extension**: The file extension that contains imports. Defaults to filename extension or py.
    - **config**: The config object to use when sorting imports.
    - **file_path**: The disk location where the code string was pulled from.
    - **unique**: If True, only the first instance of an import is returned.
    - **top_only**: If True, only return imports that occur before the first function or class.
    - ****config_kwargs**: Any config modifications.
    r�Nr<)r!r*rLr	r}rI)rvrArBr�r�rEr�s       r>rr=s�����$
����h�	�	�
�;�)�
�$�+���3�;�#3���
�
��

�
�	
�	
�	
�	
�	
�	
�	
�
�
�
�
�
�
�
�
�
�
�
�
����
�
�
�
�
�
s�%A�A�A�pathsc	+������K�tdd�i|����rt��nd�t����fd�tjtt|���gg��D���Ed{V��dS)ajFinds and returns all imports within the provided source paths.

    - **paths**: A collection of paths to recursively look for imports within.
    - **extension**: The file extension that contains imports. Defaults to filename extension or py.
    - **config**: The config object to use when sorting imports.
    - **file_path**: The disk location where the code string was pulled from.
    - **unique**: If True, only the first instance of an import is returned.
    - **top_only**: If True, only return imports that occur before the first function or class.
    - ****config_kwargs**: Any config modifications.
    rANc3�@�K�|]}t|�������V��dS))r�rAr�r�N)r)�.0�	file_namerAr�r�r�s  ����r>�	<genexpr>z(find_imports_in_paths.<locals>.<genexpr>osT�����

�

��
!��&��(�RV�
�
�
�

�

�

�

�

�

r=r<)rJr�rr�find�mapr])r�rArBr�r�rEr�s ` `` @r>rrZs���������$�
4�
4�F�
4�m�
4�
4�F�(.�8�s�u�u�u�D�D��

�

�

�

�

�

�

�#�Z��C������R�H�H�	

�

�

����������r=rIc��|r|tur
d|vr	d|vr||d<|r$|turtd���tdi|��}|S)N�
settings_path�
settings_fileziYou can either specify custom configuration options using kwargs or passing in a Config object. Not Both!r<)r.�
ValueErrorr/)rIrArEs   r>rJrJxs{���.��.� � ��=�0�0��=�0�0�)-�
�o�&��)���'�'��8���
�
�(�(�-�(�(���Mr=)B�__all__�
contextlibr�r��enumrr!r�	itertoolsr�pathlibr�typingrrrrrrr�warningsr�isortrrprr �
exceptionsr"r#r$r%�formatr&r'r(r)r*�placer+r
r,r�settingsr-r.r/rr]�boolrrrrrr��contextmanagerr�r�r
�Importrr	rrrJr<r=r>�<module>r�s����� ����
�
�
�
�
�
�
�
�������������������������D�D�D�D�D�D�D�D�D�D�D�D�D�D�D�D�D�D�������������!�!�!�!�!�!�!�!�!�!�������������e�d�d�d�d�d�d�d�d�d���������)�)�)�)�)�)�A�A�A�A�A�A�?�?�?�?�?�?�?�?�?�?����������8 $�#� $� �%*�
! �! �

�! ���}�! �
�! ���~�	! �
�! ��T�6�\�"�
! ��! �	�! �! �! �! �L&+�#�#� $� �
��

���T�6�\�"����}��
�	�
��~���
���
�����F $�#� $� �%*��b�b��b��b���}�b�
�	b�
��~�b��
b��T�6�\�"�b��b��b�
�b�b�b�b�N&+�#�#� $� �
@�@��@��T�6�\�"�@���}�@�
�	@�
��~�@��
@��@�
�@�@�@�@�J&+�#� $��#�
)
�)
��C��I��)
��T�6�\�"�)
�
�)
���~�	)
�
�)
���}�
)
��)
�
�)
�)
�)
�)
�XN�4�N�D�N�N�N�N���!�(�6�*:�!�!�!���!����%��T�	�*:����RZ�[a�Rb������� $�#� $���%*�!�#�G�G��C��I��G���}�G�
�G���~�	G�
�G��
G��T�6�\�"�G��G�
�V��G��G�
�G�G�G�G�X$� $�%*����

������~��
�$�	�/�"�	�
���
��h�o������:$� $�%*�� $�
'$�'$��'$��'$���~�'$�
�$�	�/�"�	'$�
�'$��C��H��
'$��'$��h�o��'$�'$�'$�'$�X$� $�%*��
�
��C��I��
��
���~�
�
�$�	�/�"�	
�
�
��

��h�o��
�
�
�
�>$� $�%*�����E�#�t�)�$�%������~��
�$�	�/�"�	�
���
��h�o������> �.���
�4�.��)/��SV��������r=