
    ,]D                     r    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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                       e Zd ZdZd Zd ZdS )FixAbsoluteImport	   c                 @   | j         rdS |d         }|j        t          j        k    r~t	          |d          s|j        d         }t	          |d          |                     |j                  r5d|j        z   |_        |                                 t          d|           dS dS d}d}t          |          D ]}|                     |          rd}d}|r|r|                     |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news           G/usr/lib/python3/dist-packages/libfuturize/fixes/fix_absolute_import.py	transformzFixAbsoluteImport.transform   sW    9 	Fen9(((
 c7++ &l1o c7++ &++CI66 8 39,	0$777778 8
 J!M,S11 ) )//99 )!%JJ$(MM  N LL'LMMMTC5))CCJ,d333J    c                 X   |                     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          ||z             r dS 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exts       r$   r   z)FixAbsoluteImport.probably_a_local_importI   s    
 t$$ 	5>>$**1-DM**	H--	 d79--}==>> 	53uffE 	 	Ci#o&& ttur&   N)__name__
__module____qualname__	run_orderr%   r    r&   r$   r   r      s8        I( ( (T    r&   r   N)__doc__os.pathr   r   r   r   lib2to3.fixes.fix_importr   lib2to3.fixer_utilr   r	   r
   libfuturize.fixer_utilr   r   r3   r&   r$   <module>r9      s    & / . . . . . . . . . . . . . . . . . / / / / / / / / 5 5 5 5 5 5 0 0 0 0 0 0? ? ? ? ?	 ? ? ? ? ?r&   