Your IP : 172.28.240.42


Current Path : /usr/lib/python2.7/lib2to3/fixes/
Upload File :
Current File : //usr/lib/python2.7/lib2to3/fixes/fix_urllib.pyc


|_c@ssdZddlmZmZddlmZddlmZmZm	Z	m
Z
mZmZm
Z
iddddd	d
ddd
gfddddddddddddddddgfddgfgd 6dd
d!d"d#d$d%d&d'd(d)d*d+d,d-d.d/d0d1d2d3d4d5d6d7gfdd8d9gfgd:6Zed:jed d;d<Zd=efd>YZd?S(@sFix 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
FixImports(t
fixer_base(tNametCommat
FromImporttNewlinetfind_indentationtNodetsymssurllib.requestt	URLopenertFancyURLopenerturlretrievet
_urlopenerturlopent
urlcleanuptpathname2urlturl2pathnamesurllib.parsetquotet
quote_plustunquotetunquote_plust	urlencodet	splitattrt	splithostt
splitnporttsplitpasswdt	splitportt
splitquerytsplittagt	splittypet	splitusert
splitvaluesurllib.errortContentTooShortErrorturllibtinstall_openertbuild_openertRequesttOpenerDirectortBaseHandlertHTTPDefaultErrorHandlertHTTPRedirectHandlertHTTPCookieProcessortProxyHandlertHTTPPasswordMgrtHTTPPasswordMgrWithDefaultRealmtAbstractBasicAuthHandlertHTTPBasicAuthHandlertProxyBasicAuthHandlertAbstractDigestAuthHandlertHTTPDigestAuthHandlertProxyDigestAuthHandlertHTTPHandlertHTTPSHandlertFileHandlert
FTPHandlertCacheFTPHandlertUnknownHandlertURLErrort	HTTPErrorturllib2iccst}xtjD]w\}}xh|D]`}|\}}t|}d||fVd|||fVd|Vd|Vd||fVq)WqWdS(Nsimport_name< 'import' (module=%r
                                  | dotted_as_names< any* module=%r any* >) >
                  simport_from< 'from' mod_member=%r 'import'
                       ( member=%s | import_as_name< member=%s 'as' any > |
                         import_as_names< members=any*  >) >
                  sIimport_from< 'from' module_star=%r 'import' star='*' >
                  stimport_name< 'import'
                                  dotted_as_name< module_as=%r 'as' any > >
                  sKpower< bare_with_attr=%r trailer< '.' member=%s > any* >
                  (tsettMAPPINGtitemsR(tbaret
old_moduletchangestchanget
new_moduletmembers((s./usr/lib/python2.7/lib2to3/fixes/fix_urllib.pyt
build_pattern1s	
		t	FixUrllibcBs5eZdZdZdZdZdZRS(cCsdjtS(Nt|(tjoinRF(tself((s./usr/lib/python2.7/lib2to3/fixes/fix_urllib.pyRFJscCs|jd}|j}g}x?t|jd D],}|jt|dd|tgq0W|jtt|jddd||j|dS(sTransform for the basic import case. Replaces the old
           import name with a comma separated list of its
           replacements.
        tmoduleiitprefixN(	tgetRLR>tvaluetextendRRtappendtreplace(RJtnodetresultst
import_modtpreftnamestname((s./usr/lib/python2.7/lib2to3/fixes/fix_urllib.pyttransform_importMs	*(cCs|jd}|j}|jd}|rt|trI|d}nd
}x6t|jD]'}|j|dkr]|d}Pq]q]W|r|jt|d|q|j	|dn/g}i}	|d}
x|
D]}|j
tjkr|j
dj}|j
dj}n|j}d
}|d	krxlt|jD]Z}||dkr>|d|	krx|j|dn|	j|dgj|q>q>WqqWg}
t|}t}d
}x|D]}|	|}g}x8|d D],}|j||||jtqW|j||d|t||}|sa|jjj|rm||_n|
j|t}qW|
rg}x(|
d D]}|j|tgqW|j|
d|j|n|j	|dd
S(sTransform for imports of specific module elements. Replaces
           the module to be imported from with the appropriate new
           module.
        t
mod_membertmemberiiRLs!This is an invalid module elementREiu,cSsz|jtjkrdt|jdjd||jdj|jdjg}ttj|gSt|jd|gS(NiRLii(ttypeR	timport_as_nameRtchildrenRNtcloneR(RWRLtkids((s./usr/lib/python2.7/lib2to3/fixes/fix_urllib.pythandle_namesisAll module elements are invalidN(RMRLt
isinstancetlisttNoneR>RNRQRtcannot_convertR[R	R\R]RPt
setdefaultRtTrueRORRtparenttendswithtFalseR(RJRRRSRYRURZtnew_nameRCtmodulestmod_dictREtas_nametmember_namet	new_nodestindentationtfirstR`RKteltsRVtelttnewtnodestnew_node((s./usr/lib/python2.7/lib2to3/fixes/fix_urllib.pyttransform_member]sh	



	+	



cCs|jd}|jd}d}t|tr@|d}nx6t|jD]'}|j|dkrN|d}PqNqNW|r|jt|d|jn|j	|ddS(s.Transform for calls to module members in code.tbare_with_attrRZiiRLs!This is an invalid module elementN(
RMRcRaRbR>RNRQRRLRd(RJRRRSt
module_dotRZRjRC((s./usr/lib/python2.7/lib2to3/fixes/fix_urllib.pyt
transform_dots

cCs|jdr"|j||n|jdrD|j||nf|jdrf|j||nD|jdr|j|dn"|jdr|j|dndS(NRKRYRxtmodule_starsCannot handle star imports.t	module_ass#This module is now multiple modules(RMRXRwRzRd(RJRRRS((s./usr/lib/python2.7/lib2to3/fixes/fix_urllib.pyt	transforms(t__name__t
__module__RFRXRwRzR}(((s./usr/lib/python2.7/lib2to3/fixes/fix_urllib.pyRGHs
			L	N(t__doc__tlib2to3.fixes.fix_importsRRtlib2to3Rtlib2to3.fixer_utilRRRRRRR	R>RPRFRG(((s./usr/lib/python2.7/lib2to3/fixes/fix_urllib.pyt<module>sD4