U if @sddlmZmZddlmZmZmZmZmZm Z m Z ddddddd d d gfd d ddddddddddddddgfddgfgddddd d!d"d#d$d%d&d'd(d)d*d+d,d-d.d/d0d1d2d3d4gfdd5d6gfgd7Z e d8 e d9d:d;d<Z Gd=d>d>eZd?S)@) alternates FixImports)NameComma FromImportNewlinefind_indentationNodesymszurllib.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)urlliburllib2r r ccsvt}tD]b\}}|D]T}|\}}t|}d||fVd|||fVd|Vd|Vd||fVqqdS)Nzimport_name< 'import' (module=%r | dotted_as_names< any* module=%r any* >) > zimport_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* > )setMAPPINGitemsr)ZbareZ old_moduleZchangeschangeZ new_modulemembersr=/opt/alt/python38/lib64/python3.8/lib2to3/fixes/fix_urllib.py build_pattern0s(rc@s4eZdZddZddZddZddZd d Zd S) FixUrllibcCs dtS)N|)joinr)selfrrrrIszFixUrllib.build_patterncCsv|d}|j}g}t|jddD] }|t|d|dtgq&|tt|jdd|d||dS)Nmodulerprefix) getrrvalueextendrrappendreplace)rnoderesultsZ import_modprefnamesnamerrrtransform_importLs  zFixUrllib.transform_importcCs&|d}|j}|d}|rt|tr0|d}d}t|jD]}|j|dkr>|d}q^q>|rv|t||dn ||dng}i} |d} | D]}|j t j kr|j dj} |j dj} n |j} d} | d krt|jD]B}| |dkr|d| kr | |d| |dg |qqg} t|}d }d d }|D]}| |}g}|dd D]"}||||| tq^|||d |t||}|r|jj|r||_| |d}qB| rg}| dd D]}||tgq| | d ||n ||ddS)N mod_membermemberrr r!This is an invalid module elementr,TcSsX|jtjkrHt|jdj|d|jd|jdg}ttj|gSt|j|dgS)Nrrr r,)typer import_as_namerchildrenrZcloner )r'rZkidsrrr handle_names   z/FixUrllib.transform_member..handle_namerFzAll module elements are invalid)rr isinstancelistrrr"rcannot_convertr.r r/r0r! setdefaultrr rrparentendswithr)rr#r$r)r%r*new_namermodulesZmod_dictrZas_name member_nameZ new_nodesZ indentationfirstr1rZeltsr&ZeltnewZnodesZnew_noderrrtransform_member\sh         zFixUrllib.transform_membercCs~|d}|d}d}t|tr*|d}t|jD]}|j|dkr4|d}qTq4|rn|t||jdn ||ddS)Nbare_with_attrr*rr rr+) rr2r3rrr"rrr4)rr#r$Z module_dotr*r8rrrr transform_dots    zFixUrllib.transform_dotcCsz|dr|||n^|dr0|||nF|drH|||n.|dr`||dn|drv||ddS)Nrr)r>Z module_starzCannot handle star imports.Z module_asz#This module is now multiple modules)rr(r=r?r4)rr#r$rrr transforms     zFixUrllib.transformN)__name__ __module__ __qualname__rr(r=r?r@rrrrrGs LrN)Zlib2to3.fixes.fix_importsrrZlib2to3.fixer_utilrrrrrr r rr!rrrrrrs|$ !