Ñò
$8Zc           @   sz   d  Z  d d k l Z d d k l Z l Z l Z l Z d d k l	 Z	 l
 Z
 l Z d „  Z d e i f d „  ƒ  YZ d	 S(
   sÞ   Fixer for import statements.
If spam is being imported from the local directory, this import:
    from spam import eggs
Becomes:
    from .spam import eggs

And this import:
    import spam
Becomes:
    from . import spam
i   (   t
   fixer_baseiÿÿÿÿ(   t   dirnamet   joint   existst   sep(   t
   FromImportt   symst   tokenc         c   sø   |  g } xè | oà | i  ƒ  } | i t i j o | i Vq | i t i j o3 d i g  } | i D] } | | i qe ~ ƒ Vq | i t i	 j o | i
 | i d ƒ q | i t i j o! | i | i d d d … ƒ q t d ƒ ‚ q Wd S(   sF   
    Walks over all the names imported in a dotted_as_names node.
    t    i    Niþÿÿÿs   unkown node type(   t   popt   typeR   t   NAMEt   valueR   t   dotted_nameR   t   childrent   dotted_as_namet   appendt   dotted_as_namest   extendt   AssertionError(   t   namest   pendingt   nodet   _[1]t   ch(    (    s.   /usr/lib/python2.6/lib2to3/fixes/fix_import.pyt   traverse_imports   s    	 3!t	   FixImportc           B   s)   e  Z d  Z d „  Z d „  Z d „  Z RS(   sj   
    import_from< 'from' imp=any 'import' ['('] any [')'] >
    |
    import_name< 'import' imp=any >
    c         C   s/   t  t |  ƒ i | | ƒ d | i j |  _ d  S(   Nt   absolute_import(   t   superR   t
   start_treet   future_featurest   skip(   t   selft   treet   name(    (    s.   /usr/lib/python2.6/lib2to3/fixes/fix_import.pyR   .   s    c         C   s  |  i  o d  S| d } | i t i j oZ x" t | d ƒ p | i d } q/ W|  i | i ƒ o d | i | _ | i ƒ  qn t	 } t	 } x4 t
 | ƒ D]& } |  i | ƒ o
 t } qŸ t } qŸ W| o  | o |  i | d ƒ n d  St d | g ƒ } | i | _ | Sd  S(   Nt   impR   i    u   .s#   absolute and local imports together(   R   R
   R   t   import_fromt   hasattrR   t   probably_a_local_importR   t   changedt   FalseR   t   Truet   warningR   t   prefix(   R    R   t   resultsR#   t
   have_localt   have_absolutet   mod_namet   new(    (    s.   /usr/lib/python2.6/lib2to3/fixes/fix_import.pyt	   transform2   s0    

  

c         C   s§   | i  d ƒ o t S| i d d ƒ d } t |  i ƒ } t | | ƒ } t t t | ƒ d ƒ ƒ p t Sx6 d t d d d d	 g D] } t | | ƒ o t Sqƒ Wt S(
   Nu   .i   i    s   __init__.pys   .pys   .pycs   .sos   .sls   .pyd(	   t
   startswithR(   t   splitR   t   filenameR   R   R   R)   (   R    t   imp_namet	   base_patht   ext(    (    s.   /usr/lib/python2.6/lib2to3/fixes/fix_import.pyR&   T   s     	(   t   __name__t
   __module__t   PATTERNR   R1   R&   (    (    (    s.   /usr/lib/python2.6/lib2to3/fixes/fix_import.pyR   &   s   		"N(   t   __doc__R   R    t   os.pathR   R   R   R   t
   fixer_utilR   R   R   R   t   BaseFixR   (    (    (    s.   /usr/lib/python2.6/lib2to3/fixes/fix_import.pyt   <module>   s
   "	