File: //usr/lib/python3.6/site-packages/libfuturize/fixes/__pycache__/fix_absolute_import.cpython-36.pyc
3
�cD � @ sd d Z ddlmZmZmZmZ ddlmZ ddlm Z m
Z
ddlmZ ddlm
Z
G dd� de�Zd S )
a�
Fixer for import statements, with a __future__ import line.
Based on lib2to3/fixes/fix_import.py, but extended slightly so it also
supports Cython modules.
If spam is being imported from the local directory, this import:
from spam import eggs
becomes:
from __future__ import absolute_import
from .spam import eggs
and this import:
import spam
becomes:
from __future__ import absolute_import
from . import spam
� )�dirname�join�exists�sep)� FixImport)�
FromImport�syms)�traverse_imports)�
future_importc @ s e Zd ZdZdd� Zdd� ZdS )�FixAbsoluteImport� c C s� | j r
dS |d }|jtjkrdxt|d�s6|jd }q W | j|j�r�d|j |_|j� t d|� nhd}d}x$t
|�D ]}| j|�r�d}qvd}qvW |r�|r�| j|d � dS td|g�}|j
|_
t d|� |S dS )
z�
Copied from FixImport.transform(), but with this line added in
any modules that had implicit relative imports changed:
from __future__ import absolute_import"
N�imp�valuer �.Zabsolute_importFTz#absolute and local imports together)�skip�typer Zimport_from�hasattrZchildren�probably_a_local_importr Zchangedr
r Zwarningr �prefix)�selfZnode�resultsr
Z
have_localZ
have_absoluteZmod_name�new� r �)/usr/lib/python3.6/fix_absolute_import.py� transform s0
zFixAbsoluteImport.transformc C sx |j d�rdS |jdd�d }t| j�}t||�}ttt|�d��sHdS x*dtddd d
dgD ]}t|| �r\dS q\W dS )
zq
Like the corresponding method in the base class, but this also
supports Cython modules.
r F� r z__init__.pyz.pyz.pycz.soz.slz.pydz.pyxT)�
startswith�splitr �filenamer r r )r Zimp_name� base_pathZextr r r r I s
z)FixAbsoluteImport.probably_a_local_importN)�__name__�
__module__�__qualname__Z run_orderr r r r r r r s *r N)�__doc__Zos.pathr r r r Zlib2to3.fixes.fix_importr Zlib2to3.fixer_utilr r r Zlibfuturize.fixer_utilr
r r r r r �<module> s