Ñò
$8Zc           @   sg  d  Z  d d k l Z l Z d d k l Z d d k l Z l Z l	 Z	 l
 Z
 l Z h d d d d	 d
 d d d d g f d d d d d d d d d d d d d d d d g f d d  g f g d! 6d d d" d# d$ d% d& d' d( d) d* d+ d, d- d. d/ d0 d1 d2 d3 d4 d5 d6 d7 d8 g f d d9 d: g f g d; 6Z e d; i e d! d ƒ d< „  Z d= e f d> „  ƒ  YZ d? S(@   s¾   Fix changes imports of urllib which are now incompatible.
   This is rather similar to fix_imports, but because of the more
   complex nature of the fixing for urllib, it has its own fixer.
i   (   t
   alternatest
   FixImportsi   (   t
   fixer_base(   t   Namet   Commat
   FromImportt   Newlinet
   attr_chains   urllib.requestt	   URLOpenert   FancyURLOpenert   urlretrievet
   _urlopenert   urlopent
   urlcleanupt   pathname2urlt   url2pathnames   urllib.parset   quotet
   quote_plust   unquotet   unquote_plust	   urlencodet	   splitattrt	   splithostt
   splitnportt   splitpasswdt	   splitportt
   splitqueryt   splittagt	   splittypet	   splitusert
   splitvalues   urllib.errort   ContentTooShortErrort   urllibt   install_openert   build_openert   Requestt   OpenerDirectort   BaseHandlert   HTTPDefaultErrorHandlert   HTTPRedirectHandlert   HTTPCookieProcessort   ProxyHandlert   HTTPPasswordMgrt   HTTPPasswordMgrWithDefaultRealmt   AbstractBasicAuthHandlert   HTTPBasicAuthHandlert   ProxyBasicAuthHandlert   AbstractDigestAuthHandlert   HTTPDigestAuthHandlert   ProxyDigestAuthHandlert   HTTPHandlert   HTTPSHandlert   FileHandlert
   FTPHandlert   CacheFTPHandlert   UnknownHandlert   URLErrort	   HTTPErrort   urllib2c          c   s•   t  ƒ  }  x… t i ƒ  D]w \ } } xh | D]` } | \ } } t | ƒ } d | | f Vd | | | f Vd | Vd | Vd | | f Vq) Wq Wd  S(   Ns   import_name< 'import' (module=%r
                                  | dotted_as_names< any* module=%r any* >) >
                  sÆ   import_from< 'from' mod_member=%r 'import'
                       ( member=%s | import_as_name< member=%s 'as' any > |
                         import_as_names< members=any*  >) >
                  sI   import_from< 'from' module_star=%r 'import' star='*' >
                  st   import_name< 'import'
                                  dotted_as_name< module_as=%r 'as' any > >
                  sK   power< bare_with_attr=%r trailer< '.' member=%s > any* >
                  (   t   sett   MAPPINGt   itemsR    (   t   baret
   old_modulet   changest   changet
   new_modulet   members(    (    s.   /usr/lib/python2.6/lib2to3/fixes/fix_urllib.pyt   build_pattern0   s    	  		t	   FixUrllibc           B   s5   e  Z d  „  Z d „  Z d „  Z d „  Z d „  Z RS(   c         C   s   d i  t ƒ  ƒ S(   Nt   |(   t   joinRD   (   t   self(    (    s.   /usr/lib/python2.6/lib2to3/fixes/fix_urllib.pyRD   I   s    c         C   s™   | i  d ƒ } | i } g  } x? t | i d  D], } | i t | d d | ƒt ƒ  g ƒ q0 W| i t t | i d d d | ƒƒ | i | ƒ d S(   s‘   Transform for the basic import case. Replaces the old
           import name with a comma separated list of its
           replacements.
        t   moduleiÿÿÿÿi    t   prefixN(	   t   getRJ   R<   t   valuet   extendR   R   t   appendt   replace(   RH   t   nodet   resultst
   import_modt   preft   namest   name(    (    s.   /usr/lib/python2.6/lib2to3/fixes/fix_urllib.pyt   transform_importL   s    	 *(c         C   sƒ  | i  d ƒ } | i } | i  d ƒ } | o— t | t ƒ o | d } n d } x8 t | i D]) } | i | d j o | d } Pq` q` W| o | i t | d | ƒƒ q|  i	 | d ƒ n»g  } h  }	 | i  d ƒ }
 x¡ |
 D]™ } | i } | d j o} xz t | i D]g } | | d j oP | d |	 j o |	 | d i
 | ƒ qx| g |	 | d <| i
 | d ƒ qqWqç qç Wg  } xˆ | D]€ } |	 | } g  } x4 | d	  D]( } | i t | d | ƒt ƒ  g ƒ q²W| i
 t | d	 d | ƒƒ | i
 t | | ƒ ƒ q‘W| oS g  } x( | d	  D] } | i | t ƒ  g ƒ q-W| i
 | d	 ƒ | i | ƒ n |  i	 | d
 ƒ d S(   sš   Transform for imports of specific module elements. Replaces
           the module to be imported from with the appropriate new
           module.
        t
   mod_membert   memberi    i   RJ   s!   This is an invalid module elementRC   t   ,iÿÿÿÿs   All module elements are invalidN(   RK   RJ   t
   isinstancet   listt   NoneR<   RL   RO   R   t   cannot_convertRN   RM   R   R   R   (   RH   RP   RQ   RW   RS   RX   t   new_nameRA   t   modulest   mod_dictRC   t	   new_nodesRI   t   eltsRT   t   eltt   nodest   new_node(    (    s.   /usr/lib/python2.6/lib2to3/fixes/fix_urllib.pyt   transform_member\   s`    	 
		 	 ! 
 & c         C   s¸   | i  d ƒ } | i  d ƒ } d } t | t ƒ o | d } n x8 t | i D]) } | i | d j o | d } PqP qP W| o  | i t | d | i ƒƒ n |  i	 | d ƒ d S(   s.   Transform for calls to module members in code.t   bare_with_attrRX   i    i   RJ   s!   This is an invalid module elementN(
   RK   R\   RZ   R[   R<   RL   RO   R   RJ   R]   (   RH   RP   RQ   t
   module_dotRX   R^   RA   (    (    s.   /usr/lib/python2.6/lib2to3/fixes/fix_urllib.pyt   transform_dot˜   s     
	c         C   s¸   | i  d ƒ o |  i | | ƒ n‘ | i  d ƒ o |  i | | ƒ nm | i  d ƒ o |  i | | ƒ nI | i  d ƒ o |  i | d ƒ n% | i  d ƒ o |  i | d ƒ n d  S(   NRI   RW   Rg   t   module_stars   Cannot handle star imports.t	   module_ass#   This module is now multiple modules(   RK   RV   Rf   Ri   R]   (   RH   RP   RQ   (    (    s.   /usr/lib/python2.6/lib2to3/fixes/fix_urllib.pyt	   transform©   s    (   t   __name__t
   __module__RD   RV   Rf   Ri   Rl   (    (    (    s.   /usr/lib/python2.6/lib2to3/fixes/fix_urllib.pyRE   G   s
   			<	N(   t   __doc__t   fix_importsR    R   t    R   t
   fixer_utilR   R   R   R   R   R<   RN   RD   RE   (    (    (    s.   /usr/lib/python2.6/lib2to3/fixes/fix_urllib.pyt   <module>   sD   (							