관리-도구
편집 파일: __init__.cpython-37.opt-1.pyc
B �A�[�G � # @ sZ d Z ddlZddlZddlZddlZddlZddlZddlmZ ddl m Z ddlmZ e� e�Ze�ej� eej�eej� eej� eej� Zdddd d ddd ddddddddddddddddddd d!d"d#d$d%d&d'd(g#ZG d)d*� d*�Zd+d,� Zd-d.� Zd/d0� ZG d1d2� d2e�Ze� Zd>d4d5�Z d6d7� Z!d8d9� Z"G d:d;� d;e�Z#G d<d=� d=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 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)�fixeszlib2to3.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 @ s8 e Zd ZdZdZdZdZdZedd� �Z edd� �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 C s. dt jt jgkr*tt�t _ttddi�t _dS )zj Call this before using the refactoring tools to create them on demand if needed. N�print_functionT)r �_rt�_rtpr �myfixes� r r �J/opt/alt/python37/lib/python3.7/site-packages/past/translation/__init__.py�setup� s z RTs.setupc C s. dt jt jgkr*tt�t _ttddi�t _dS )zj Call this before using the refactoring tools to create them on demand if needed. Nr T)r �_rt_py2_detect�_rtp_py2_detectr �py2_detect_fixersr r r r �setup_detect_python2� s zRTs.setup_detect_python2)�__name__� __module__�__qualname__�__doc__r r r r �staticmethodr r r r r r r v s r c C sr g }xht j�| �}|d | kr2|�d|d � P q|d | krR|�d|d � P q|d } |�d|d � qW |S )zA Split a path into all components. From Python Cookbook. r � )�os�path�split�insert)r Zallparts�partsr r r �splitall� s r c C sL g }t | �}t |�}x*t||�D ]\}}||kr2P |�|� q W tjj|� S )z^ Returns the longest common substring to the two strings, starting from the left. )r �zip�appendr r �join)�s1�s2ZchunksZpath1Zpath2Zdir1Zdir2r r r �common_substring� s r"