관리-도구
편집 파일: __init__.cpython-311.pyc
� �܋f�D � �� � d Z ddlZddlZddlZddlZddlZddlZddlmZ ddl m Z ddlmZ ej e� � Ze� ej � � eej � � eej � � z eej � � z eej � � z Zg d�Z G d� d� � Zd � Zd � Zd� Z G d� d e� � Z e� � Zdd�Z d� Z!d� Z" G d� de� � Z# G d� de� � Z$e Z%dS )a' past.translation ================== The ``past.translation`` package provides an import hook for Python 3 which transparently runs ``futurize`` fixers over Python 2 code on import to convert print statements into functions, etc. It is intended to assist users in migrating to Python 3.x even if some dependencies still only support Python 2.x. Usage ----- Once your Py2 package is installed in the usual module search path, the import hook is invoked as follows: >>> from past.translation import autotranslate >>> autotranslate('mypackagename') Or: >>> autotranslate(['mypackage1', 'mypackage2']) You can unregister the hook using:: >>> from past.translation import remove_hooks >>> remove_hooks() Author: Ed Schofield. Inspired by and based on ``uprefix`` by Vinay M. Sajip. � N)� ParseError)�RefactoringTool)�fixes)#zlib2to3.fixes.fix_applyzlib2to3.fixes.fix_exceptzlib2to3.fixes.fix_execfilezlib2to3.fixes.fix_exitfunczlib2to3.fixes.fix_funcattrszlib2to3.fixes.fix_filterzlib2to3.fixes.fix_has_keyzlib2to3.fixes.fix_idiomszlib2to3.fixes.fix_importzlib2to3.fixes.fix_internzlib2to3.fixes.fix_isinstancezlib2to3.fixes.fix_methodattrszlib2to3.fixes.fix_nezlib2to3.fixes.fix_numliteralszlib2to3.fixes.fix_parenzlib2to3.fixes.fix_printzlib2to3.fixes.fix_raisezlib2to3.fixes.fix_renameszlib2to3.fixes.fix_reducezlib2to3.fixes.fix_reprzlib2to3.fixes.fix_standarderrorzlib2to3.fixes.fix_sys_exczlib2to3.fixes.fix_throwzlib2to3.fixes.fix_tuple_paramszlib2to3.fixes.fix_typeszlib2to3.fixes.fix_ws_commazlib2to3.fixes.fix_xreadlineszlib2to3.fixes.fix_basestringzlib2to3.fixes.fix_execzlib2to3.fixes.fix_getcwduzlib2to3.fixes.fix_longzlib2to3.fixes.fix_nextzlib2to3.fixes.fix_nonzerozlib2to3.fixes.fix_raw_inputzlib2to3.fixes.fix_xrangec �N � e Zd ZdZdZdZdZdZed� � � Z ed� � � Z dS )�RTsa& A namespace for the refactoring tools. This avoids creating these at the module level, which slows down the module import. (See issue #117). There are two possible grammars: with or without the print statement. Hence we have two possible refactoring tool implementations. Nc � � dt j t j fv rAt t � � t _ t t ddi� � t _ dS dS �zj Call this before using the refactoring tools to create them on demand if needed. N�print_functionT)r �_rt�_rtpr �myfixes� � �j/builddir/build/BUILD/cloudlinux-venv-1.0.6/venv/lib/python3.11/site-packages/past/translation/__init__.py�setupz RTs.setup� sJ � � �C�G�S�X�&�&�&�%�g�.�.�C�G�&�w�1A�4�0H�I�I�C�H�H�H� '�&r c � � dt j t j fv rAt t � � t _ t t ddi� � t _ dS dS r )r �_rt_py2_detect�_rtp_py2_detectr �py2_detect_fixersr r r �setup_detect_python2zRTs.setup_detect_python2� sX � � �C�&��(;�<�<�<�!0�1B�!C�!C�C��"1�2C�3C�T�2J�#L� #L�C���� =�<r )�__name__� __module__�__qualname__�__doc__r r r r �staticmethodr r r r r r r v sp � � � � � �� � �C��D��N��O��J� J� �\�J� �L� L� �\�L� L� Lr r c �8 � g } t j � | � � }|d | k r|� d|d � � nN|d | k r|� d|d � � n%|d } |� d|d � � ��|S )zA Split a path into all components. From Python Cookbook. Tr � )�os�path�split�insert)r �allparts�partss r �splitallr$ � s� � � �H� )��� � �d�#�#����8�t����O�O�A�u�Q�x�(�(�(�� �1�X�� � ��O�O�A�u�Q�x�(�(�(����8�D��O�O�A�u�Q�x�(�(�(� )� �Or c �� � g }t | � � }t |� � }t ||� � D ]"\ }}||k r n|� |� � �#t j j |� S )z^ Returns the longest common substring to the two strings, starting from the left. )r$ �zip�appendr r �join)�s1�s2�chunks�path1�path2�dir1�dir2s r �common_substringr0 � sn � � �F��R�L�L�E��R�L�L�E��E�5�)�)� � ���t��4�<�<��E�� � �d����� �7�<�� � r c � � t � � � t j � | |� � }nN# t $ rA}|j dk s|j dk r� t j � | |� � }Y d}~nd}~ww xY w| t |� � dd� k r/t � d� |� � � � dS t � d� |� � � � dS ) zD Returns a bool indicating whether we think the code is Py2 � bad input�=N���zDetected Python 2 code: {0}TzDetected Python 3 code: {0}F)r r r �refactor_stringr �msg�valuer �str�logger�debug�format)�source�pathname�tree�es r �detect_python2r@ � s� � � ������:��!�1�1�&�(�C�C����� :� :� :��5�K���1�7�c�>�>���x�'�'���9�9�����������:���� ��T���3�B�3�������2�9�9�(�C�C�D�D�D��t����2�9�9�(�C�C�D�D�D��us � <