a XC?h¯ ã@s¤dZddlmZmZddlmZmZmZmZm Z m Z m Z dgd¢fdgd¢fdd gfgdgd ¢fdd d gfgd œZ e d  e dd¡dd„ZGdd„deƒZdS)z¾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.request) Z URLopenerZFancyURLopenerZ urlretrieveZ _urlopenerÚurlopenZ urlcleanupZ pathname2urlZ url2pathnameZ getproxiesz urllib.parse)ZquoteZ quote_plusZunquoteZ unquote_plusZ urlencodeZ splitattrZ splithostZ splitnportZ splitpasswdZ splitportZ splitqueryZsplittagZ splittypeZ splituserZ splitvaluez urllib.errorZContentTooShortError)r Zinstall_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ú=/opt/alt/python39/lib64/python3.9/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|dvr>|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}| |dvrà|d| v�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ÚmemberrNrrú!This is an invalid module elementréú,TcSsX|jtjkrHt|jdj|d�|jd ¡|jd ¡g}ttj|ƒgSt|j|d�gS)Nrrrr-)Útyper Úimport_as_namerÚchildrenr Zcloner )r(rZkidsrrrÚ handle_nameŒs   þz/FixUrllib.transform_member..handle_namerFzAll module elements are invalid)rrÚ isinstanceÚlistrr r#rÚcannot_convertr/r r0r1r"Ú setdefaultrr!rrÚparentÚendswithr)rr$r%r*r&r+Únew_namerÚmodulesZmod_dictrZas_nameÚ member_nameZ new_nodesZ indentationÚfirstr2rÚeltsr'ÚeltÚnewZnodesZnew_noderrrÚtransform_member\sh         zFixUrllib.transform_membercCs~| d¡}| d¡}d}t|tƒr*|d}t|jD]}|j|dvr4|d}qTq4|rn| t||jd�¡n | |d¡dS)z.Transform for calls to module members in code.Úbare_with_attrr+Nrrrr,) rr3r4rr r#rrr5)rr$r%Z module_dotr+r9rrrrÚ transform_dot¨s   ÿ zFixUrllib.transform_dotcCsz| d¡r| ||¡n^| d¡r0| ||¡nF| d¡rH| ||¡n.| d¡r`| |d¡n| d¡rv| |d¡dS)Nrr*rAZ module_starzCannot handle star imports.Z module_asz#This module is now multiple modules)rr)r@rBr5)rr$r%rrrÚ transform¹s     zFixUrllib.transformN)Ú__name__Ú __module__Ú __qualname__rr)r@rBrCrrrrrGs LrN)Ú__doc__Zlib2to3.fixes.fix_importsrrZlib2to3.fixer_utilrrrrrr r rr"rrrrrrÚs.$ÿÿÿö ÿÿñô!