File: //opt/alt/python27/lib/python2.7/site-packages/libfuturize/fixes/fix_absolute_import.pyc
�
�A�[c           @   s�   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
 d e f d �  �  YZ d	 S(
   s�  
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
i����(   t   dirnamet   joint   existst   sep(   t	   FixImport(   t
   FromImportt   syms(   t   traverse_imports(   t
   future_importt   FixAbsoluteImportc           B   s    e  Z d  Z d �  Z d �  Z RS(   i	   c         C   s"  |  j  r
 d S| d } | j t j k r� x  t | d � sK | j d } q, W|  j | j � rd | j | _ | j �  t	 d | � qn� t
 } t
 } x2 t | � D]$ } |  j | � r� t } q� t } q� W| r� | r� |  j
 | d � n  d St d | g � } | j | _ t	 d | � | Sd S(   s�   
        Copied from FixImport.transform(), but with this line added in
        any modules that had implicit relative imports changed:
            from __future__ import absolute_import"
        Nt   impt   valuei    u   .u   absolute_imports#   absolute and local imports together(   t   skipt   typeR   t   import_fromt   hasattrt   childrent   probably_a_local_importR   t   changedR   t   FalseR   t   Truet   warningR   t   prefix(   t   selft   nodet   resultsR
   t
   have_localt
   have_absolutet   mod_namet   new(    (    sV   /opt/alt/python27/lib/python2.7/site-packages/libfuturize/fixes/fix_absolute_import.pyt	   transform   s0    	
	
c         C   s�   | j  d � r t S| j d d � d } t |  j � } t | | � } t t t | � d � � sf t Sx7 d t d d d d	 d
 g D] } t | | � r� t Sq� Wt S(   sq   
        Like the corresponding method in the base class, but this also
        supports Cython modules.
        u   .i   i    s   __init__.pys   .pys   .pycs   .sos   .sls   .pyds   .pyx(	   t
   startswithR   t   splitR    t   filenameR   R   R   R   (   R   t   imp_namet	   base_patht   ext(    (    sV   /opt/alt/python27/lib/python2.7/site-packages/libfuturize/fixes/fix_absolute_import.pyR   I   s    "(   t   __name__t
   __module__t	   run_orderR   R   (    (    (    sV   /opt/alt/python27/lib/python2.7/site-packages/libfuturize/fixes/fix_absolute_import.pyR	      s   	*N(   t   __doc__t   os.pathR    R   R   R   t   lib2to3.fixes.fix_importR   t   lib2to3.fixer_utilR   R   R   t   libfuturize.fixer_utilR   R	   (    (    (    sV   /opt/alt/python27/lib/python2.7/site-packages/libfuturize/fixes/fix_absolute_import.pyt   <module>   s   "