Plan 9 from Bell Labs’s /usr/web/sources/contrib/jas/root/sys/lib/python2.7/site-packages/mercurial/url.pyc

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


��Qc@s�ddlZddlZddlZddlZddlZddlZddlmZddlZddl	Z	ddl
Z
ddlZdej
fd��YZdejfd��YZd�Ze	jed�Zery
ejZWqek
re�Zedd	�ZqXnd
ejfd��YZd�Zd
�Zdejfd��YZer�dejfd��YZ dej!ej"fd��YZ#ndej$fd��YZ%dej&fd��YZ'gZ(dd�Z)dd�Z*dS(i�N(t_tpasswordmgrcBs,eZd�Zd�Zd�Zd�ZRS(cCstjj|�||_dS(N(turllib2tHTTPPasswordMgrWithDefaultRealmt__init__tui(tselfR((s1/sys/lib/python2.7/site-packages/mercurial/url.pyRsc	Cs�tjj|||�}|\}}|rJ|rJ|j||�||fS|sX|r�tj|j||�}|r�|\}}|jd�|jd�}}|jjd|�q�n|s�|r||jj	�s�jtd���n|jj
td��|jj
td�|�|rC|jj
td�|�n|jjtd�d	d�}|s||jj�}q|n|j||||�|j||�||fS(
Ntusernametpasswords#using auth.%s.* for authentication
shttp authorization requiredshttp authorization required
s
realm: %s
s	user: %s
suser:tdefault(RRtfind_user_passwordt_writedebugthttpconnectionmodtreadauthforuriRtgettdebugtinteractivetutiltAbortRtwritetprompttNonetgetpasstadd_password(	Rtrealmtauthuritauthinfotusertpasswdtrestgrouptauth((s1/sys/lib/python2.7/site-packages/mercurial/url.pyR
s2	
cCs@td�}|jj|||r1dt|�p4df�dS(Ns http auth: user %s, password %s
t*snot set(RRRtlen(RRRtmsg((s1/sys/lib/python2.7/site-packages/mercurial/url.pyR4scCstjj|d|�S(N(RRR
R(RR((s1/sys/lib/python2.7/site-packages/mercurial/url.pytfind_stored_password8s	(t__name__t
__module__RR
RR#(((s1/sys/lib/python2.7/site-packages/mercurial/url.pyRs		 	tproxyhandlercBseZd�Zd�ZRS(cCs|jdd�ptjd�}|r�|jd�pB|jd�sVd|d}ntj|�}|js�|jdd�|_|jdd�|_nd	d
g}|jg|j	dd�D]}|j
�^q��|jgtjdd
�jd�D]$}|j�r�j�j
�^q�|j
dd�rDg|_n	||_t|�}i|d6|d6}|jd|j|jf�ni}|jdd�r�dddgD]:}y |tjkr�tj|=nWq�tk
r�q�Xq�Wntjj||�||_dS(Nt
http_proxythostshttp:shttps:shttp://t/RRt	localhosts	127.0.0.1tnotno_proxytt,talwaysthttpthttpssproxying through http://%s:%s
t
HTTP_PROXY(tconfigtostgetenvt
startswithRturlRRtextendt
configlisttlowertsplittstript
configbooltno_listtstrRR(tporttenvirontOSErrorRtProxyHandlerRR(RRtproxyurltproxyR>tptproxiestenv((s1/sys/lib/python2.7/site-packages/mercurial/url.pyR=s@!		)	%		
css|j�jd�d}||jkr,dS|j�d�f�fd��Y}||_tjj||||�S(Nt:it_requestcseZ�fd�ZRS(cs4|j�dkr!|j�}n�j|||�S(Nsproxy-authorization(R:R<t
add_header(Rtkeytval(t	baseclass(s1/sys/lib/python2.7/site-packages/mercurial/url.pyRKvs(R$R%RK((RN(s1/sys/lib/python2.7/site-packages/mercurial/url.pyRJus(tget_hostR;R>Rt	__class__RRCt
proxy_open(RtreqREttype_R(RJ((RNs1/sys/lib/python2.7/site-packages/mercurial/url.pyRQms		(R$R%RRQ(((s1/sys/lib/python2.7/site-packages/mercurial/url.pyR&<s	0cs�fd�}|S(NcsZt|tj�rI|jd�x4tj|�D]}�||�q/Wn
�||�dS(Ni(t
isinstanceRthttpsendfiletseekRt
filechunkiter(Rtdatatchunk(torgsend(s1/sys/lib/python2.7/site-packages/mercurial/url.pyt	_sendfiles

((RZR[((RZs1/sys/lib/python2.7/site-packages/mercurial/url.pyt
_gen_sendfile~s	tHTTPSHandlerc
Cs�d}|\}}x�tj||dtj�D]�}|\}}}	}
}d}y\tj|||	�}|tk	r�|j|�n|r�|j|�n|j|�|SWq.tjk
r�}|dk	r�|j	�q�q.Xq.Wtj|��dS(Ns!getaddrinfo returns an empty listi(
tsockettgetaddrinfotSOCK_STREAMRt_GLOBAL_DEFAULT_TIMEOUTt
settimeouttbindtconnectterrortclose(
taddressttimeouttsource_addressR"R(R@Rtaftsocktypetprotot	canonnametsatsock((s1/sys/lib/python2.7/site-packages/mercurial/url.pyt_create_connection�s""
thttpconnectioncBs,eZeejj�Zd�Zd�ZRS(cCs�trs|jrstjtjtj�|_|jj|j|jf�t	|�r�t
j|jdd�|_q�nt
jj|�dS(N(t	has_httpstrealhostportR^tAF_INETR`RoRdR(R@t_generic_proxytunneltsslutiltssl_wrap_socketRt	keepalivetHTTPConnection(R((s1/sys/lib/python2.7/site-packages/mercurial/url.pyRd�s!cCsKt|dd�}|r;|jr.|j�nd|_|Stjj|�S(Ntproxyres(tgetattrRt
will_closeRfRzRxRytgetresponse(RRz((s1/sys/lib/python2.7/site-packages/mercurial/url.pyR}�s	
	(R$R%R\RxRytsendRdR}(((s1/sys/lib/python2.7/site-packages/mercurial/url.pyRq�s	
cCs�t|dd�}|r>|d d	kr5d|}nt}n|j�}t}|sh||j�kr�tj|�}|s�|jdkr�dj	|j
|jp�dg�|_|j
j�|_
|j
j|jj�dSnd|_d|_
dS(
Nt_tunnel_hostishttp://shttps:/shttps://R1RIt443(shttp://shttps:/(R{RtTruetget_selectortFalsetget_full_urlRR7tschemetjoinR(R@Rstheaderstcopytupdatetparentt
addheaders(thandlerthRRttunnel_hostt
new_tunneltu((s1/sys/lib/python2.7/site-packages/mercurial/url.pyt_generic_start_transaction�s 
	$	c
Cs�tg|jD].}|j�jd�r
||j|f^q
�}|j|j|j�|jd|j�x%|j	�D]}|jd|�q{W|jd�|j
|jd|jd|j
�}x^tr'|j�\}}}|tjkr�x)tr#|jj�j�}|s��Wq�W||_|j�|_|jdkrx)trz|jj�}	|	dkrRPqRqRWtS|dkr�d	|_nB|jd
�r�d|_n'|dkr�d
|_ntj|��|jd
krd|_d|_d|_tjtj��|_ t!Stj|j�|_ d|j _|j j"d�}
|
r|
j�dkrd|_d|_#n	d|_|j$�|_|j j"d�}|r|jryt%|�|_Wnt&k
r�d|_qX|jdkrd|_qn	d|_|tj'ksY|tj(ksYd|koEdknsY|j
dkred|_n|jr�|jr�|jdkr�d|_n||_)t!S(Nsproxy-sCONNECT %s HTTP/1.0
s%s: %s
s
tstricttmethodi�sHTTP/1.0i
sHTTP/1.isHTTP/0.9i	iistransfer-encodingtchunkedscontent-lengthidtHEAD(*tdictR�R:R6t
_set_hostportR(R@R~Rst	iteritemstresponse_classRoR�t_methodR�t_read_statusthttplibtCONTINUEtfptreadlineR<tstatustreasontversiontUnknownProtocolRtlengthR�R|tHTTPMessaget	cStringIOtStringIOR"R�t	getheadert
chunk_leftt_check_closetintt
ValueErrort
NO_CONTENTtNOT_MODIFIEDRz(RtxtproxyheaderstheaderRR�R�R�tskiptlinettrencR�((s1/sys/lib/python2.7/site-packages/mercurial/url.pyRu�s�1
										

	

	thttphandlercBseZd�Zd�ZRS(cCs|jt|�S(N(tdo_openRq(RRR((s1/sys/lib/python2.7/site-packages/mercurial/url.pyt	http_open:scCs&t|||�tjj|||�S(N(R�RxtHTTPHandlert_start_transaction(RR�RR((s1/sys/lib/python2.7/site-packages/mercurial/url.pyR�=s(R$R%R�R�(((s1/sys/lib/python2.7/site-packages/mercurial/url.pyR�9s	thttpsconnectioncBs;eZejZeej�Zeje	j
�Zd�ZRS(cCs�t|j|jf�|_|j}|jrSt|�|jjdd�d}ntj|j|j	|j
tj|j|��|_tj
|j|�|j�dS(NRIii(RpR(R@RoRsRutrsplitRvRwtkey_filet	cert_filet	sslkwargsRt	validator(RR(((s1/sys/lib/python2.7/site-packages/mercurial/url.pyRdHs		
(
R$R%RxtHTTPResponseR�R\tsafesendR~twrapgetresponseR�tHTTPSConnectionR}Rd(((s1/sys/lib/python2.7/site-packages/mercurial/url.pyR�Bs	thttpshandlercBs/eZd�Zd�Zd�Zdd�ZRS(cCs?tjj|�tjj|�||_t|j�|_dS(N(RxtKeepAliveHandlerRRR]RRtpwmgr(RR((s1/sys/lib/python2.7/site-packages/mercurial/url.pyRUs	cCs&t|||�tjj|||�S(N(R�RxR�R�(RR�RR((s1/sys/lib/python2.7/site-packages/mercurial/url.pyR�[scCs�|j�}|jj|�\}}tj|j||�}|rn|\}}||_|jjd|�n	d|_|j	|j
|�S(Ns#using auth.%s.* for authentication
(R�R�R#RR
RRRRR�t_makeconnection(RRRR7RRRRR((s1/sys/lib/python2.7/site-packages/mercurial/url.pyt
https_open_s		c	Os�d}d}t|�dkr+|d}nt|�dkrJ|d}n|d}|jr�d|jkr�d|jkr�|jd}|jd}nt||||||�}|j|_|S(NiiiRLtcert(RR!RR�R(RR(R@targstkwargstkeyfiletcertfiletconn((s1/sys/lib/python2.7/site-packages/mercurial/url.pyR�ms


'
	N(R$R%RR�R�RR�(((s1/sys/lib/python2.7/site-packages/mercurial/url.pyR�Ts			thttpdigestauthhandlercBs#eZd�Zd�Zd�ZRS(cOs#tjj|||�d|_dS(N(RtHTTPDigestAuthHandlerRRtretried_req(RR�R�((s1/sys/lib/python2.7/site-packages/mercurial/url.pyR�scCsdS(N((R((s1/sys/lib/python2.7/site-packages/mercurial/url.pytreset_retry_count�scCs�||jk	r$||_d|_ny tjj|||||�SWn6tk
r|}|jd}|jd�rvdS�nXdS(Nis'AbstractDigestAuthHandler doesn't know (R�tretriedRR�thttp_error_auth_reqedR�R�R6(Rtauth_headerR(RRR�tinsttarg((s1/sys/lib/python2.7/site-packages/mercurial/url.pyR��s		
(R$R%RR�R�(((s1/sys/lib/python2.7/site-packages/mercurial/url.pyR��s		thttpbasicauthhandlercBs#eZd�Zd�Zd�ZRS(cOs#tjj|||�d|_dS(N(RtHTTPBasicAuthHandlerRRR�(RR�R�((s1/sys/lib/python2.7/site-packages/mercurial/url.pyR�scCsdS(N((R((s1/sys/lib/python2.7/site-packages/mercurial/url.pyR��scCs@||jk	r$||_d|_ntjj|||||�S(Ni(R�R�RR�R�(RR�R(RRR�((s1/sys/lib/python2.7/site-packages/mercurial/url.pyR��s
		(R$R%RR�R�(((s1/sys/lib/python2.7/site-packages/mercurial/url.pyR��s		cCsM|jddt�r3tj|t|��g}n(t�g}tr[|jt|��n|jt	|��t|�}|dk	r�|j|�|dd!\}}|jd||r�dt
|�p�df�n|jt|�t|�f�|jgtD]}|||�^q�tj|�}d
g|_|jjd�|S(se
    construct an opener suitable for urllib2
    authinfo will be added to the password manager
    Rtusehttp2iis http auth: user %s, password %s
R snot sets
User-agentsmercurial/proto-1.0tAcceptsapplication/mercurial-0.1N(s
User-agentsmercurial/proto-1.0(R�sapplication/mercurial-0.1(R=R�Rthttp2handlerRR�RrtappendR�R&RRRR!R8R�R�thandlerfuncsRtbuild_openerR�(RRthandlerstpassmgrRRR�topener((s1/sys/lib/python2.7/site-packages/mercurial/url.pyR��s&
	')cCs�tj|�}|jr?|jj�|_|j�\}}n4tjtjj|��}dt	j
|�}d}t||�j
||�S(Nsfile://(RR7R�R:RtnormpathR4tpathtabspathturllibtpathname2urlRR�topen(Rturl_RXR�RR�((s1/sys/lib/python2.7/site-packages/mercurial/url.pyR��s	(+R�RR�R4R^R�ti18nRRxRRvRqRRRRCR&R\tsafehasattrRrtcreate_connectionRptAttributeErrortobjectRaRRyR�RuR�R�R�R�R�R]R�R�R�R�R�R�R�R�(((s1/sys/lib/python2.7/site-packages/mercurial/url.pyt<module>
s4H$-B	

			b".

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.