AlkantarClanX12

Your IP : 18.217.207.112


Current Path : /opt/alt/python312/lib64/python3.12/lib2to3/__pycache__/
Upload File :
Current File : //opt/alt/python312/lib64/python3.12/lib2to3/__pycache__/main.cpython-312.pyc

�

�Q�fN.���dZddlmZmZddlZddlZddlZddlZddlZddl	Z	ddl
mZd�ZGd�dej�Zd	�Zdd
�Zy)z
Main program for 2to3.
�)�with_statement�print_functionN�)�refactorc	�z�|j�}|j�}tj||||ddd��S)z%Return a unified diff of two strings.z
(original)z(refactored)�)�lineterm)�
splitlines�difflib�unified_diff)�a�b�filenames   �3/opt/alt/python312/lib64/python3.12/lib2to3/main.py�
diff_textsrs;��	����A�	����A�����1�h�� ,�n�)+�-�-�c�<��eZdZdZ	d�fd�	Zd�Z�fd�Zd�Z�xZS)�StdoutRefactoringToola2
    A refactoring tool that can avoid overwriting its input files.
    Prints output to stdout.

    Output files can optionally be written to a different directory and or
    have an extra file suffix appended to their name for use in situations
    where you do not want to replace the input files.
    c	����||_||_|r2|jtj�s|tjz
}||_||_||_tt|�+|||�y)aF
        Args:
            fixers: A list of fixers to import.
            options: A dict with RefactoringTool configuration.
            explicit: A list of fixers to run even if they are explicit.
            nobackups: If true no backup '.bak' files will be created for those
                files that are being refactored.
            show_diffs: Should diffs of the refactoring be printed to stdout?
            input_base_dir: The base directory for all input files.  This class
                will strip this path prefix off of filenames before substituting
                it with output_dir.  Only meaningful if output_dir is supplied.
                All files processed by refactor() must start with this path.
            output_dir: If supplied, all converted files will be written into
                this directory tree instead of input_base_dir.
            append_suffix: If supplied, all files output by this tool will have
                this appended to their filename.  Useful for changing .py to
                .py3 for example by passing append_suffix='3'.
        N)�	nobackups�
show_diffs�endswith�os�sep�_input_base_dir�_output_dir�_append_suffix�superr�__init__)
�self�fixers�options�explicitrr�input_base_dir�
output_dir�
append_suffix�	__class__s
         �rrzStdoutRefactoringTool.__init__$sa���(#���$����.�"9�"9�"�&�&�"A��b�f�f�$�N�-���%���+���
�#�T�3�F�G�X�Nrc��|jj|||f�|jj|g|��i|��y�N)�errors�append�logger�error)r �msg�args�kwargss    r�	log_errorzStdoutRefactoringTool.log_errorAs9�������C��v�.�/�������#�/��/��/rc���|}|jrw|j|j�rAtjj|j|t
|j�d�}ntd|�d|j����|jr||jz
}||k7rhtjj|�}tjj|�s|rtj|�|jd||�|jsQ|dz}tjj|�r	tj|�	tj"||�t$t&|�R}|||||�|jst+j,|�||k7rt+j,||�yy#t $r|jd|�Y��wxYw#t $r|jd||�Y��wxYw)Nz	filename z( does not start with the input_base_dir zWriting converted %s to %s.z.bakzCan't remove backup %szCan't rename %s to %s)r�
startswithrr�path�join�len�
ValueErrorr�dirname�isdir�makedirs�log_messager�lexists�remove�OSError�renamerr�
write_file�shutil�copymode)
r �new_textr�old_text�encoding�
orig_filenamer%�backup�writer's
         �rr@z StdoutRefactoringTool.write_fileEs���� �
�����"�"�4�#7�#7�8��7�7�<�<��(8�(8�(0��T�5I�5I�1J�1K�(L�N��!�)1�4�3G�3G�"I�J�J������+�+�+�H��H�$�������2�J��7�7�=�=��,�����J�'����:�M�%�
'��~�~���&�F��w�w���v�&�G��I�I�f�%�
L��	�	�(�F�+��+�T�=��
�h��(�H�5��~�~��O�O�F�H�-��H�$��O�O�M�8�4�%���G��$�$�%=�v�F�G���
L�� � �!8�(�F�K�
L�s$�G�G%�G"�!G"�%H�Hc��|r|jd|�y|jd|�|jrst|||�}	|j�F|j5|D]
}t	|��t
jj�ddd�y|D]
}t	|��yy#1swYyxYw#t$rtd|�d��YywxYw)NzNo changes to %sz
Refactored %szcouldn't encode z's diff for your terminal)
r;rr�output_lock�print�sys�stdout�flush�UnicodeEncodeError�warn)r �old�newr�equal�
diff_lines�lines       r�print_outputz"StdoutRefactoringTool.print_outputls�������/��:����_�h�7����'��S�(�;�
���'�'�3�!�-�-�(2�� %�d��)3��J�J�,�,�.�.�-�
%/�D�!�$�K�%/��.�-��*���"�%�&���s6�B4�1B(�B4�B4�(B1�-B4�1B4�4C�C)rrr)	�__name__�
__module__�__qualname__�__doc__rr1r@rV�
__classcell__)r's@rrrs%����BD�O�:0�%5�Nrrc�@�td|��tj��y)Nz	WARNING: ��file)rKrL�stderr)r.s rrPrP�s��	�3�
 �s�z�z�2rc
���tjd��}|jdddd��|jdd	d
gd��|jd
ddddd��|jddd
gd��|jdddd��|jdddd��|jdddd��|jd d!dd"��|jd#dd$��|jd%d&dd'��|jd(d)dd*d+��|jd,d-dd.d/d0�1�|jd2d3dd4��|jd5dd.d/d6�1�d*}i}|j|�\}}|jr#d7|d8<|j
st
d9�d7|_|jr|js|jd:�|jr|js|jd;�|j
s|jrt
d<�|j
s|jr|jd=�|jr3td>�tj��D]
}t|��|sy?|s7td@t j"�A�tdBt j"�A�yCdD|vr*d7}|j
rtdEt j"�A�yC|j$rd7|dF<|j&rd7|dG<|j(rt*j,nt*j.}t+j0dH|�I�t+j2dJ�}t5tj6���}	t5�fdK�|j8D��}
t5�}|j:rHd*}|j:D]!}
|
dLk(rd7}�|j=�dMz|
z��#|r|	j?|�n|}n|	j?|�}|jA|
�}tBjDjG|�}|r]|jItBjJ�s>tBjDjM|�stBjDjO|�}|jr<|jQtBjJ�}|jSdN|j|�tUtW|�|tW|�|j|j||j|j�O�}|jXsV|r|j[�n3	|j||j
|j\|j^�|jc�tetg|jX��S#tj`$r/|j^dkDsJ�tdPt j"�A�YywxYw)Qz�Main program.

    Args:
        fixer_pkg: the name of a package where the fixers are located.
        args: optional; a list of command line arguments. If omitted,
              sys.argv[1:] is used.

    Returns a suggested exit status (0, 1, 2).
    z2to3 [options] file|dir ...)�usagez-dz--doctests_only�
store_truezFix up doctests only)�action�helpz-fz--fixr+z1Each FIX specifies a transformation; default: all)rc�defaultrdz-jz--processes�storer�intzRun 2to3 concurrently)rcre�typerdz-xz--nofixz'Prevent a transformation from being runz-lz--list-fixeszList available transformationsz-pz--print-functionz0Modify the grammar so that print() is a functionz-ez--exec-functionz/Modify the grammar so that exec() is a functionz-vz	--verbosezMore verbose loggingz
--no-diffsz#Don't show diffs of the refactoringz-wz--writezWrite back modified filesz-nz--nobackupsFz&Don't write backups for modified filesz-oz--output-dir�strrzXPut output files in this directory instead of overwriting the input files.  Requires -n.)rcrhrerdz-Wz--write-unchanged-fileszYAlso write files even if no changes were required (useful with --output-dir); implies -w.z--add-suffixzuAppend this string to all output filenames. Requires -n if non-empty.  ex: --add-suffix='3' will generate .py3 files.T�write_unchanged_filesz&--write-unchanged-files/-W implies -w.z%Can't use --output-dir/-o without -n.z"Can't use --add-suffix without -n.z@not writing files and not printing diffs; that's not very usefulzCan't use -n without -wz2Available transformations for the -f/--fix option:rz1At least one file or directory argument required.r]zUse --help to show usage.��-zCan't write to stdin.r�
exec_functionz%(name)s: %(message)s)�format�levelzlib2to3.mainc3�.�K�|]}�dz|z���y�w)�.fix_N�)�.0�fix�	fixer_pkgs  �r�	<genexpr>zmain.<locals>.<genexpr>�s�����L�m�s��W�,�s�2�m�s��allrqz7Output in %r will mirror the input directory %r layout.)r$r%r&z+Sorry, -j isn't supported on this platform.)4�optparse�OptionParser�
add_option�
parse_argsrjrHrPr%rr-�
add_suffix�no_diffs�
list_fixesrKr�get_all_fix_namesrLr_rrm�verbose�logging�DEBUG�INFO�basicConfig�	getLogger�set�get_fixers_from_package�nofixrt�add�union�
differencerr4�commonprefixrrr9r8�rstrip�infor�sortedr*�refactor_stdin�
doctests_only�	processes�MultiprocessingUnsupported�	summarizerg�bool)rur/�parserr��flagsr"�fixnameror,�avail_fixes�unwanted_fixesr#�all_presentrt�	requested�fixer_namesr$�rts`                 r�mainr��so����
"�
"�)F�
G�F�
���d�-�l�1��3�
���d�G�H�b�N��P�
���d�M�'�1� �'>��@�
���d�I�h��D��F�
���d�N�<�;��=�
���d�.�|�M��O�
���d�-�l�L��N�
���d�K��1��3�
���l�<�@��B�
���d�I�l�6��8�
���d�M�,��C��E�
���d�N�7�� �(N��O����d�5�l�A��B����n�W�5�"�G��H��N��E��%�%�d�+�M�G�T��$�$�)-��%�&��}�}��9�:���
����'�"3�"3����<�=����'�"3�"3����9�:��=�=�W�-�-��
O�P��=�=�W�.�.����.�/����
�B�C��1�1�)�<�G��'�N�=����
�A��
�
�S�
�)��
�
�;��
�d�{����=�=��)��
�
�;�����"&�������!%��o��%�_�_�G�M�M�'�,�,�E����6�e�D�
�
�
�~�
.�F��h�6�6�y�A�B�K��L�g�m�m�L�L�N��u�H��{�{����;�;�C��e�|�"�����Y��0�3�6�7�	�
4?�K�%�%�h�/�H�	��%�%�h�/�	��&�&�~�6�K��W�W�)�)�$�/�N��~�6�6�r�v�v�>����
�
�n�-�������8�����'�.�.�r�v�v�6�����M��&�&��	8�	��;����x�(8����7�#3�#3�3�)��)�)�!�,�,�
.�B��9�9������
����D�'�-�-��1F�1F�#�-�-�/�	�����t�B�I�I������6�6�
��(�(�1�,�,�,��C��:�:�'��	
�s�:2V�?W�Wr))rZ�
__future__rrrLrrr�rArxrrr�MultiprocessRefactoringToolrrPr�rrrr�<module>r�sI���6�
�	���
���-�e�H�@�@�e�N3�L r