관리-도구
편집 파일: fix_absolute_import.cpython-37.opt-1.pyc
B �A�[D � @ 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�r�d|j |_|�� t d|� nhd}d}x$t |�D ]}| �|�r�d}qvd}qvW |r�|r�| �|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 �changedr r Zwarningr �prefix)�selfZnodeZresultsr Z have_localZ have_absoluteZmod_name�new� r �V/opt/alt/python37/lib/python3.7/site-packages/libfuturize/fixes/fix_absolute_import.py� transform s0 zFixAbsoluteImport.transformc C sx |� d�rdS |�dd�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_path�extr 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