î i fÀ ã@svdZddlmZmZddlmZddlmZmZm Z m Z m Z m Z m Z iddddd d d d d gfddddddddddddddddgfddgfgd 6dd d!d"d#d$d%d&d'd(d)d*d+d,d-d.d/d0d1d2d3d4d5d6d7gfdd8d9gfgd:6Zed:jed d;ƒ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Ú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.errorZContentTooShortErrorZurllibZinstall_openerZ build_openerZRequestZOpenerDirectorZ BaseHandlerZHTTPDefaultErrorHandlerZHTTPRedirectHandlerZHTTPCookieProcessorZ ProxyHandlerZHTTPPasswordMgrZHTTPPasswordMgrWithDefaultRealmZAbstractBasicAuthHandlerZHTTPBasicAuthHandlerZProxyBasicAuthHandlerZAbstractDigestAuthHandlerZHTTPDigestAuthHandlerZProxyDigestAuthHandlerZ HTTPHandlerZ HTTPSHandlerZ FileHandlerZ FTPHandlerZCacheFTPHandlerZUnknownHandlerZURLErrorZ HTTPErrorZurllib2é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/python34/lib64/python3.4/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ƒrI|d}nd}x6t|jD]'}|j|dkr]|d}Pq]q]W|rª|jt|d|ƒƒqû|j|dƒn>g}i} |d} xÍ| D]Å}|j t j kr|j d j} |j dj} n|j} d} | d krÚxlt|jD]Z}| |dkr>|d| krx|j |dƒn| j|dgƒj |ƒq>q>WqÚqÚWg} t|ƒ}d }d d „}xÃ|D]»}| |}g}x>|dd…D],}|j|||ƒƒ|j tƒƒqõW|j||d|ƒƒt||ƒ}| sj|jjj|ƒrv||_n| 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}nx6t|jD]'}|j|dkrN|d}PqNqNW|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||ƒnf|jdƒrf|j||ƒnD|jdƒrˆ|j|dƒn"|jdƒrª|j|dƒndS)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ÚsD4