Hacked By AnonymousFox

Current Path : /lib64/python3.8/urllib/__pycache__/
Upload File :
Current File : //lib64/python3.8/urllib/__pycache__/request.cpython-38.opt-2.pyc

U

e5d���!@s�ddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlZddlZddlZddlmZmZmZddlmZmZmZmZmZmZmZmZmZmZm Z m!Z!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'ddl(m)Z)m*Z*zddl+Z+Wne,k
�rdZ-YnXdZ-ddd	d
ddd
ddddddddddddddddddd d!d"d#d$d%d&d'g!Z.d(ej/dd)�Z0da1de
j2fddddd*�d+d�Z3d,d�Z4gZ5d}d-d$�Z6d.d%�Z7e	�8d/e	j9�Z:d0d1�Z;Gd2d�d�Z<Gd3d�d�Z=d4d �Z>Gd5d	�d	�Z?Gd6d�de?�Z@Gd7d
�d
e?�ZAGd8d�de?�ZBd9d:�ZCGd;d
�d
e?�ZDGd<d�d�ZEGd=d�deE�ZFGd>d�deF�ZGGd?d�d�ZHGd@d�deHe?�ZIGdAd�deHe?�ZJejKZLGdBd�d�ZMGdCd�de?eM�ZNGdDd�de?eM�ZOGdEdF�dFe?�ZPGdGd�deP�ZQeRejSdH��r&GdIdJ�dJeP�ZTe.�UdJ�GdKd�de?�ZVGdLd�de?�ZWdMdN�ZXdOdP�ZYGdQd�de?�ZZdRdS�Z[GdTd�de?�Z\GdUd�de\�Z]GdVd�de?�Z^dWZ_ej`dXk�r�ddYlambZbmcZcndZd"�Zbd[d!�ZciZdGd\d&�d&�ZeGd]d'�d'ee�Zfdagd^d_�Zhdaid`da�Zjdakdbdc�Zldamddde�ZnGdfdg�dg�Zodhdi�Zpd~djdk�Zqdldm�Zrejsdnk�r�ddoltmuZumvZvdpdq�Zwdrds�Zxdtdu�Zydvd#�Zzn6ej`dXk�r�dwdx�Z{dyd#�Zzdzd{�Z|d|du�ZynepZzeqZydS)�N)�URLError�	HTTPError�ContentTooShortError)�urlparse�urlsplit�urljoin�unwrap�quote�unquote�
_splittype�
_splithost�
_splitport�
_splituser�_splitpasswd�
_splitattr�_splitquery�_splitvalue�	_splittag�	_to_bytes�unquote_to_bytes�
urlunparse)�
addinfourl�addclosehookFT�Request�OpenerDirector�BaseHandler�HTTPDefaultErrorHandler�HTTPRedirectHandler�HTTPCookieProcessor�ProxyHandler�HTTPPasswordMgr�HTTPPasswordMgrWithDefaultRealm�HTTPPasswordMgrWithPriorAuth�AbstractBasicAuthHandler�HTTPBasicAuthHandler�ProxyBasicAuthHandler�AbstractDigestAuthHandler�HTTPDigestAuthHandler�ProxyDigestAuthHandler�HTTPHandler�FileHandler�
FTPHandler�CacheFTPHandler�DataHandler�UnknownHandler�HTTPErrorProcessor�urlopen�install_opener�build_opener�pathname2url�url2pathname�
getproxies�urlretrieve�
urlcleanup�	URLopener�FancyURLopenerz%d.%d�)�cafile�capath�	cadefault�contextc
Cs�|s|s|rfddl}|�dtd�|dk	r2td��ts>td��tjtjj||d�}t	|d�}t
|�}	n0|r~t	|d�}t
|�}	ntdkr�t
�a}	nt}	|	�|||�S)NrzJcafile, capath and cadefault are deprecated, use a custom context instead.r:zDYou can't pass both context and any of cafile, capath, and cadefaultzSSL support not available)r;r<)r>)
�warnings�warn�DeprecationWarning�
ValueError�	_have_ssl�sslZcreate_default_contextZPurposeZSERVER_AUTH�HTTPSHandlerr2�_opener�open)
�url�data�timeoutr;r<r=r>r?Z
https_handler�opener�rL�&/usr/lib64/python3.8/urllib/request.pyr0�s2<��
�



cCs|adS�N)rF)rKrLrLrMr1�sc
Cs:t|�\}}t�t||����}|��}|dkrN|sNtj�|�|fW5QR�S|r^t|d�}nt	j
dd�}|j}t�
|�|��||f}	d}
d}d}d}
d|kr�t|d	�}|r�||
|
|�|�|
�}|s�q�|t|�7}|�|�|
d
7}
|r�||
|
|�q�W5QRXW5QRX|dk�r6||k�r6td||f|	��|	S)N�file�wbF)�delete� ���r�content-length�Content-Length��1retrieval incomplete: got only %i out of %i bytes)r�
contextlib�closingr0�info�os�path�normpathrG�tempfileZNamedTemporaryFile�name�_url_tempfiles�append�int�read�len�writer)rH�filename�
reporthookrIZurl_typer\�fp�headers�tfp�result�bs�sizerc�blocknum�blockrLrLrMr6�sH


"��c	CsDtD](}zt�|�Wqtk
r*YqXqtdd�=tr@dadSrN)r`r[�unlink�OSErrorrF)Z	temp_filerLrLrMr7$s
z:\d+$cCs<|j}t|�d}|dkr&|�dd�}t�d|d�}|��S)NrV��Host)�full_urlr�
get_header�_cut_port_re�sub�lower)�requestrH�hostrLrLrM�request_host3sr{c@s�eZdZdidddfdd�Zedd��Zejdd��Zejdd��Zed	d
��Zejdd
��Zejdd
��Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zd#dd�Zdd �Zd!d"�ZdS)$rNFc	Csl||_i|_i|_d|_||_d|_|��D]\}}|�||�q,|dkrRt|�}||_	||_
|rh||_dSrN)rtri�unredirected_hdrs�_datarI�_tunnel_host�items�
add_headerr{�origin_req_host�unverifiable�method)	�selfrHrIrir�r�r��key�valuerLrLrM�__init__EszRequest.__init__cCs|jrd�|j|j�S|jS)Nz{}#{})�fragment�format�	_full_url�r�rLrLrMrtWszRequest.full_urlcCs(t|�|_t|j�\|_|_|��dSrN)rr�rr��_parse�r�rHrLrLrMrt]s
cCsd|_d|_d|_dS�Nrr)r�r��selectorr�rLrLrMrtdscCs|jSrN)r}r�rLrLrMrIjszRequest.datacCs(||jkr$||_|�d�r$|�d�dS)N�Content-length)r}�
has_header�
remove_header)r�rIrLrLrMrIns

cCs
d|_dSrN)rIr�rLrLrMrIxscCsNt|j�\|_}|jdkr(td|j��t|�\|_|_|jrJt|j�|_dS)Nzunknown url type: %r)	rr��typerBrtrrzr�r
)r��restrLrLrMr�|s
zRequest._parsecCs|jdk	rdnd}t|d|�S)N�POST�GETr�)rI�getattr)r�Zdefault_methodrLrLrM�
get_method�szRequest.get_methodcCs|jSrN)rtr�rLrLrM�get_full_url�szRequest.get_full_urlcCs2|jdkr|js|j|_n||_|j|_||_dS)N�https)r�r~rzrtr�)r�rzr�rLrLrM�	set_proxy�s

zRequest.set_proxycCs|j|jkSrN)r�rtr�rLrLrM�	has_proxy�szRequest.has_proxycCs||j|��<dSrN)ri�
capitalize�r�r��valrLrLrMr��szRequest.add_headercCs||j|��<dSrN)r|r�r�rLrLrM�add_unredirected_header�szRequest.add_unredirected_headercCs||jkp||jkSrN)rir|�r��header_namerLrLrMr��s
�zRequest.has_headercCs|j�||j�||��SrN)ri�getr|)r�r��defaultrLrLrMru�s�zRequest.get_headercCs |j�|d�|j�|d�dSrN)ri�popr|r�rLrLrMr��szRequest.remove_headercCs|j|j�}t|���SrN)r|ri�listr)r��hdrsrLrLrM�header_items�szRequest.header_items)N)�__name__�
__module__�__qualname__r��propertyrt�setter�deleterrIr�r�r�r�r�r�r�r�rur�r�rLrLrLrMrCs8�





	

c@sNeZdZdd�Zdd�Zdd�Zdd�Zd	ejfd
d�Z	ddd
�Z
dd�Zd	S)rcCs6dt}d|fg|_g|_i|_i|_i|_i|_dS)N�Python-urllib/%sz
User-agent)�__version__�
addheaders�handlers�handle_open�handle_error�process_response�process_request)r�Zclient_versionrLrLrMr��szOpenerDirector.__init__c	CsTt|d�stdt|���d}t|�D�]}|dkr6q&|�d�}|d|�}||dd�}|�d�r�|�d�|d}||dd�}zt|�}Wntk
r�YnX|j�	|i�}	|	|j|<n>|dkr�|}|j
}	n*|d	kr�|}|j}	n|d
kr&|}|j}	nq&|	�
|g�}
|
�r"t�|
|�n
|
�|�d}q&|�rPt�|j|�|�|�dS)N�
add_parentz%expected BaseHandler instance, got %rF)�redirect_request�do_open�
proxy_open�_rV�errorrG�responseryT)�hasattr�	TypeErrorr��dir�find�
startswithrbrBr�r�r�r�r��
setdefault�bisectZinsortrar�r�)r��handlerZadded�meth�i�protocolZ	condition�j�kind�lookupr�rLrLrM�add_handler�sL
�


zOpenerDirector.add_handlercCsdSrNrLr�rLrLrM�close�szOpenerDirector.closec	Gs<|�|d�}|D]&}t||�}||�}|dk	r|SqdS)NrL)r�r�)	r��chainr��	meth_name�argsr�r��funcrkrLrLrM�_call_chain�s
zOpenerDirector._call_chainNc
Cs�t|t�rt||�}n|}|dk	r(||_||_|j}|d}|j�|g�D]}t||�}||�}qJt	�
d|j|j|j|�
��|�||�}	|d}|j�|g�D]}t||�}|||	�}	q�|	S)NZ_requestzurllib.RequestZ	_response)�
isinstance�strrrIrJr�r�r�r��sys�auditrtrir��_openr�)
r��fullurlrIrJ�reqr�r�Z	processorr�r�rLrLrMrG�s$



zOpenerDirector.opencCsP|�|jdd|�}|r|S|j}|�|j||d|�}|r>|S|�|jdd|�S)Nr�Zdefault_openr��unknown�unknown_open)r�r�r�)r�r�rIrkr�rLrLrMr�s$
���
�zOpenerDirector._opencGs~|dkr,|jd}|d}d|}d}|}n|j}|d}d}|||f|}|j|�}|r^|S|rz|dd	f|}|j|�SdS)
N��httpr�r�r:z
http_error_%srVZ_errorrr��http_error_default)r�r�)r��protor��dictr�Zhttp_errZ	orig_argsrkrLrLrMr�&s 

zOpenerDirector.error)N)r�r�r�r�r�r�r��socket�_GLOBAL_DEFAULT_TIMEOUTrGr�r�rLrLrLrMr�s/
c	Gs�t�}ttttttttt	g	}t
tjd�r2|�
t�t�}|D]B}|D]8}t|t�rht||�r||�|�qDt||�rD|�|�qDq<|D]}|�|�q�|D]}|�|��q�|D]}t|t�r�|�}|�|�q�|S)N�HTTPSConnection)rrr.r)rrr+r*r/r-r�r��clientrarE�setr�r��
issubclass�add�remover�)r�rKZdefault_classes�skip�klassZcheck�hrLrLrMr2?s8	�




c@s(eZdZdZdd�Zdd�Zdd�ZdS)	r��cCs
||_dSrN)�parent)r�r�rLrLrMr�fszBaseHandler.add_parentcCsdSrNrLr�rLrLrMr�iszBaseHandler.closecCst|d�sdS|j|jkS)N�
handler_orderT)r�r�)r��otherrLrLrM�__lt__ms
zBaseHandler.__lt__N)r�r�r�r�r�r�r�rLrLrLrMrcsc@seZdZdZdd�ZeZdS)r/i�cCsH|j|j|��}}}d|kr,dksDn|j�d|||||�}|S)N���,r�)�code�msgrZr�r�)r�ryr�r�r�r�rLrLrM�
http_responsezs�z HTTPErrorProcessor.http_responseN)r�r�r�r�r��https_responserLrLrLrMr/vsc@seZdZdd�ZdS)rcCst|j||||��dSrN)rrt)r�r�rhr�r�r�rLrLrMr��sz*HTTPDefaultErrorHandler.http_error_defaultN)r�r�r�r�rLrLrLrMr�sc@s4eZdZdZdZdd�Zdd�ZeZZZ	dZ
dS)	r��
c	st|��}|dkr|dks:|dkr(|dks:t|j||||��|�dd�}d��fdd	�|j��D�}t|||jd
d�S)N)�-�.�/i3)r�ZHEAD)r�r�r�r�� z%20)rTzcontent-typecs"i|]\}}|���kr||�qSrL)rx��.0�k�v�ZCONTENT_HEADERSrLrM�
<dictcomp>�s�z8HTTPRedirectHandler.redirect_request.<locals>.<dictcomp>T)rir�r�)r�rrt�replacerirrr�)	r�r�rhr�r�ri�newurl�mZ
newheadersrLrrMr��s
���z$HTTPRedirectHandler.redirect_requestc
CsLd|kr|d}nd|kr$|d}ndSt|�}|jdkrRt||d||f||��|jsn|jrnt|�}d|d<t|�}t|dtj	d�}t
|j|�}|�||||||�}|dkr�dSt
|d	��r|j}	|_|	�|d
�|jks�t|	�|jk�rt|j||j|||��ni}	|_|_|	�|d
�d|	|<|��|��|jj||jd�S)
N�location�uri�r�r��ftprrz+%s - Redirection to url '%s' is not allowed�/r:z
iso-8859-1)�encoding�safe�
redirect_dictrrV�rJ)r�schemerr\Znetlocr�rr	�stringZpunctuationrrtr�r�r
r��max_repeatsrd�max_redirections�inf_msgrcr�r�rGrJ)
r�r�rhr�r�rir�urlparts�newZvisitedrLrLrM�http_error_302�sT



����z"HTTPRedirectHandler.http_error_302zoThe HTTP server returned a redirect error that would lead to an infinite loop.
The last 30x error message was:
N)r�r�r�rrr�r�http_error_301�http_error_303�http_error_307rrLrLrLrMr�s&<c
Cs�t|�\}}|�d�s d}|}nZ|�d�s6td|��d|krV|�d�}|�d|�}n|�dd�}|dkrnd}|d|�}t|�\}}|dk	r�t|�\}}	nd}}	|||	|fS)Nr
�//zproxy URL with no authority: %r�@r:rS)rr�rBr�rr)
�proxyrZr_scheme�	authorityZhost_separator�endZuserinfo�hostport�user�passwordrLrLrM�_parse_proxy�s$


r"c@s"eZdZdZddd�Zdd�ZdS)r�dNcCsP|dkrt�}||_|��D].\}}|��}t|d||||jfdd��qdS)Nz%s_opencSs||||�SrNrL)�rrr�r�rLrLrM�<lambda>)sz'ProxyHandler.__init__.<locals>.<lambda>)r5�proxiesrrx�setattrr�)r�r&r�rHrLrLrMr�!s
�zProxyHandler.__init__cCs�|j}t|�\}}}}|dkr"|}|jr6t|j�r6dS|rv|rvdt|�t|�f}	t�|	����d�}
|�	dd|
�t|�}|�
||�||ks�|dkr�dS|jj||j
d�SdS)N�%s:%s�ascii�Proxy-authorization�Basic r�r)r�r"rz�proxy_bypassr
�base64�	b64encode�encode�decoder�r�r�rGrJ)r�r�rr�Z	orig_typeZ
proxy_typer r!rZ	user_passZcredsrLrLrMr�,s"�zProxyHandler.proxy_open)N)r�r�r�r�r�r�rLrLrLrMrs
c@s6eZdZdd�Zdd�Zdd�Zd
dd	�Zd
d�ZdS)r cCs
i|_dSrN)�passwdr�rLrLrMr�JszHTTPPasswordMgr.__init__cs\t|t�r|g}|�jkr$i�j|<dD].�t��fdd�|D��}||f�j||<q(dS)N�TFc3s|]}��|��VqdSrN)�
reduce_uri)r��u��default_portr�rLrM�	<genexpr>Tsz/HTTPPasswordMgr.add_password.<locals>.<genexpr>)r�r�r1�tuple)r��realmrr r1�reduced_urirLr5rM�add_passwordMs


�zHTTPPasswordMgr.add_passwordc	Cs`|j�|i�}dD]H}|�||�}|��D].\}}|D] }|�||�r6|Sq6q*qdS)Nr2�NN)r1r�r3r�	is_suburi)	r�r9�authuriZdomainsr6�reduced_authuriZurisZauthinforrLrLrM�find_user_passwordXsz"HTTPPasswordMgr.find_user_passwordTc
Cs�t|�}|dr.|d}|d}|dp*d}nd}|}d}t|�\}}|r~|dkr~|dk	r~ddd��|�}	|	dk	r~d||	f}||fS)	NrVrr:r
�Pi�r�z%s:%d)rr
r�)
r�rr6�partsrrr\rz�portZdportrLrLrMr3bs$��zHTTPPasswordMgr.reduce_uricCsN||krdS|d|dkr dS|d}|dd�dkr@|d7}|d�|�S)NTrFrVrSr
)r�)r��base�test�prefixrLrLrMr=yszHTTPPasswordMgr.is_suburiN)T)r�r�r�r�r;r@r3r=rLrLrLrMr Hs


c@seZdZdd�ZdS)r!cCs0t�|||�\}}|dk	r"||fSt�|d|�SrN)r r@)r�r9r>r r!rLrLrMr@�s�z2HTTPPasswordMgrWithDefaultRealm.find_user_passwordN)r�r�r�r@rLrLrLrMr!�scs<eZdZ�fdd�Zd
�fdd�	Zddd�Zdd	�Z�ZS)r"csi|_t�j||�dSrN)�
authenticated�superr��r�r��kwargs��	__class__rLrMr��sz%HTTPPasswordMgrWithPriorAuth.__init__Fcs<|�||�|dk	r&t��d|||�t��||||�dSrN)�update_authenticatedrHr;)r�r9rr r1�is_authenticatedrKrLrMr;�sz)HTTPPasswordMgrWithPriorAuth.add_passwordcCs>t|t�r|g}dD]$}|D]}|�||�}||j|<qqdS�Nr2)r�r�r3rG)r�rrNr6r4r:rLrLrMrM�s
z1HTTPPasswordMgrWithPriorAuth.update_authenticatedcCsDdD]:}|�||�}|jD]"}|�||�r|j|SqqdSrO)r3rGr=)r�r>r6r?rrLrLrMrN�s

z-HTTPPasswordMgrWithPriorAuth.is_authenticated)F)F)r�r�r�r�r;rMrN�
__classcell__rLrLrKrMr"�s

c@sTeZdZe�dej�Zddd�Zdd�Zdd�Z	d	d
�Z
dd�Zd
d�ZeZ
eZdS)r#z1(?:^|,)[ 	]*([^ 	,]+)[ 	]+realm=(["']?)([^"']*)\2NcCs"|dkrt�}||_|jj|_dSrN)r r1r;)r�Zpassword_mgrrLrLrMr��sz!AbstractBasicAuthHandler.__init__ccspd}tj�|�D]6}|��\}}}|dkr8t�dtd�||fVd}q|sl|r^|��d}nd}|dfVdS)NF)�"�'zBasic Auth Realm was unquoted�Trrr)r#�rx�finditer�groupsr?r@�UserWarning�split)r��headerZfound_challengeZmorr	r9rLrLrM�_parse_realm�s�
z%AbstractBasicAuthHandler._parse_realmc	Cs~|�|�}|sdSd}|D]H}|�|�D]8\}}|��dkrB|}q(|dk	r(|�|||�Sq(q|dk	rztd|f��dS)N�basiczBAbstractBasicAuthHandler does not support the following scheme: %r)Zget_allrZrx�retry_http_basic_authrB)	r��authreqrzr�riZunsupportedrYrr9rLrLrM�http_error_auth_reqed�s
�z.AbstractBasicAuthHandler.http_error_auth_reqedcCs||j�||�\}}|dk	rtd||f}dt�|����d�}|�|jd�|krTdS|�|j|�|j	j
||jd�SdSdS)Nr(r+r)r)r1r@r-r.r/r0ru�auth_headerr�r�rGrJ)r�rzr�r9r �pw�raw�authrLrLrMr\�sz.AbstractBasicAuthHandler.retry_http_basic_authcCstt|jd�r|j�|j�s|S|�d�sp|j�d|j�\}}d�||���}t�	|��
�}|�dd�|����|S)NrN�
Authorizationz{0}:{1}zBasic {})
r�r1rNrtr�r@r�r/r-Zstandard_b64encoder0r��strip)r�r�r r1ZcredentialsZauth_strrLrLrM�http_requests�
�z%AbstractBasicAuthHandler.http_requestcCsLt|jd�rHd|jkr"dkr8nn|j�|jd�n|j�|jd�|S)NrNr�r�TF)r�r1r�rMrt)r�r�r�rLrLrMr�s
z&AbstractBasicAuthHandler.http_response)N)r�r�r��re�compile�IrTr�rZr^r\rer��
https_requestr�rLrLrLrMr#�s�

c@seZdZdZdd�ZdS)r$rccCs|j}|�d|||�}|S)N�www-authenticate)rtr^)r�r�rhr�r�rirHr�rLrLrM�http_error_401$s�z#HTTPBasicAuthHandler.http_error_401N)r�r�r�r_rkrLrLrLrMr$ sc@seZdZdZdd�ZdS)r%r*cCs|j}|�d|||�}|S�N�proxy-authenticate)rzr^)r�r�rhr�r�rirr�rLrLrM�http_error_407/s�z$ProxyBasicAuthHandler.http_error_407N)r�r�r�r_rnrLrLrLrMr%+sc@sNeZdZddd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	dd�Z
dS)r&NcCs4|dkrt�}||_|jj|_d|_d|_d|_dS�Nr)r r1r;�retried�nonce_count�
last_nonce)r�r1rLrLrMr�Is
z"AbstractDigestAuthHandler.__init__cCs
d|_dSro)rpr�rLrLrM�reset_retry_countRsz+AbstractDigestAuthHandler.reset_retry_countcCs||�|d�}|jdkr*t|jdd|d��n|jd7_|rx|��d}|��dkr`|�||�S|��dkrxtd|��dS)	N�i�zdigest auth failedrVrZdigestr[zEAbstractDigestAuthHandler does not support the following scheme: '%s')r�rprrtrXrx�retry_http_digest_authrB)r�r_rzr�rir]rrLrLrMr^Us

��z/AbstractDigestAuthHandler.http_error_auth_reqedcCsz|�dd�\}}ttdt|���}|�||�}|rvd|}|j�|jd�|krRdS|�|j|�|j	j
||jd�}|SdS)Nr�rVz	Digest %sr)rX�parse_keqv_list�filter�parse_http_list�get_authorizationrir�r_r�r�rGrJ)r�r�rb�tokenZ	challenge�chalZauth_valZresprLrLrMruisz0AbstractDigestAuthHandler.retry_http_digest_authcCs@d|j|t��f}|�d�td�}t�|���}|dd�S)Nz	%s:%s:%s:r)��)rq�time�ctimer/�_randombytes�hashlib�sha1�	hexdigest)r��nonce�s�b�digrLrLrM�
get_cnonceusz$AbstractDigestAuthHandler.get_cnoncecCs�z6|d}|d}|�d�}|�dd�}|�dd�}Wntk
rLYdSX|�|�\}}	|dkrhdS|j�||j�\}
}|
dkr�dS|jdk	r�|�|j|�}nd}d|
||f}
d|��|j	f}|dkr�|	||
�d|||�f�}n~d	|�
d
�k�r\||jk�r|jd7_nd|_||_d|j}|�
|�}d
|||d	||�f}|	||
�|�}ntd|��d|
|||j	|f}|�r�|d|7}|�r�|d|7}|d|7}|�r�|d||f7}|S)Nr9r��qop�	algorithm�MD5�opaquez%s:%s:%sr(rb�,rVz%08xz%s:%s:%s:%s:%szqop '%s' is not supported.z>username="%s", realm="%s", nonce="%s", uri="%s", response="%s"z
, opaque="%s"z
, digest="%s"z, algorithm="%s"z, qop=auth, nc=%s, cnonce="%s")r��KeyError�get_algorithm_implsr1r@rtrI�get_entity_digestr�r�rXrrrqr�r)r�r�r{r9r�r�r�r��H�KDr r`ZentdigZA1ZA2ZrespdigZncvalueZcnonceZnoncebitrDrLrLrMry�s\

�


��z+AbstractDigestAuthHandler.get_authorizationcsD|dkrdd��n|dkr$dd��ntd|���fdd�}�|fS)Nr�cSst�|�d����S�Nr))r�Zmd5r/r���xrLrLrMr%��z?AbstractDigestAuthHandler.get_algorithm_impls.<locals>.<lambda>ZSHAcSst�|�d����Sr�)r�r�r/r�r�rLrLrMr%�r�z.Unsupported digest authentication algorithm %rcs�d||f�S)Nr(rL)r��d�r�rLrMr%�r�)rB)r�r�r�rLr�rMr��s

�z-AbstractDigestAuthHandler.get_algorithm_implscCsdSrNrL)r�rIr{rLrLrMr��sz+AbstractDigestAuthHandler.get_entity_digest)N)r�r�r�r�rsr^rur�ryr�r�rLrLrLrMr&>s
	>
c@seZdZdZdZdd�ZdS)r'rc��cCs*t|j�d}|�d|||�}|��|S)NrVrj)rrtr^rs�r�r�rhr�r�rirz�retryrLrLrMrk�s�z$HTTPDigestAuthHandler.http_error_401N)r�r�r�r_r�rkrLrLrLrMr'�sc@seZdZdZdZdd�ZdS)r(�Proxy-Authorizationr�cCs"|j}|�d|||�}|��|Srl)rzr^rsr�rLrLrMrn�s�z%ProxyDigestAuthHandler.http_error_407N)r�r�r�r_r�rnrLrLrLrMr(�sc@s6eZdZd
dd�Zdd�Zdd�Zdd	�Zd
d�ZdS)�AbstractHTTPHandlerrcCs
||_dSrN��_debuglevel)r��
debuglevelrLrLrMr��szAbstractHTTPHandler.__init__cCs
||_dSrNr�)r��levelrLrLrM�set_http_debuglevel�sz'AbstractHTTPHandler.set_http_debuglevelcCstjj�|j|���SrN)r�r��HTTPConnection�_get_content_lengthrIr��r�ryrLrLrMr��s�z'AbstractHTTPHandler._get_content_lengthcCs|j}|std��|jdk	r�|j}t|t�r8d}t|��|�d�sN|�dd�|�d�s�|�d�s�|�|�}|dk	r�|�dt|��n|�dd�|}|�	�r�t
|j�\}}t|�\}}	|�d�s�|�d|�|j
jD]&\}
}|
��}
|�|
�s�|�|
|�q�|S)	N�
no host givenz\POST data should be bytes, an iterable of bytes, or a file object. It cannot be of type str.zContent-type�!application/x-www-form-urlencodedr��Transfer-encodingZchunkedrs)rzrrIr�r�r�r�r�r�r�rr�rr�r�r�)r�ryrzrIr�Zcontent_lengthZsel_hostrZselZsel_pathr_r�rLrLrM�do_request_�sJ


�
�
��

zAbstractHTTPHandler.do_request_c

sT|j}|std��||fd|ji|��}|�|j�t|j�����fdd�|j�	�D��d�d<dd���	�D��|j
r�i}d}|�kr��|||<�|=|j|j
|d	�z`z&|j|�
�|j|j�|�d
�d�Wn,tk
�r}zt|��W5d}~XYnX|��}	Wn|���YnX|j�r>|j��d|_|��|	_|	j|	_|	S)Nr�rJcsi|]\}}|�kr||�qSrLrLr��rirLrMr/s�z/AbstractHTTPHandler.do_open.<locals>.<dictcomp>r��
ConnectioncSsi|]\}}|��|�qSrL)�title)r�r_r�rLrLrMr<sr�r�r�)Zencode_chunked)rzrrJZset_debuglevelr�r�r|�updaterirr~Z
set_tunnelryr�r�rIr�rq�getresponser�Zsockr�rH�reasonr�)
r�Z
http_classr�Zhttp_conn_argsrzr�Ztunnel_headersZproxy_auth_hdr�errr$rLr�rMr�!sB
�


zAbstractHTTPHandler.do_openN)r)r�r�r�r�r�r�r�r�rLrLrLrMr��s

&r�c@seZdZdd�ZejZdS)r)cCs|�tjj|�SrN)r�r�r�r��r�r�rLrLrM�	http_openfszHTTPHandler.http_openN)r�r�r�r�r�r�rerLrLrLrMr)dsr�c@s$eZdZddd�Zdd�ZejZdS)rErNcCst�||�||_||_dSrN)r�r��_context�_check_hostname)r�r�r>�check_hostnamerLrLrMr�oszHTTPSHandler.__init__cCs|jtjj||j|jd�S)N)r>r�)r�r�r�r�r�r�r�rLrLrM�
https_opents�zHTTPSHandler.https_open)rNN)r�r�r�r�r�r�r�rirLrLrLrMrEms
rEc@s.eZdZddd�Zdd�Zdd�ZeZeZdS)	rNcCs$ddl}|dkr|j��}||_dSro)Zhttp.cookiejar�	cookiejarZ	CookieJar)r�r�r�rLrLrMr�}s
zHTTPCookieProcessor.__init__cCs|j�|�|SrN)r�Zadd_cookie_headerr�rLrLrMre�sz HTTPCookieProcessor.http_requestcCs|j�||�|SrN)r�Zextract_cookies)r�ryr�rLrLrMr��sz!HTTPCookieProcessor.http_response)N)r�r�r�r�rer�rir�rLrLrLrMr|s

c@seZdZdd�ZdS)r.cCs|j}td|��dS)Nzunknown url type: %s)r�r)r�r�r�rLrLrMr��szUnknownHandler.unknown_openN)r�r�r�r�rLrLrLrMr.�scCsNi}|D]@}|�dd�\}}|ddkr@|ddkr@|dd�}|||<q|S)N�=rVrrQrS)rX)�lZparsedZeltr�rrLrLrMrv�s
rvcCs�g}d}d}}|D]l}|r*||7}d}q|rT|dkr>d}qn|dkrJd}||7}q|dkrl|�|�d}q|dkrxd}||7}q|r�|�|�dd�|D�S)	NrrF�\TrQr�cSsg|]}|���qSrL)rd)r��partrLrLrM�
<listcomp>�sz#parse_http_list.<locals>.<listcomp>)ra)r��resr��escaper	ZcurrLrLrMrx�s4	


rxc@s(eZdZdd�ZdZdd�Zdd�ZdS)r*cCs\|j}|dd�dkrN|dd�dkrN|jrN|jdkrN|j|��krXtd��n
|�|�SdS)Nr:rrSr
�	localhost�-file:// scheme is supported only on localhost)r�rz�	get_namesr�open_local_file)r�r�rHrLrLrM�	file_open�s&�
zFileHandler.file_openNcCs`tjdkrZz*tt�d�dt�t���d�t_Wn$tjk
rXt�d�ft_YnXtjS)Nr�r:)r*�namesr8r��gethostbyname_ex�gethostname�gaierror�
gethostbynamer�rLrLrMr��s
��
zFileHandler.get_namesc
Cs�ddl}ddl}|j}|j}t|�}z�t�|�}|j}|jj	|j
dd�}	|�|�d}
|�d|
pbd||	f�}|r~t
|�\}}|r�|s�t|�|��kr�|r�d||}
nd|}
tt|d�||
�WSWn*tk
r�}zt|��W5d}~XYnXtd��dS)	NrT�Zusegmtz6Content-type: %s
Content-length: %d
Last-modified: %s
�
text/plain�file://�rbzfile not on local host)�email.utils�	mimetypesrzr�r4r[�stat�st_size�utils�
formatdate�st_mtime�
guess_type�message_from_stringr
�_safe_gethostbynamer�rrGrqr)r�r��emailr�rzrfZ	localfile�statsrm�modified�mtyperirCZorigurl�exprLrLrMr��s:
����zFileHandler.open_local_file)r�r�r�r�r�r�r�rLrLrLrMr*�s
cCs*zt�|�WStjk
r$YdSXdSrN)r�r�r�)rzrLrLrMr��sr�c@seZdZdd�Zdd�ZdS)r+c
Cs*ddl}ddl}|j}|s"td��t|�\}}|dkr>|j}nt|�}t|�\}}|rdt|�\}}nd}t	|�}|pvd}|p~d}zt
�|�}Wn*tk
r�}zt|��W5d}~XYnXt
|j�\}	}
|	�d�}ttt	|��}|dd�|d}}|�r|d�s|dd�}z�|�||||||j�}
|�r6d�p8d}|
D]2}t|�\}}|��d	k�r>|d
k�r>|��}�q>|
�||�\}}d}|�|j�d}|�r�|d|7}|dk	�r�|dk�r�|d|7}t�|�}t|||j�WS|jk
�r$}z"td
|�}|�t� �d��W5d}~XYnXdS)Nr�ftp error: no host givenrrr
rSrVrh�Dr���a�Ar�rhr�r�zContent-type: %s
zContent-length: %d
�
ftp error: %rr:)!�ftplibr�rzrr
�FTP_PORTrbrrr
r�r�rqrr�rXr��map�connect_ftprJrrx�upper�retrfiler�rtr�r�r�
all_errors�with_tracebackr��exc_info)r�r�r�r�rzrCr r1r�r\�attrs�dirsrO�fwr��attrr�rh�retrlenrir�r��excrLrLrM�ftp_opens^
�
zFTPHandler.ftp_openc	Cst||||||dd�S)NF)�
persistent)�
ftpwrapper)r�r r1rzrCr�rJrLrLrMr�7s�zFTPHandler.connect_ftpN)r�r�r�r�r�rLrLrLrMr+s5c@s<eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
S)r,cCs"i|_i|_d|_d|_d|_dS)Nr�<r})�cacherJ�soonest�delay�	max_connsr�rLrLrMr�>s
zCacheFTPHandler.__init__cCs
||_dSrN)r�)r��trLrLrM�
setTimeoutEszCacheFTPHandler.setTimeoutcCs
||_dSrN)r�)r�rrLrLrM�setMaxConnsHszCacheFTPHandler.setMaxConnscCsr|||d�|�|f}||jkr4t��|j|j|<n,t||||||�|j|<t��|j|j|<|��|j|S)Nr
)�joinr�r~r�rJr��check_cache)r�r r1rzrCr�rJr�rLrLrMr�Ks

�
zCacheFTPHandler.connect_ftpcCs�t��}|j|krPt|j���D].\}}||kr |j|��|j|=|j|=q tt|j����|_t	|j�|j
kr�t|j���D]&\}}||jkr�|j|=|j|=q�q�tt|j����|_dSrN)r~r�r�rJrr�r��min�valuesrdr�)r�r�r�rrLrLrMr�Vs


zCacheFTPHandler.check_cachecCs0|j��D]}|��q
|j��|j��dSrN)r�r�r��clearrJ)r��connrLrLrM�clear_cachejs

zCacheFTPHandler.clear_cacheN)	r�r�r�r�r�r�r�r�rrLrLrLrMr,;sc@seZdZdd�ZdS)r-cCs~|j}|�dd�\}}|�dd�\}}t|�}|�d�rNt�|�}|dd�}|sVd}t�d|t|�f�}t	t
�|�||�S)N�:rVr�z;base64i�����text/plain;charset=US-ASCIIz$Content-type: %s
Content-length: %d
)rtrXr�endswithr-�decodebytesr�r�rdr�io�BytesIO)r�r�rHrrIZ	mediatyperirLrLrM�	data_openqs



�zDataHandler.data_openN)r�r�r�r	rLrLrLrMr-psr��nt)r4r3cCst|�SrN)r
��pathnamerLrLrMr4�scCst|�SrN)r	rrLrLrMr3�sc@s�eZdZdZdeZd)dd�Zdd�Zdd�Zd	d
�Z	dd�Z
d*d
d�Zd+dd�Zd,dd�Z
d-dd�Zdd�Zd.dd�Zd/dd�Zdd�Zer�dd�Zd0dd �Zd!d"�Zd#d$�Zd%d&�Zd1d'd(�ZdS)2r8Nr�cKszdd|jji}tj|tdd�|dkr.t�}||_|�d�|_|�d�|_	d|j
fdg|_g|_t
j|_d|_t|_dS)	NzW%(class)s style of invoking requests is deprecated. Use newer urlopen functions/methods�classrS)�
stacklevel�key_file�	cert_filez
User-Agent)ZAcceptz*/*)rLr�r?r@rAr5r&r�rr�versionr��_URLopener__tempfilesr[rp�_URLopener__unlink�	tempcache�ftpcache)r�r&Zx509r�rLrLrMr��s
�zURLopener.__init__cCs|��dSrN)r�r�rLrLrM�__del__�szURLopener.__del__cCs|��dSrN)�cleanupr�rLrLrMr��szURLopener.closec	CsV|jrB|jD](}z|�|�Wqtk
r2YqXq|jdd�=|jrR|j��dSrN)rrrqrr)r�rOrLrLrMr�s
zURLopener.cleanupcGs|j�|�dSrN)r�ra)r�r�rLrLrM�	addheader�szURLopener.addheaderc
Csptt|��}t|dd�}|jrL||jkrL|j|\}}t|d�}t|||�St|�\}}|s`d}||jkr�|j|}t|�\}}	t|	�\}
}|
|f}nd}d|}||_	|�
dd�}t||�r�|dkr�|r�|�|||�S|�
||�Sz0|dk�rt||�|�WSt||�||�WSWnVttfk
�r0�Yn<tk
�rj}
ztd	|
��t��d
��W5d}
~
XYnXdS)Nz%/:=&?~#+!$,;'@()*[]|�rr�rOZopen_�-r�r�zsocket errorr:)rrr	rrGrrr&rr�rr��open_unknown_proxy�open_unknownr�rrrqr�r�r�)r�r�rIrfrirh�urltyperHr�	proxyhostrzr�r_r�rLrLrMrG�s<




zURLopener.opencCst|�\}}tdd|��dS)N�	url errorzunknown url type�rrq)r�r�rIr�rHrLrLrMr
szURLopener.open_unknowncCs t|�\}}tdd||��dS)Nrzinvalid proxy for %sr )r�rr�rIr�rHrLrLrMrszURLopener.open_unknown_proxyc
Cstt|��}|jr&||jkr&|j|St|�\}}|dkr�|rF|dkr�z0|�|�}|��}|��tt|�d�|fWSt	k
r�}	zW5d}	~	XYnX|�
||�}�z<|��}
|r�t
|d�}nrt|�\}}
t|
p�d�\}}
t|
p�d�\}
}t|
p�d�\}
}t
j�|
�d}t�|�\}}|j�|�t
�|d�}z�||
f}|jdk	�rT||j|<d}d}d}d}d|
k�rzt|
d	�}|�r�||||�|�|�}|�s��q�|t|�7}|�|�|d7}|�r�||||��q�W5|��XW5|��X|dk�r||k�rtd
||f|��|S)NrOrVrPrrrRrSrrTrUrW)rrrrr�rZr�r4rrqrGrrr[r\�splitextr^Zmkstemprra�fdopenrbrcrdrer)r�rHrfrgrIr�Zurl1rhr�r�rirjZgarbager\�suffix�fdrkrlrmrcrnrorLrLrM�retrievesn






��zURLopener.retrievecCs$d}d}t|t�r<t|�\}}|r6t|�\}}t|�}|}nt|\}}t|�\}}t|�\}	}
|
}d}|	��dkrvd}n:t|
�\}}
|r�t|�\}}|r�d|	||
f}t|�r�|}|s�tdd��|r�t|�}t	�
|����d�}nd}|�rt|�}t	�
|����d�}nd}||�}
i}|�r*d||d<|�r<d||d<|�rJ||d	<d
|d<|j
D]\}}|||<�qX|dk	�r�d|d
<|
�d|||�n|
jd||d�z|
��}Wn"tjjk
�r�td��YnXd|jk�r�dk�rnnt||jd||j�S|�||j|j|j|j|�SdS)Nr�z	%s://%s%sz
http errorr�r)zBasic %sr�rcrsr�r�r�zContent-Typer�r�r�z$http protocol error: bad status liner�r��http:)r�r�rrr
rrxr,rqr-r.r/r0r�ryr�r�r�Z
BadStatusLinerZstatusrr��
http_errorrhr�)r�Zconnection_factoryrHrIZuser_passwdZproxy_passwdrzr�Zrealhostrr�Z
proxy_authrbZ	http_connrirYr�r�rLrLrM�_open_generic_httpVs~



��zURLopener._open_generic_httpcCs|�tjj||�SrN)r(r�r�r��r�rHrIrLrLrM�	open_http�szURLopener.open_httpc
Csbd|}t||�rPt||�}|dkr6||||||�}	n|||||||�}	|	rP|	S|�|||||�S)Nz
http_error_%d)r�r�r�)
r�rHrh�errcode�errmsgrirIr_r�rkrLrLrMr'�s

zURLopener.http_errorcCs|��t||||d��dSrN)r�r�r�rHrhr+r,rirLrLrMr��szURLopener.http_error_defaultcCstjj||j|jd�S)N)rr)r�r�r�rr)r�rzrLrLrM�_https_connection�s�zURLopener._https_connectioncCs|�|j||�SrN)r(r.r)rLrLrM�
open_https�szURLopener.open_httpscCs^t|t�std��|dd�dkrP|dd�dkrP|dd���dkrPtd��n
|�|�SdS)	NzEfile error: proxy support for file protocol currently not implementedr:rrSr
�z
localhost/r�)r�r�rrxrBr�r�rLrLrM�	open_file�s

4
zURLopener.open_filec
Cs\ddl}ddl}t|�\}}t|�}zt�|�}Wn0tk
rb}zt|j|j	��W5d}~XYnX|j
}	|jj|j
dd�}
|�|�d}|�d|p�d|	|
f�}|s�|}
|dd�dkr�d|}
tt|d	�||
�St|�\}}|�sPt�|�t�ft�k�rP|}
|dd�dk�r d|}
n|dd
�dk�r>td|��tt|d	�||
�Std
��dS)NrTr�z6Content-Type: %s
Content-Length: %d
Last-modified: %s
r�rVr
r�r�r:z./zAlocal file url may start with / or file:. Unknown url of type: %sz#local file error: not on local host)r�r�rr4r[r�rqr�strerrorrfr�r�r�r�r�r�rrGr
r�r�r��thishostrB)r�rHr�r�rzrOZ	localnamer��ermr�r�riZurlfilerCrLrLrMr��s@ ���
zURLopener.open_local_filec
Cs�t|t�std��ddl}t|�\}}|s2td��t|�\}}t|�\}}|r\t|�\}}nd}t|�}t|ppd�}t|p|d�}t	�
|�}|s�ddl}|j}nt
|�}t|�\}}	t|�}|�d�}
|
dd�|
d}
}|
r�|
ds�|
dd�}
|
�r
|
d�s
d|
d<|||d�|
�f}t|j�tk�rbt|j�D]*}
|
|k�r6|j|
}|j|
=|���q6z�||jk�r�t|||||
�|j|<|�s�d}nd	}|	D]2}t|�\}}|��d
k�r�|dk�r�|��}�q�|j|�||�\}}|�d|�d}d}|�r|d
|7}|dk	�r,|dk�r,|d|7}t�|�}t||d|�WSt�k
�r�}ztd|�� t!�"�d��W5d}~XYnXdS)NzCftp error: proxy support for ftp protocol currently not implementedrr�rrr
rSrVr�rhr�r�zftp:zContent-Type: %s
zContent-Length: %d
zftp error %rr:)#r�r�rr�rr
rrr
r�r�r�r�rbrrXr�rdr�MAXFTPCACHEr�r�r�rrxr�r�r�r�r�r�	ftperrorsr�r�r�)r�rHr�rzr\rCr r1r�r�r�rOr�r�rr�r�r�rhr�r�rir�rLrLrM�open_ftp�st




��
zURLopener.open_ftpc	
Cs<t|t�std��z|�dd�\}}Wntk
rDtdd��YnX|sNd}|�d�}|dkr�d	||d�kr�||dd�}|d|�}nd
}g}|�dt�	dt�
t�����|�d
|�|dkr�t�|�
d���d�}nt|�}|�dt|��|�d
�|�|�d�|�}t�|�}t�|�}t|||�S)NzEdata error: proxy support for data protocol currently not implementedr�rVz
data errorzbad data URLr�;rr�rrzDate: %sz%a, %d %b %Y %H:%M:%S GMTzContent-type: %sr-r)zlatin-1zContent-Length: %d�
)r�r�rrXrBrq�rfindrar~�strftime�gmtimer-rr/r0r
rdr�r�r�r�StringIOr)	r�rHrIr�Zsemirr�ri�frLrLrM�	open_data8s8

�




zURLopener.open_data)N)N)N)N)NNN)N)N)N)N)r�r�r�rr�rr�rr�rrrGrrr%r(r*r'r�rCr.r/r1r�r7r?rLrLrLrMr8�s,

$


A\


	 :c@s�eZdZdd�Zdd�Zd"dd�Zdd	�Zd#d
d�Zd$dd
�Zd%dd�Z	d&dd�Z
d'dd�Zd(dd�Zd)dd�Z
d*dd�Zd+dd�Zd,dd�Zd d!�ZdS)-r9cOs(tj|f|�|�i|_d|_d|_dS)Nrr�)r8r��
auth_cache�tries�maxtriesrIrLrLrMr�eszFancyURLopener.__init__cCst||d||�S)Nr&)rr-rLrLrMr�ksz!FancyURLopener.http_error_defaultNc	Csv|jd7_zZ|jrN|j|jkrNt|d�r4|j}n|j}|||dd|�W�S|�||||||�}|W�Sd|_XdS)NrVr�http_error_500r�z)Internal Server Error: Redirect Recursion)rArBr�rCr��redirect_internal)	r�rHrhr+r,rirIr�rkrLrLrMros 
��zFancyURLopener.http_error_302c	Csxd|kr|d}nd|kr$|d}ndS|��t|jd||�}t|�}|jdkrnt|||d|||��|�|�S)Nrrrrz( Redirection to url '%s' is not allowed.)r�rr�rrrrG)	r�rHrhr+r,rirIrrrLrLrMrD�s"


��z FancyURLopener.redirect_internalcCs|�||||||�SrN�r�r�rHrhr+r,rirIrLrLrMr�szFancyURLopener.http_error_301cCs|�||||||�SrNrErFrLrLrMr�szFancyURLopener.http_error_303cCs2|dkr|�||||||�S|�|||||�SdSrN)rr�rFrLrLrMr�szFancyURLopener.http_error_307Fc
Cs�d|krt�||||||�|d}t�d|�}	|	sHt�||||||�|	��\}
}|
��dkrtt�||||||�|s�t�||||||�d|jd}|dkr�t||�||�St||�|||�SdS)Nrj�![ 	]*([^ 	]+)[ 	]+realm="([^"]*)"r[Zretry_�_basic_auth�r8r�rf�matchrVrxr�r��
r�rHrhr+r,rirIr�ZstuffrJrr9r_rLrLrMrk�s:
�
�
��zFancyURLopener.http_error_401c
Cs�d|krt�||||||�|d}t�d|�}	|	sHt�||||||�|	��\}
}|
��dkrtt�||||||�|s�t�||||||�d|jd}|dkr�t||�||�St||�|||�SdS)NrmrGr[Zretry_proxy_rHrIrKrLrLrMrn�s:
�
�
��zFancyURLopener.http_error_407cCs�t|�\}}d||}|jd}t|�\}}	t|	�\}	}
|	�d�d}|	|d�}	|�|	||�\}}
|sr|
srdSdt|dd�t|
dd�|	f}	d|	|
|jd<|dkr�|�|�S|�||�SdS)N�http://r�rrV�%s:%s@%srrr�rr&rr��get_user_passwdr	rG�r�rHr9rIrzr�rrrrZ
proxyselectorr�r r1rLrLrM�retry_proxy_http_basic_auth�s$

�
z*FancyURLopener.retry_proxy_http_basic_authcCs�t|�\}}d||}|jd}t|�\}}	t|	�\}	}
|	�d�d}|	|d�}	|�|	||�\}}
|sr|
srdSdt|dd�t|
dd�|	f}	d|	|
|jd<|dkr�|�|�S|�||�SdS)N�https://r�rrVrMrrrrNrPrLrLrM�retry_proxy_https_basic_auth�s$

�
z+FancyURLopener.retry_proxy_https_basic_authc
Cs�t|�\}}|�d�d}||d�}|�|||�\}}|sD|sDdSdt|dd�t|dd�|f}d||}	|dkr�|�|	�S|�|	|�SdS)NrrVrMrrrrL�rr�rOr	rG�
r�rHr9rIrzr�r�r r1rrLrLrMr\	s
�
z$FancyURLopener.retry_http_basic_authc
Cs�t|�\}}|�d�d}||d�}|�|||�\}}|sD|sDdSdt|dd�t|dd�|f}d||}	|dkr�|�|	�S|�|	|�SdS)NrrVrMrrrrRrTrUrLrLrM�retry_https_basic_auth	s
�
z%FancyURLopener.retry_https_basic_authrcCs`|d|��}||jkr2|r(|j|=n
|j|S|�||�\}}|sJ|rX||f|j|<||fS)Nr)rxr@�prompt_user_passwd)r�rzr9rr�r r1rLrLrMrO	s


zFancyURLopener.get_user_passwdcCsXddl}z.td||f�}|�d|||f�}||fWStk
rRt�YdSXdS)NrzEnter username for %s at %s: z#Enter password for %s in %s at %s: r<)�getpass�input�KeyboardInterrupt�print)r�rzr9rXr r1rLrLrMrW)	s�
z!FancyURLopener.prompt_user_passwd)N)N)N)N)NF)NF)N)N)N)N)r)r�r�r�r�r�rrDrrrrkrnrQrSr\rVrOrWrLrLrLrMr9bs&



�
�





cCstdkrt�d�atS)Nr�)�
_localhostr�r�rLrLrLrMr�9	s
r�cCsPtdkrLztt�t���d�aWn(tjk
rJtt�d�d�aYnXtS)Nr:r�)�	_thishostr8r�r�r�r�rLrLrLrMr3A	sr3cCstdkrddl}|jatSro)�
_ftperrorsr�r�)r�rLrLrMr6L	sr6cCstdkrt�d�atSr�)�
_noheadersr�r�rLrLrLrM�	noheadersU	s
r`c@sFeZdZddd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Zdd�Z	dS)r�NTcCsX||_||_||_||_||_||_d|_||_z|��Wn|�	��YnXdSro)
r r1rzrCr�rJ�refcount�	keepalive�initr�)r�r r1rzrCr�rJr�rLrLrMr�b	szftpwrapper.__init__cCs\ddl}d|_|��|_|j�|j|j|j�|j�|j	|j
�d�|j�}|j�
|�dS)Nrr
)r��busyZFTPr	ZconnectrzrCrJZloginr r1r�r��cwd)r�r�Z_targetrLrLrMrcr	s
zftpwrapper.initc
Cs�ddl}|��|dkr"d}d}nd|}d}z|j�|�Wn*|jk
rh|��|j�|�YnXd}|r�|s�zd|}|j�|�\}}WnR|jk
r�}z2t|�dd�dkr�t	d	|��
t��d
��W5d}~XYnX|�s�|j�d�|�rl|j�
�}	zJz|j�|�Wn4|jk
�rN}zt	d	|�|�W5d}~XYnXW5|j�|	�Xd|}nd}|j�|�\}}d|_t|�d
�|j�}
|jd7_|��|
|fS)Nr)r�r�zTYPE ArVzTYPE zRETR rSZ550r�r:zLIST ZLISTr�)r��endtransferr	Zvoidcmdr�rcZntransfercmdZ
error_permr�rr�r�r��pwdrerdrZmakefile�
file_closerar�)r�rOr�r��cmd�isdirrr�r�rgZftpobjrLrLrMr�{	sP
�
$
zftpwrapper.retrfilecCs
d|_dSro)rdr�rLrLrMrf�	szftpwrapper.endtransfercCsd|_|jdkr|��dS)NFr)rbra�
real_closer�rLrLrMr��	s
zftpwrapper.closecCs2|��|jd8_|jdkr.|js.|��dS)NrVr)rfrarbrkr�rLrLrMrh�	szftpwrapper.file_closecCs2|��z|j��Wnt�k
r,YnXdSrN)rfr	r�r6r�rLrLrMrk�	s
zftpwrapper.real_close)NT)
r�r�r�r�rcr�rfr�rhrkrLrLrLrMr�_	s�
	-r�cCs�i}tj��D]4\}}|��}|r|dd�dkr|||dd�<qdtjkrZ|�dd�tj��D]J\}}|dd�dkrd|��}|r�|||dd�<qd|�|dd�d�qd|S)Ni�����_proxyZREQUEST_METHODr�)r[�environrrxr�)r&r_r�rLrLrM�getproxies_environment�	s	
rncCs�|dkrt�}z|d}Wntk
r0YdSX|dkr>dS|��}t|�\}}|�d�D]Z}|��}|r\|�d�}|��}||ks�||kr�dSd|}|�|�s�|�|�r\dSq\dS)NZnoF�*Tr��.)rnr�rxr
rXrd�lstripr)rzr&Zno_proxy�hostonlyrCr_rLrLrM�proxy_bypass_environment�	s*
rsc	Cs0ddlm}t|�\}}dd�}d|kr4|dr4dSd}|�dd	�D]�}|sNqDt�d
|�}|dk	�r|dkr�zt�|�}||�}Wntk
r�YqDYnX||�d��}	|�d�}
|
dkr�d
|�d��	d�d}
nt
|
dd��}
|
dksD|
dkr�qDd|
}
||
?|	|
?k�r*dSqD|||�rDdSqDdS)Nr)�fnmatchcSsh|�d�}ttt|��}t|�dkr<|ddddgdd�}|dd>|dd>B|dd>B|d	BS)
Nrpr�r�rVr}r:r|rS)rXr�r�rbrd)ZipAddrrBrLrLrM�ip2num
s

z,_proxy_bypass_macosx_sysconf.<locals>.ip2numrpZexclude_simpleT�
exceptionsrLz(\d+(?:\.\d+)*)(/\d+)?rVr:r|� F)rtr
r�rfrJr�r�rq�group�countrb)rz�proxy_settingsrtrrrCrvZhostIPr�rrD�maskrLrLrM�_proxy_bypass_macosx_sysconf
s>




r}�darwin)�_get_proxy_settings�_get_proxiescCst�}t||�SrN)rr})rzr{rLrLrM�proxy_bypass_macosx_sysconfF
sr�cCst�SrN)r�rLrLrLrM�getproxies_macosx_sysconfJ
sr�cCs t�}|rt||�St|�SdSrN)rnrsr��rzr&rLrLrMr,T
s
r,cCst�p
t�SrN)rnr�rLrLrLrMr5a
sc
Csi}zddl}Wntk
r(|YSXz�|�|jd�}|�|d�d}|r�t|�|d�d�}d|kr�|�d�D]4}|�dd�\}}t�d|�s�d	||f}|||<qtn>|dd
�dkr�||d<n$d
||d<d||d<d||d<|�	�Wnt
ttfk
�rYnX|S)Nr�;Software\Microsoft\Windows\CurrentVersion\Internet Settings�ProxyEnableZProxyServerr�r8rVz
(?:[^/:]+)://z%s://%srtr&r�z	http://%sz
https://%sr�zftp://%sr	)
�winreg�ImportError�OpenKey�HKEY_CURRENT_USER�QueryValueExr�rXrfrJZCloserqrBr�)r&r��internetSettings�proxyEnableZproxyServer�pr�ZaddressrLrLrM�getproxies_registryf
sF
�����
r�cCst�p
t�SrN)rnr�rLrLrLrMr5�
scCs|zddl}Wntk
r"YdSXz6|�|jd�}|�|d�d}t|�|d�d�}Wntk
rpYdSX|rz|s~dSt|�\}}|g}z t�	|�}||kr�|�
|�Wntk
r�YnXz t�|�}||kr�|�
|�Wntk
�r�YnX|�d�}|D]j}	|	dk�r*d|k�r*dS|	�
dd	�}	|	�
d
d�}	|	�
dd�}	|D] }
t�|	|
tj��rRdS�qR�qdS)
Nrr�r�Z
ProxyOverrider8z<local>rprVz\.roz.*�?)r�r�r�r�r�r�rqr
r�r�raZgetfqdnrXrrfrJrh)rzr�r�r�Z
proxyOverrideZrawHostrCZaddrZfqdnrEr�rLrLrM�proxy_bypass_registry�
s`�����





r�cCs t�}|rt||�St|�SdSrN)rnrsr�r�rLrLrMr,�
s
)NNN)N)}r-r�r�r�Zhttp.clientr�rr[�	posixpathrfr�rr�r~r^rXr?Zurllib.errorrrrZurllib.parserrrrr	r
rrr
rrrrrrrrrZurllib.responserrrDr�rC�__all__�version_infor�rFr�r0r1r`r6r7rg�ASCIIrvr{rrr2rr/rrr"rr r!r"r#r$r%�urandomr�r&r'r(r�r)r�r�rErarr.rvrxr*r�r+r,r-r5r_Z
nturl2pathr4r3rr8r9r\r�r]r3r^r6r_r`r�rnrsr}�platformZ_scproxyrr�r�r�r,r5r�r�rLrLrLrM�<module>TsP
��U
?m$q!+@
ov

+3:5!@W

_
%A

-	2


Hacked By AnonymousFox1.0, Coded By AnonymousFox