o
    áË·eD  ã                   @   sd   d Z ddlmZmZmZmZ ddlmZ ddlm	Z	m
Z
 ddlmZ ddlmZ G dd„ deƒZd	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 Zd ZdZdd„ Zdd„ ZdS )ÚFixAbsoluteImporté	   c                 C   sÒ   | j rdS |d }|jtjkr7t|dƒs|jd }t|dƒr|  |j¡r5d|j |_| ¡  t	d|ƒ dS dS d}d}t
|ƒD ]}|  |¡rId}q?d}q?|rX|rV|  |d	¡ dS td|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!   ú\/var/www/ideatree/venv/lib/python3.10/site-packages/libfuturize/fixes/fix_absolute_import.pyÚ	transform   s4   


ÿý

zFixAbsoluteImport.transformc                 C   sv   |  d¡rdS | dd¡d }t| jƒ}t||ƒ}ttt|ƒdƒƒs$dS dtddd	d
dfD ]}t|| ƒr8 dS q-dS )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"   r   I   s   


ÿz)FixAbsoluteImport.probably_a_local_importN)Ú__name__Ú
__module__Ú__qualname__Ú	run_orderr#   r   r!   r!   r!   r"   r      s    *r   N)Ú__doc__Úos.pathr   r   r   r   Úlib2to3.fixes.fix_importr   Úlib2to3.fixer_utilr   r   r	   Úlibfuturize.fixer_utilr
   r   r!   r!   r!   r"   Ú<module>   s    