3
+��hB: � + @ s� d Z ddlZejdFkr ddlZnddlZddlZddlZddlZddlm Z ddl
mZ ddlm
Z
yddlmZmZ W n ek
r� dZeZY nX ejdd � dGk r�ddlZeje�Zejej� ee
j�ee
j� ee
j� ee
j� Zddd
ddddddddddddddddddd d!d"d#d$d%d&d'd(d)d*d+d,d-g#ZG d.d/� d/�Zd0d1� Z d2d3� Z!d4d5� Z"d6d7� Z#G d8d9� d9e�Z$G d:d;� d;e�Z%e%� Z&f f fd<d=�Z'd>d?� Z(d@dA� Z)G dBdC� dCe�Z*G dDdE� dEe�Z+e'Z,dS )Ha'
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)�
PathFinder�SourceFileLoader� � 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 @ 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 �@/root/tmp/pip-build-yeh9mt8d/future/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 � s r c C sr g }xht jj| �}|d | kr2|jd|d � P q|d | krR|jd|d � P q|d } |jd|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" |