Plan 9 from Bell Labs’s /usr/web/sources/contrib/bichued/root/sys/lib/python/mercurial/url.pyc

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


�
�c@s8ddkZddkZddkZddkZddkZddkZddkZddkZddkl	Z	ddk
Z
ddkZd�Zd�Z
d�Zddd�ZdZdadad�Zd	eifd
��YZdeifd��YZd
efd��YZd�Zeed�Zeo<yddkZeiZ Wqpe!j
od�Z qpXnde
i"fd��YZ#de
i$fd��YZ%eo<dei&fd��YZ'de
i(ei)fd��YZ*ndei+fd��YZ,d�Z-gZ.dd�Z/ei0d�Z1dd�Z2dS( i�N(t_cCsUti|�\}}}}}}tidd|�}ti||||||f�S(s$hide user credential in a url strings([^:]*):([^@]*)@(.*)s	\1:***@\3(turlparsetretsubt
urlunparse(turltschemetnetloctpathtparamstquerytfragment((s /sys/lib/python/mercurial/url.pythidepasswords!cCsWti|�\}}}}}}||id�d}ti||||||f�S(s7remove all authentication information from a url stringt@i(RtfindR(RRRRR	R
R((s /sys/lib/python/mercurial/url.pyt
removeauths!c
Cs�|id�}|djod\}}nz|| ||d}}|id�}|djoti|�d}}n+ti|| �}ti||d�}|id�}|djo|d}}n|| ||d}}||||fS(s/split [user[:passwd]@]host[:port] into 4-tuple.R
i�it:N(NN(RtNoneturllibtunquote(Rtatusertpasswdtuserpasstcthosttport((s /sys/lib/python/mercurial/url.pytnetlocsplits


cCst|o|d|}n|}|oJ|o$ti|�dti|�}nti|�}|d|Sn|S(s?turn host, port, user, passwd into [user[:passwd]@]host[:port].RR
(Rtquote(RRRRthostportR((s /sys/lib/python/mercurial/url.pyt
netlocunsplit/s$sBabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_.-/cCs�tdjott�atd�ant|�}x�tt|��D]�}||}|djoE|dt|�jo.||dtjo||dtjoqH|tjodt|�||<qHqHWdi	|�S(s�quote the path part of a URL

    This is similar to urllib.quote, but it also tries to avoid
    quoting things twice (inspired by wget):

    >>> quotepath('abc def')
    'abc%20def'
    >>> quotepath('abc%20def')
    'abc%20def'
    >>> quotepath('abc%20 def')
    'abc%20%20def'
    >>> quotepath('abc def%20')
    'abc%20def%20'
    >>> quotepath('abc def%2')
    'abc%20def%252'
    >>> quotepath('abc def%')
    'abc%20def%25'
    tabcdefABCDEF0123456789t%iis%%%02XtN(
t_safesetRtsett_safet_hextlisttxrangetlentordtjoin(RtltiR((s /sys/lib/python/mercurial/url.pyt	quotepathBs

N
tpasswordmgrcBs,eZd�Zd�Zd�Zd�ZRS(cCstii|�||_dS(N(turllib2tHTTPPasswordMgrWithDefaultRealmt__init__tui(tselfR2((s /sys/lib/python/mercurial/url.pyR1cscCs�tii|||�}|\}}|o%|o|i||�||fSn|p=|i|�}|o#|id�|id�}}q�n|p|o�|ii�pti	t
d���n|iit
d��|iit
d�|�|o|iit
d�|�n|ii
t
d�dd�}|p|ii�}q^n|i||||�|i||�||fS(	Ntusernametpasswordshttp authorization requiredshttp authorization required
s
realm: %s
s	user: %s
suser:tdefault(R/R0tfind_user_passwordt_writedebugt
readauthtokentgetR2tinteractivetutiltAbortRtwritetstatustpromptRtgetpasstadd_password(R3trealmtauthuritauthinfoRRtauth((s /sys/lib/python/mercurial/url.pyR7gs.	'cCsBtd�}|ii|||odt|�pdf�dS(Ns http auth: user %s, password %s
t*snot set(RR2tdebugR((R3RRtmsg((s /sys/lib/python/mercurial/url.pyR8�scCsot�}xW|iid�D]C\}}|idd�\}}|i|t��}|||<qW|idd�\}}	d}
d}x�i�D]�}|id�}
|
pq�n|
idd�}t|�djo|dg|d}}
n|id�pdi�}|
d	jp|	i	|
�o6t|
�|
jo#||jot|
�}
|}q�q�W|S(
NRFt.is://itprefixtschemesthttpsRG(
tdictR2tconfigitemstsplitt
setdefaultRt
itervaluesR:R(t
startswith(R3turitconfigtkeytvaltgrouptsettingtgdictRthostpathtbestlentbestauthRFRKtpRL((s /sys/lib/python/mercurial/url.pyR9�s,	
 (t__name__t
__module__R1R7R8R9(((s /sys/lib/python/mercurial/url.pyR.bs			tproxyhandlercBseZd�Zd�ZRS(cCsz|idd�p
tid�}|o�|id�p
|id�pd|d}nti|�}|\}}}}}t|�}	|	\}
}}}
|p(|idd�}|idd�}
nd	d
g}|ig}|idd�D]}||i	�q��|ig}tidd
�i
d�D]*}|i�o||i�i	�q8q8~�|idd�o
g|_
n
||_
ti|t|
|||
pd
�|||f�}h|d<|d<}|itd�|
|f�nh}xOdddgD]>}y"|tijoti|=nWqtj
oqXqWtii||�||_dS(Nt
http_proxyRshttp:shttps:shttp://t/RRt	localhosts	127.0.0.1tnotno_proxyR!t,talwaysthttpRMsproxying through http://%s:%s
t
HTTP_PROXY(RUtostgetenvRSRturlsplitRtextendt
configlisttlowerRPtstript
configbooltno_listt
urlunsplitRRHRtenvirontOSErrorR/tProxyHandlerR1R2(R3R2tproxyurltsnpqftproxyschemetproxynetloct	proxypatht
proxyqueryt	proxyfragthpupt	proxyhostt	proxyportt	proxyusertproxypasswdRst_[1]R^t_[2]tproxiestenv((s /sys/lib/python/mercurial/url.pyR1�sL"
-
.
		csx|i�id�d}||ijodSn|i�d�f�fd��Y}||_tii||||�S(NRit_requestcseZ�fd�ZRS(cs6|i�djo|i�}n�i|||�S(Nsproxy-authorization(RpRqt
add_header(R3RVRW(t	baseclass(s /sys/lib/python/mercurial/url.pyR��s(R_R`R�((R�(s /sys/lib/python/mercurial/url.pyR��s(tget_hostRPRsRt	__class__R/Rwt
proxy_open(R3treqtproxyttype_RR�((R�s /sys/lib/python/mercurial/url.pyR��s		(R_R`R1R�(((s /sys/lib/python/mercurial/url.pyRa�s	5thttpsendfilecBseZd�ZRS(cCsti|i��iS(N(Rktfstattfilenotst_size(R3((s /sys/lib/python/mercurial/url.pyt__len__�s(R_R`R�(((s /sys/lib/python/mercurial/url.pyR��scs�fd�}|S(Ncs_t|t�o;|id�x;ti|�D]}�i||�q-Wn�i||�dS(Ni(t
isinstanceR�tseekR<t
filechunkitertsend(R3tdatatchunk(t
connection(s /sys/lib/python/mercurial/url.pyt	_sendfile�s
((R�R�((R�s /sys/lib/python/mercurial/url.pyt
_gen_sendfile�s	tHTTPSHandlercCs%ti|||�}ti||�S(N(tsockettsslthttplibt
FakeSocket(tsocktkey_filet	cert_fileR�((s /sys/lib/python/mercurial/url.pyt_ssl_wrap_socketsthttpconnectioncBs2eZeei�Zd�Zd�Zd�ZRS(c
Cs�tg}|iD]4}|i�id�o|||i|fqq~�}|i|i|i�|id|i|i	f�x%|i
�D]}|id|�q�W|id�|i|id|i
d|i�}xfto^|i�\}}}|tijoPnx-to%|ii�i�}	|	pPqqWq�W||_|i�|_|idjo8x-to%|ii�}
|
djoPqqqqWtSn|djo
d	|_nG|id
�o
d|_n*|djo
d
|_nti|��|id
jo;d|_d|_d|_titi ��|_!t"Snti|i�|_!d|i!_|i!i#d�}|o)|i�djod|_d|_$n
d|_|i%�|_|i!i#d�}|o^|ioSyt&|�|_Wnt'j
od|_qLX|idjo
d|_qLn
d|_|ti(jp>|ti)jp.d|jo
djnp|idjo
d|_n|io(|io|idjo
d|_n||_*t"S(Nsproxy-sCONNECT %s:%d HTTP/1.0
s%s: %s
s
tstricttmethodi�sHTTP/1.0i
sHTTP/1.isHTTP/0.9i	iistransfer-encodingtchunkedscontent-lengthidtHEAD(+RNtheadersRpRSt
_set_hostportRRR�trealhosttrealportt	iteritemstresponse_classR�R�t_methodtTruet_read_statusR�tCONTINUEtfptreadlineRqR?treasontversiontUnknownProtocolRtlengthR�t
will_closetHTTPMessaget	cStringIOtStringIORItFalset	getheadert
chunk_leftt_check_closetintt
ValueErrort
NO_CONTENTtNOT_MODIFIEDtproxyres(
R3R�txtproxyheaderstheadertresR�R?R�tskiptlinettrencR�((s /sys/lib/python/mercurial/url.pyt_proxytunnel	s�:

	

	







				
		 

	cCs�ton|iodtititi�|_|ii|i|if�|i	�ot
|idd�|_q�nti
i|�dS(N(t	has_httpsR�R�tAF_INETtSOCK_STREAMR�tconnectRRR�R�Rt	keepalivetHTTPConnection(R3((s /sys/lib/python/mercurial/url.pyR�js
 cCsRt|dd�}|o)|io|i�nd|_|Sntii|�S(NR�(tgetattrRR�tcloseR�R�R�tgetresponse(R3R�((s /sys/lib/python/mercurial/url.pyR�ts
	(	R_R`R�R�R�R�R�R�R�(((s /sys/lib/python/mercurial/url.pyR�s	a	
thttphandlercBs#eZd�Zd�Zd�ZRS(cCs|it|�S(N(tdo_openR�(R3R�((s /sys/lib/python/mercurial/url.pyt	http_open~scCs|i�|i�jo�ti|i��}|ddjo�d|djo)|did�\}}t|�}n|d}d}||_||_|ii�|_|ii	|i
i�ti
i|||�Sq�nd|_d|_d|_ti
i|||�S(NiRMRii�(tget_selectortget_full_urlRRPR�R�R�R�tcopytupdatetparentt
addheadersR�tHTTPHandlert_start_transactionR(R3thR�turlpartsR�R�((s /sys/lib/python/mercurial/url.pyR��s"
					cCs|i�dS(N(t	close_all(R3((s /sys/lib/python/mercurial/url.pyt__del__�s(R_R`R�R�R�(((s /sys/lib/python/mercurial/url.pyR�}s		thttpsconnectioncBs eZeiZeei�ZRS((	R_R`R�tHTTPResponseR�R�R�tHTTPSConnectionR�(((s /sys/lib/python/mercurial/url.pyR��s	thttpshandlercBs&eZd�Zd�Zdd�ZRS(cCs?tii|�tii|�||_t|i�|_dS(N(R�tKeepAliveHandlerR1R/R�R2R.tpwmgr(R3R2((s /sys/lib/python/mercurial/url.pyR1�s	cCs.|ii|i��|_|i|i|�S(N(R�R9R�RFR�t_makeconnection(R3R�((s /sys/lib/python/mercurial/url.pyt
https_open�si�cOsd}d}|o|id�}n|o|id�}n|io>d|ijo.d|ijo|id}|id}nd|jo
d|jp
d|joF|idd�\}}t|�}d|jo|dd!}q�t||||||�S(	NiRVtcertRt[s]:ii�(RtpopRFtrsplitR�R�(R3RRtargstkwargstkeyfiletcertfile((s /sys/lib/python/mercurial/url.pyR��s*
'
(R_R`R1R�R�(((s /sys/lib/python/mercurial/url.pyR��s		thttpdigestauthhandlercBseZd�ZRS(c	Csdy tii|||||�SWn=tj
o1}|id}|id�odSn�nXdS(Nis'AbstractDigestAuthHandler doesn't know (R/tHTTPDigestAuthHandlerthttp_error_auth_reqedR�R�RS(R3tauth_headerRR�R�tinsttarg((s /sys/lib/python/mercurial/url.pyR��s	
(R_R`R�(((s /sys/lib/python/mercurial/url.pyR��scCs�ti|�\}}}}}|p
d}n|djot|�}nt|�\}}}}	ti|t||�|||f�}
|oB|}|o|d|7}nd|
|f||	pdf}nd}|
|fS(NRctfileRR!(RRmR-RRtRR(RRRturlpathR
tfragRRRRRRE((s /sys/lib/python/mercurial/url.pytgetauthinfo�s

#c	Cs1t�g}to|it|��n|it|��t|�}|d
j	oY|i|�|dd!\}}|it	d�||odt
|�pdf�n|iti
|�t|�f�|ig}tD]}||||�q��ti|�}dg|_|iid�|S(
se
    construct an opener suitable for urllib2
    authinfo will be added to the password manager
    iis http auth: user %s, password %s
RGsnot sets
User-agentsmercurial/proto-1.0tAcceptsapplication/mercurial-0.1N(s
User-agentsmercurial/proto-1.0(Rsapplication/mercurial-0.1(R�R�tappendR�RaR.RRBRHRR(RnR/tHTTPBasicAuthHandlerR�thandlerfuncstbuild_openerR�(	R2REthandlerstpassmgrRRR�R�topener((s /sys/lib/python/mercurial/url.pyR�s"

*1s^([a-zA-Z0-9+-.]+)://cCs�d}ti|�}|o|id�i�}n|p8titii	|��}dt
i|�}d}nt|�\}}t
||�i||�S(Nisfile://(Rt	scheme_retsearchRXRpR<tnormpathRkRtabspathRtpathname2urlRRtopen(R2RR�RtmRRE((s /sys/lib/python/mercurial/url.pyR
s
(3RR/RR�RkRR�R�ti18nRR�R<RRRRRR$R"R%R-R0R.RwRaRR�R�thasattrR�R�twrap_socketR�tImportErrorR�R�R�R�R�R�R�R�R�R�R�RRRtcompileRR(((s /sys/lib/python/mercurial/url.pys<module>
s@`				 AG	
x#&	

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.