� !A?hN.��� ddlmZmZddlZddlZddlZddlZddlZddlZddl m Z d�Z Gd�de j ��Z d�Zd d �ZdS) �)�with_statement�print_functionN�)�refactorc �� |���}|���}tj||||ddd���S)Nz (original)z (refactored)�)�lineterm)� splitlines�difflib� unified_diff)�a�b�filenames �9/opt/alt/python-internal/lib64/python3.11/lib2to3/main.py� diff_textsrsI��/� � � ���A� � � ���A� � ��1�h�� ,�n�)+� -� -� -�-�c�:��eZdZ d�fd� Zd�Z�fd�Zd�Z�xZS)�StdoutRefactoringToolrc ��� ||_||_|r.|�tj��s|tjz }||_||_||_tt|��� |||��dS�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 �rr zStdoutRefactoringTool.__init__$s���� �$#���$��� � %�.�"9�"9�"�&�"A�"A� %� �b�f� $�N�-���%���+��� �#�T�*�*�3�3�F�G�X�N�N�N�N�Nrc�l�|j�|||f��|jj|g|�Ri|��dSr)�errors�append�logger�error)r!�msg�args�kwargss r� log_errorzStdoutRefactoringTool.log_errorAsJ�� � ���C��v�.�/�/�/��� ��#�/��/�/�/��/�/�/�/�/rc���|}|jrt|�|j��r@tj�|j|t |j��d���}ntd|�d|j�����|jr ||jz }||krktj� |��}tj� |��s|rtj |��|� d||��|j s�|dz}tj�|��r< tj|��n&#t $r|� d|��YnwxYw tj||��n'#t $r|� d||��YnwxYwt%t&|��j}|||||��|j st+j||��||krt+j||��dSdS)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_fileEsd��� � � � � J��"�"�4�#7�8�8� J��7�<�<��(8�(0��T�5I�1J�1J�1K�1K�(L�N�N���!�j�)1���4�3G�3G�"I�J�J�J� � � ,� ��+� +�H� �H� $� $������2�2�J��7�=�=��,�,� (�� (�� �J�'�'�'� � � �:�M�%� '� '� '��~� L���&�F��w���v�&�&� G�G��I�f�%�%�%�%���G�G�G��$�$�%=�v�F�F�F�F�F�G���� L�� �(�F�+�+�+�+��� L� L� L�� � �!8�(�F�K�K�K�K�K� L�����+�T�2�2�=�� ��h��(�H�5�5�5��~� .� �O�F�H� -� -� -� �H� $� $� �O�M�8� 4� 4� 4� 4� 4� %� $s$�-E� E%�$E%�)E?�?!F#�"F#c���|r|�d|��dS|�d|��|jr�t|||��} |j�U|j5|D]}t |���t j���ddd��n #1swxYwYdSdS|D]}t |���dS#t$rtd|�d���YdSwxYwdS)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� 7� 7��� �'��S�(�;�;� � ��'�3�!�-�/�/�(2�,�,�� %�d� � � � ��J�,�,�.�.�.�/�/�/�/�/�/�/�/�/�/�/����/�/�/�/�/�/�/�/� %/�(�(�D�!�$�K�K�K�K�(�(��)�����D�"�(�(�%�&�&�&��F�F����� � s<� B<�3B� B<�B�B<�B�B<�&B<�<C�C)rrr)�__name__� __module__� __qualname__r r1r@rV� __classcell__)r(s@rrrs���������BD�O�O�O�O�O�O�:0�0�0�%5�%5�%5�%5�%5�N������rrc�B�td|��tj���dS)Nz WARNING: ��file)rKrL�stderr)r.s rrPrP�s$�� �E�3�3� �s�z�2�2�2�2�2�2rc � �� tjd���}|�dddd���|�dd d gd � ��|�d ddddd���|�ddd gd� ��|�dddd���|�dddd���|�dddd���|�d d!dd"���|�d#dd$���|�d%d&dd'���|�d(d)dd*d+� ��|�d,d-dd.d/d0�1��|�d2d3dd4���|�d5dd.d/d6�1��d*}i}|�|��\}}|jr"d7|d8<|jst d9��d7|_|jr|js|� d:��|j r|js|� d;��|js|j rt d<��|js|jr|� d=��|j r9td>��tj���D]}t|���|sd?S|s8td@t j�A��tdBt j�A��dCSdD|vr&d7}|jrtdEt j�A��dCS|jrd7|dF<|jrd7|dG<|jr t*jn t*j}t+jdH|�I��t+jdJ��}t5tj�����} t5�fdK�|jD����} t5��} |jrJd*} |jD]&} | dLkrd7} � | ��dMz| z���'| r| �| ��n| }n| �| ��}|� | ��}tBj"�#|��}|r]|�$tBj%��s>tBj"�&|��stBj"�'|��}|jr;|�(tBj%��}|�)dN|j|��tUtW|��|tW| ��|j|j ||j|j �O��}|j,s�|r|�-��nZ |�||j|j.|j/��n1#tj0$rtdPt j�A��YdSwxYw|�1��tetg|j,����S)QNz2to3 [options] file|dir ...)�usagez-dz--doctests_only� store_truezFix up doctests only)�action�helpz-fz--fixr+z1Each FIX specifies a transformation; default: all)rb�defaultrcz-jz --processes�storer�intzRun 2to3 concurrently)rbrd�typercz-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.)rbrgrdrcz-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|zV�� dS)�.fix_N�)�.0�fix� fixer_pkgs �r� zmain..�s-�����L�L�s��W�,�s�2�L�L�L�L�L�Lr�allrpz7Output 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_argsrirHrPr&rr-� add_suffix�no_diffs� list_fixesrKr�get_all_fix_namesrLr^rrl�verbose�logging�DEBUG�INFO� basicConfig� getLogger�set�get_fixers_from_package�nofixrs�add�union� differencerr4� commonprefixrrr9r8�rstrip�infor�sortedr*�refactor_stdin� doctests_only� processes�MultiprocessingUnsupported� summarizerf�bool)rtr/�parserr��flagsr#�fixnamernr,� avail_fixes�unwanted_fixesr$� all_presentrs� requested� fixer_namesr%�rts` r�mainr��s����� "�)F� G� G� G�F� ���d�-�l�1��3�3�3� ���d�G�H�b�N��P�P�P� ���d�M�'�1� �'>��@�@�@� ���d�I�h��D��F�F�F� ���d�N�<�;��=�=�=� ���d�.�|�M��O�O�O� ���d�-�l�L��N�N�N� ���d�K� �1��3�3�3� ���l�<�@��B�B�B� ���d�I�l�6��8�8�8� ���d�M�,��C��E�E�E� ���d�N�7�� �(N��O�O�O� ���d�5�l�A��B�B�B� ���n�W�5�"�G��H�H�H� �N� �E��%�%�d�+�+�M�G�T��$��)-��%�&��}� ;� �9� :� :� :��� ���>�'�"3�>�� � �<�=�=�=���;�'�"3�;�� � �9�:�:�:� �=�Q�W�-�Q� � O�P�P�P� �=�0�W�.�0�� � �.�/�/�/���� �B�C�C�C��1�)�<�<� � �G� �'�N�N�N�N�� ��1� �� �A�� �S�S�S�S� �)�� �;�;�;�;��q� �d�{�{��� �=� � �)�� � ;� ;� ;� ;��1���'�"&������&�!%��o��%�_� >�G�M�M�'�,�E� ��6�e�D�D�D�D� � �~� .� .�F��h�6�y�A�A�B�B�K��L�L�L�L�g�m�L�L�L�L�L�N��u�u�H��{� 0�� ��;� 8� 8�C��e�|�|�"� � �� � �Y��0�3�6�7�7�7�7�3>�L�K�%�%�h�/�/�/�H� � ��%�%�h�/�/� ��&�&�~�6�6�K��W�)�)�$�/�/�N��9�~�6�6�r�v�>�>�9��� � �n�-�-�9� �����8�8����8�'�.�.�r�v�6�6��� � �M��&�� 8� 8� 8� � �;� � ���x�(8�(8� � �7�#3�3�)��)�!�,�  .� .� .�B� �9� � � � � � � � � � � �� � �D�'�-��1F�#�-�/�/�/�/���6� � � ��C��:�'�'�'�'��q�q�  ���� � � ���� �t�B�I��� � �s�<'U$�$*V�Vr)� __future__rrrLrr r�rArwrrr�MultiprocessRefactoringToolrrPr�rqrr�r�s����6�5�5�5�5�5�5�5� � � � � � � � ��������� � � � �����������-�-�-�e�e�e�e�e�H�@�e�e�e�N3�3�3�L �L �L �L �L �L r