File: //lib/python3/dist-packages/libfuturize/fixes/__pycache__/fix_absolute_import.cpython-310.pyc
o
,�]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 rdS |d }|jtjkr7t|d�s|jd }t|d�r| �|j�r5d|j |_|�� t d|� dS dS d}d}t
|�D ]}| �|�rId}q?d}q?|rX|rV| �|d � dS td|g�}|j
|_
t d|� |S )
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 �.�absolute_importFTz#absolute and local imports together)�skip�typer �import_from�hasattr�children�probably_a_local_importr �changedr
r �warningr �prefix)�self�node�resultsr
�
have_local�
have_absolute�mod_name�new� r! �G/usr/lib/python3/dist-packages/libfuturize/fixes/fix_absolute_import.py� transform s4
��
zFixAbsoluteImport.transformc C sv |� d�rdS |�dd�d }t| j�}t||�}ttt|�d��s$dS dtddd d
dfD ]}t|| �r8 dS q-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 �imp_name� base_path�extr! r! r"