Ńň
mČKc           @   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 RS(   sj   
    import_from< 'from' imp=any 'import' ['('] any [')'] >
    |
    import_name< 'import' imp=any >
    c         C   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 togethert   .(   R
   R   t   import_fromt   hasattrR   t   probably_a_local_importR   t   changedt   FalseR   t   Truet   warningR   t   prefix(   t   selfR   t   resultsR   t
   have_localt   have_absolutet   mod_namet   new(    (    s.   /usr/lib/python2.6/lib2to3/fixes/fix_import.pyt	   transform.   s,    
  

c         C   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qn Wt S(
   NR   i   i    s   __init__.pys   .pys   .pycs   .sos   .sls   .pyd(   t   splitR   t   filenameR   R   R!   R   R"   (   R%   t   imp_namet	   base_patht   ext(    (    s.   /usr/lib/python2.6/lib2to3/fixes/fix_import.pyR   N   s     	(   t   __name__t
   __module__t   PATTERNR+   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
   "	