U
    hD                     @   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r`t|ds4|jd }q| |jrd|j |_|  t	d| ndd}d}t
|D ]}| |rd}qpd}qp|r|r| |d	 dS td|g}|j|_t	d| |S 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   Zimport_fromhasattrchildrenprobably_a_local_importr   changedr
   r	   warningr   prefix)selfnoderesultsr   Z
have_localZhave_absolutemod_namenew r   W/var/www/html/venv/lib/python3.8/site-packages/libfuturize/fixes/fix_absolute_import.py	transform   s0    


zFixAbsoluteImport.transformc                 C   sv   | drdS |ddd }t| j}t||}ttt|dsHdS dtddd	d
dfD ]}t|| rZ dS qZd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   Zimp_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__os.pathr   r   r   r   Zlib2to3.fixes.fix_importr   Zlib2to3.fixer_utilr   r   r	   Zlibfuturize.fixer_utilr
   r   r   r   r   r   <module>   s   