ðÕYfÀ ã@stdZddlmZmZddlmZddlmZmZm Z m Z m Z m Z m Z ddddd d d d d dgfddddddddddddddddgfdd gfgd!dd d"d#d$d%d&d'd(d)d*d+d,d-d.d/d0d1d2d3d4d5d6d7d8gfdd9d:gfgiZed!jedd;ƒd<d=„ZGd>d?„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)Ú fixer_base)ÚNameÚCommaÚ FromImportÚNewlineÚfind_indentationÚNodeÚsymsZurllibzurllib.requestZ URLopenerZFancyURLopenerZ urlretrieveZ _urlopenerZurlopenZ urlcleanupZ pathname2urlZ url2pathnamez urllib.parseZquoteZ quote_plusZunquoteZ unquote_plusZ urlencodeZ splitattrZ splithostZ splitnportZ splitpasswdZ splitportZ splitqueryZsplittagZ splittypeZ splituserZ splitvaluez urllib.errorZContentTooShortErrorZurllib2Zinstall_openerZ build_openerZRequestZOpenerDirectorZ BaseHandlerZHTTPDefaultErrorHandlerZHTTPRedirectHandlerZHTTPCookieProcessorZ ProxyHandlerZHTTPPasswordMgrZHTTPPasswordMgrWithDefaultRealmZAbstractBasicAuthHandlerZHTTPBasicAuthHandlerZProxyBasicAuthHandlerZAbstractDigestAuthHandlerZHTTPDigestAuthHandlerZProxyDigestAuthHandlerZ HTTPHandlerZ HTTPSHandlerZ FileHandlerZ FTPHandlerZCacheFTPHandlerZUnknownHandlerZURLErrorZ HTTPErroréccs•tƒ}x…tjƒD]w\}}xh|D]`}|\}}t|ƒ}d||fVd|||fVd|Vd|Vd||fVq)WqWdS)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/python35/lib64/python3.5/lib2to3/fixes/fix_urllib.pyÚ build_pattern1s      rc@sLeZdZdd„Zdd„Zdd„Zdd„Zd d „Zd S) Ú FixUrllibcCsdjtƒƒS)Nú|)Újoinr)ÚselfrrrrJszFixUrllib.build_patterncCsŸ|jdƒ}|j}g}xEt|jdd…D],}|jt|dd|ƒtƒgƒq6W|jtt|jddd|ƒƒ|j|ƒdS)z‘Transform for the basic import case. Replaces the old import name with a comma separated list of its replacements. ÚmoduleNr rÚprefixéÿÿÿÿr) ÚgetrrÚvalueÚextendrrÚappendÚreplace)rÚnodeÚresultsZ import_modÚprefÚnamesÚnamerrrÚtransform_importMs *(zFixUrllib.transform_importcCsí|jdƒ}|j}|jdƒ}|r·t|tƒrF|d}d}x3t|jD]$}|j|dkrZ|d}PqZW|r¤|jt|d|ƒƒqé|j|dƒn2g}i} |d} xÄ| D]¼}|j t j kr|j d j} |j dj} n|j} d} | d krÔxct|jD]T}| |dkr8|d| kro|j |dƒ| j|dgƒj |ƒq8WqÔWg} t|ƒ}d }d d „}xÀ|D]¸}| |}g}x>|dd…D],}|j|||ƒƒ|j tƒƒqæW|j||d|ƒƒt||ƒ}| s[|jjj|ƒrd||_| j |ƒd}q¿W| rÙg}x.| dd…D]}|j|tƒgƒq˜W|j | dƒ|j|ƒn|j|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éú,TcSsz|jtjkrdt|jdjd|ƒ|jdjƒ|jdjƒg}ttj|ƒgSt|jd|ƒgS)Nrrr r))Útyper Úimport_as_namerÚchildrenrZcloner )r%rZkidsrrrÚ handle_name�s z/FixUrllib.transform_member..handle_nameFzAll module elements are invalidrrrr)rrÚ isinstanceÚlistrrr rÚcannot_convertr+r r,r-rÚ setdefaultr rrrÚparentÚendswithr)rr!r"r'r#r(Únew_namerÚmodulesZmod_dictrZas_nameZ member_nameZ new_nodesZ indentationÚfirstr.rZeltsr$ZeltÚnewZnodesZnew_noderrrÚtransform_member]sh       %       zFixUrllib.transform_membercCs¬|jdƒ}|jdƒ}d}t|tƒr=|d}x3t|jD]$}|j|dkrK|d}PqKW|r˜|jt|d|jƒƒn|j|dƒdS)z.Transform for calls to module members in code.Úbare_with_attrr(Nrr rz!This is an invalid module element) rr/r0rrr rrr1)rr!r"Z module_dotr(r5rrrrÚ transform_dot©s  zFixUrllib.transform_dotcCs«|jdƒr"|j||ƒn…|jdƒrD|j||ƒnc|jdƒrf|j||ƒnA|jdƒrˆ|j|dƒn|jdƒr§|j|dƒdS)Nrr'r:Z module_starzCannot handle star imports.Z module_asz#This module is now multiple modules)rr&r9r;r1)rr!r"rrrÚ transformºszFixUrllib.transformN)Ú__name__Ú __module__Ú __qualname__rr&r9r;r<rrrrrHs    L rN)Ú__doc__Zlib2to3.fixes.fix_importsrrZlib2to3rZlib2to3.fixer_utilrrrrr r r rrrrrrrrÚsF4