ó
	Q˜[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 ƒ rd | j | _ | j ƒ  t	 d | ƒ qn“ 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(    (    sD   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(    (    sD   lib/python2.7/site-packages/libfuturize/fixes/fix_absolute_import.pyR   I   s    "(   t   __name__t
   __module__t	   run_orderR   R   (    (    (    sD   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	   (    (    (    sD   lib/python2.7/site-packages/libfuturize/fixes/fix_absolute_import.pyt   <module>   s   "