U e5d¡ ã@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 éccsvtƒ}t ¡D]b\}}|D]T}|\}}t|ƒ}d||fVd|||fVd|Vd|Vd||fVqqdS)Nz�import_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ú0/usr/lib64/python3.8/lib2to3/fixes/fix_urllib.pyÚ build_pattern0s(þýÿþÿrc@s4eZdZdd„Zdd„Zdd„Zdd„Zd d „Zd S) Ú FixUrllibcCs d tƒ¡S)Nú|)Újoinr)ÚselfrrrrIszFixUrllib.build_patterncCsv| d¡}|j}g}t|jdd…D] }| t|d|d�tƒg¡q&| 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}t|jD]}|j|dkr>|d}q^q>|rv| t||d�¡n | |d¡�nœg}i} |d} | D]Š}|j t j krÄ|j d j} |j dj} n |j} d} | d kršt|jD]B}| |dkrà|d| k�r |  |d¡|  |dg¡  |¡qàqšg} t|ƒ}d }d d „}|D]Š}| |}g}|dd…D]"}| |||ƒ¡|  tƒ¡�q^| ||d|ƒ¡t||ƒ}|�r¶|jj |¡�r¼||_|   |¡d}�qB| �rg}| dd…D]}| |tƒg¡�qä|  | 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 rú!This is an invalid module elementréú,TcSsX|jtjkrHt|jdj|d�|jd ¡|jd ¡g}ttj|ƒgSt|j|d�gS)Nrrr 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/r0r!Ú setdefaultrr rrÚparentÚendswithr)rr#r$r)r%r*Únew_namerÚmodulesZmod_dictrZas_nameÚ member_nameZ new_nodesZ indentationÚfirstr1rZeltsr&ZeltÚnewZnodesZnew_noderrrÚtransform_member\sh         zFixUrllib.transform_membercCs~| d¡}| d¡}d}t|tƒr*|d}t|jD]}|j|dkr4|d}qTq4|rn| t||jd�¡n | |d¡dS)z.Transform for calls to module members in code.Úbare_with_attrr*Nrr rr+) rr2r3rrr"rrr4)rr#r$Z module_dotr*r8rrrrÚ 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?r4)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~$þÿýÿÿö ôÿÿñô!