a
´i¯ ã @ s¤ d Z ddlmZmZ ddlmZmZmZmZm Z m
Z
mZ dg d¢fdg d¢fdd gfgdg d
¢fdddgfgd
œZed
ed d ¡ dd„ ZG dd„ 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 URLopenerZFancyURLopenerÚurlretrieveZ
_urlopenerÚurlopenÚ
urlcleanupÚpathname2urlÚurl2pathnameÚ
getproxieszurllib.parse)ÚquoteÚ
quote_plusÚunquoteÚunquote_plusÚ urlencodeÚ splitattrÚ splithostÚ
splitnportÚsplitpasswdÚ splitportÚ
splitqueryÚsplittagÚ splittypeÚ splituserÚ
splitvaluezurllib.errorÚContentTooShortError)r Zinstall_openerZbuild_openerZRequestZOpenerDirectorZBaseHandlerZHTTPDefaultErrorHandlerZHTTPRedirectHandlerZHTTPCookieProcessorZProxyHandlerZHTTPPasswordMgrZHTTPPasswordMgrWithDefaultRealmZAbstractBasicAuthHandlerZHTTPBasicAuthHandlerZProxyBasicAuthHandlerZAbstractDigestAuthHandlerZHTTPDigestAuthHandlerZProxyDigestAuthHandlerZHTTPHandlerZHTTPSHandlerÚFileHandlerZ
FTPHandlerZCacheFTPHandlerZUnknownHandlerÚURLErrorÚ HTTPError)ÚurllibÚurllib2r% r$ é c c sv t ƒ } t ¡ D ]b\}}|D ]T}|\}}t|ƒ}d||f V d|||f V d| V d| V d||f V qqd S )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.9/lib2to3/fixes/fix_urllib.pyÚ
build_pattern0 s( þýÿþÿr. c @ s4 e Zd Zdd„ Zdd„ Zdd„ Zdd„ Zd d
„ ZdS )Ú FixUrllibc C s d tƒ ¡S )Nú|)Újoinr. )Úselfr, r, r- r. I s zFixUrllib.build_patternc C sv | d¡}|j}g }t|j dd… D ] }| t|d |d�tƒ g¡ q&| tt|j d d |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) Úgetr6 r( ÚvalueÚextendr r ÚappendÚreplace)r2 ÚnodeÚresultsZ
import_modÚprefÚnamesÚnamer, r, r- Útransform_importL s
zFixUrllib.transform_importc C s& | d¡}|j}| d¡}|r†t|tƒr0|d }d}t|j D ]}|j|d v r>|d } q^q>|rv| t||d�¡ n| |d¡ �nœg }i } |d }
|
D ]Š}|j t
jkrÄ|jd j}|jd j}n
|j}d}|d
kršt|j D ]B}||d v rà|d | v�r|
|d ¡ | |d g ¡
|¡ qàqšg }
t|ƒ}d}dd
„ }|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Úmemberr Nr&