B hLÚHv[ã@södZddlmZmZddlmZmZmZmZm Z m Z m Z dddddd d d d gfd dddddddddddddddgfddgfgdd dd d!d"d#d$d%d&d'd(d)d*d+d,d-d.d/d0d1d2d3d4d5gfdd6d7gfgd8œZ e d9  e d:d;¡dd?„d?eƒZd@S)Az¾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. é)Ú alternatesÚ FixImports)ÚNameÚCommaÚ FromImportÚNewlineÚfind_indentationÚNodeÚsymszurllib.requestZ URLopenerZFancyURLopenerZ urlretrieveZ _urlopenerZurlopenZ urlcleanupZ pathname2urlZ url2pathnamez urllib.parseZquoteZ quote_plusZunquoteZ unquote_plusZ urlencodeZ splitattrZ splithostZ splitnportZ splitpasswdZ splitportZ splitqueryZsplittagZ splittypeZ splituserZ splitvaluez urllib.errorZContentTooShortErrorZinstall_openerZ build_openerZRequestZOpenerDirectorZ BaseHandlerZHTTPDefaultErrorHandlerZHTTPRedirectHandlerZHTTPCookieProcessorZ ProxyHandlerZHTTPPasswordMgrZHTTPPasswordMgrWithDefaultRealmZAbstractBasicAuthHandlerZHTTPBasicAuthHandlerZProxyBasicAuthHandlerZAbstractDigestAuthHandlerZHTTPDigestAuthHandlerZProxyDigestAuthHandlerZ HTTPHandlerZ HTTPSHandlerZ FileHandlerZ FTPHandlerZCacheFTPHandlerZUnknownHandlerZURLErrorZ HTTPError)ÚurllibÚurllib2r r éccs~tƒ}xrt ¡D]f\}}x\|D]T}|\}}t|ƒ}d||fVd|||fVd|Vd|Vd||fVqWqWdS)Nzimport_name< 'import' (module=%r | dotted_as_names< any* module=%r any* >) > zÆimport_from< 'from' mod_member=%r 'import' ( member=%s | import_as_name< member=%s 'as' any > | import_as_names< members=any* >) > zIimport_from< 'from' module_star=%r 'import' star='*' > ztimport_name< 'import' dotted_as_name< module_as=%r 'as' any > > zKpower< bare_with_attr=%r trailer< '.' member=%s > any* > )ÚsetÚMAPPINGÚitemsr)ZbareZ old_moduleZchangesÚchangeZ new_moduleÚmembers©rú;/opt/alt/python37/lib/python3.7/lib2to3/fixes/fix_urllib.pyÚ build_pattern0s   rc@s4eZdZdd„Zdd„Zdd„Zdd„Zd d „Zd S) Ú FixUrllibcCs d tƒ¡S)Nú|)Újoinr)ÚselfrrrrIszFixUrllib.build_patterncCsz| d¡}|j}g}x6t|jdd…D] }| t|d|dtƒg¡q(W| tt|jdd|d¡| |¡dS)z‘Transform for the basic import case. Replaces the old import name with a comma separated list of its replacements. ÚmoduleNéÿÿÿÿr)Úprefix) ÚgetrrÚvalueÚextendrrÚappendÚreplace)rÚnodeÚresultsZ import_modÚprefÚnamesÚnamerrrÚtransform_importLs   zFixUrllib.transform_importcCs<| d¡}|j}| d¡}|rˆt|tƒr0|d}d}x*t|jD]}|j|dkr@|d}Pq@W|rx| t||d¡n | |d¡n°g}i} |d} x–| D]Ž}|j t j krÈ|j d j} |j dj} n |j} d} | d kržxPt|jD]B}| |dkræ|d| kr|  |d¡|  |dg¡  |¡qæWqžWg} t|ƒ}d }d d „}x–|D]Ž}| |}g}x2|dd…D]"}| |||ƒ¡|  tƒ¡qlW| ||d|ƒ¡t||ƒ}|rÆ|jj |¡rÌ||_|   |¡d}qNW| r,g}x&| dd…D]}| |tƒg¡qøW|  | d¡| |¡n | |d¡dS)zšTransform for imports of specific module elements. Replaces the module to be imported from with the appropriate new module. Ú mod_memberÚmemberrNr )rz!This is an invalid module elementréú,TcSsX|jtjkrHt|jdj|d|jd ¡|jd ¡g}ttj|ƒgSt|j|dgS)Nr)rr r*)Útyper Úimport_as_namerÚchildrenrZcloner )r&rZkidsrrrÚ handle_nameŒs   z/FixUrllib.transform_member..handle_namerFzAll module elements are invalid)rrÚ isinstanceÚlistrrr!rÚcannot_convertr,r r-r.r Ú setdefaultrrrrÚparentÚendswithr)rr"r#r(r$r)Únew_namerÚmodulesZmod_dictrZas_nameÚ member_nameZ new_nodesZ indentationÚfirstr/rZeltsr%ZeltÚnewZnodesZnew_noderrrÚtransform_member\sh            zFixUrllib.transform_membercCs€| d¡}| d¡}d}t|tƒr*|d}x*t|jD]}|j|dkr6|d}Pq6W|rp| t||jd¡n | |d¡dS)z.Transform for calls to module members in code.Úbare_with_attrr)Nrr )rz!This is an invalid module element) rr0r1rrr!rrr2)rr"r#Z module_dotr)r6rrrrÚ transform_dot¨s   zFixUrllib.transform_dotcCsz| d¡r| ||¡n^| d¡r0| ||¡nF| d¡rH| ||¡n.| d¡r`| |d¡n| d¡rv| |d¡dS)Nrr(r<Z module_starzCannot handle star imports.Z module_asz#This module is now multiple modules)rr'r;r=r2)rr"r#rrrÚ transform¹s     zFixUrllib.transformN)Ú__name__Ú __module__Ú __qualname__rr'r;r=r>rrrrrGs LrN)Ú__doc__Zlib2to3.fixes.fix_importsrrZlib2to3.fixer_utilrrrrrr r rr rrrrrrÚs@$