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

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


��c@s�ddlZddlZddlZdZdZdZdZdZdZdZ	d	Z
d
�Zd�ZegZ
defd
��YZdefd��YZd�Zdd�Zd�Zd�Zd�Zdd�Zd�Zd�ZdS(i�Ni�i0i�i�i�i�i�i�cCs|dgkp||kS(s�Check if username is a member of userlist.

    If userlist has a single '*' member, all users are considered members.
    Can be overriden by extensions to provide more complex authorization
    schemes.
    t*((tuitusernametuserlist((s:/sys/lib/python2.7/site-packages/mercurial/hgweb/common.pytismembersc

Cs�|jjd�}|jdd�}|r[|sIt|jj||�r[ttd��n|jdd�}|r�t|jj||�r�ttd��n|dkr�|jr�ttd��n|dks�|dkr�S|jd	d
kr
d}tt
|��n|jjd�}|jdd
t�rR|dkrRtt
d��n|jdd�}|r�|s�t|jj||�r�ttd��n|jdd�}	|	o�t|jj||	�s�ttd��ndS(s�Check permission for operation based on request data (including
    authentication info). Return if op allowed, else raise an ErrorResponse
    exception.tREMOTE_USERtwebt	deny_readsread not authorizedt
allow_readtpullspull not authorizedNtREQUEST_METHODtPOSTspush requires POST requestswsgi.url_schemetpush_sslthttpssssl requiredt	deny_pushspush not authorizedt
allow_push(tenvtgett
configlistRtrepoRt
ErrorResponsetHTTP_UNAUTHORIZEDt	allowpulltNonetHTTP_METHOD_NOT_ALLOWEDt
configbooltTruetHTTP_FORBIDDEN(
thgwebtreqtoptuserRRtmsgtschemetdenytallow((s:/sys/lib/python2.7/site-packages/mercurial/hgweb/common.pyt
checkauthzs.%!%RcBs eZdgd�Zd�ZRS(cCsG|dkrt|�}ntj|�||_||_||_dS(N(Rt_statusmessaget	Exceptiont__init__tcodetmessagetheaders(tselfR(R)R*((s:/sys/lib/python2.7/site-packages/mercurial/hgweb/common.pyR'Ps
		cCs|jS(N(R)(R+((s:/sys/lib/python2.7/site-packages/mercurial/hgweb/common.pyt__str__WsN(t__name__t
__module__RR'R,(((s:/sys/lib/python2.7/site-packages/mercurial/hgweb/common.pyROstcontinuereadercBs&eZd�Zdd�Zd�ZRS(cCs||_||_t|_dS(N(tft_writetFalset	continued(R+R0twrite((s:/sys/lib/python2.7/site-packages/mercurial/hgweb/common.pyR'[s		i�cCs2|js"t|_|jd�n|jj|�S(NsHTTP/1.1 100 Continue

(R3RR1R0tread(R+tamt((s:/sys/lib/python2.7/site-packages/mercurial/hgweb/common.pyR5`s		cCs&|dkrt|j|�St�dS(Ntclosetreadlinet	readlinest__iter__(sclosesreadlines	readliness__iter__(tgetattrR0tAttributeError(R+tattr((s:/sys/lib/python2.7/site-packages/mercurial/hgweb/common.pyt__getattr__fs(R-R.R'R5R>(((s:/sys/lib/python2.7/site-packages/mercurial/hgweb/common.pyR/Zs	cCs-ddlm}|j}|j|d�dS(Ni�(tBaseHTTPRequestHandlertErrors
Unknown errori(sErrors
Unknown error(tBaseHTTPServerR?t	responsesR(R(R?RB((s:/sys/lib/python2.7/site-packages/mercurial/hgweb/common.pyR%ks	cCsd||pt|�fS(Ns%d %s(R%(R(R)((s:/sys/lib/python2.7/site-packages/mercurial/hgweb/common.pyt
statusmessagepscCsEtjj|d�}tjj|�r4tj|�Stj|�SdS(s,stat changelog if it exists, spath otherwises
00changelog.iN(tostpathtjointexistststat(tspathtcl_path((s:/sys/lib/python2.7/site-packages/mercurial/hgweb/common.pytget_statss
cCs
t|�jS(N(RKtst_mtime(RI((s:/sys/lib/python2.7/site-packages/mercurial/hgweb/common.pyt	get_mtime{scCs�|jd�}xZ|D]R}|dtjtjfksdtj|ksdtjdk	rtj|krdSqWtjj|�}t	|t
�r�|g}nx9|D]1}tjj||�}tjj|�r�Pq�q�Wyetj|�t
j|�dp�}t|d�}	|	j�}
|	j�|jt|d|
�Wnetk
r\ttd��nFtk
r�}|jtjkr�tt��q�tt|j��nXdS(	s+return a file inside directory with guessed Content-Type header

    fname always uses '/' as directory separator and isn't allowed to
    contain unusual path components.
    Content-Type is guessed using the mimetypes module.
    Return an empty string if fname is illegal or file not found.

    t/tNis
text/plaintrbtbodysillegal filename(tsplitRDtcurdirtpardirtseptaltsepRRERFt
isinstancetstrRGRHt	mimetypest
guess_typetopenR5R7trespondtHTTP_OKt	TypeErrorRtHTTP_SERVER_ERRORtOSErrorterrnotENOENTtHTTP_NOT_FOUNDtstrerror(t	directorytfnameRtpartstparttfpathtdREtcttfptdataterr((s:/sys/lib/python2.7/site-packages/mercurial/hgweb/common.pyt
staticfile~s2	
-



iccs�|r/|r/|||}|||d@}nd}d}x>tr{|V|d7}|r>||kr>d|}d}q>q>WdS(s5count parity of horizontal stripes for easier readingiiN(R(tstripecounttoffsettcounttparity((s:/sys/lib/python2.7/site-packages/mercurial/hgweb/common.pyt	paritygen�s	

cCs4|dd�p3|dd�p3tjjd�p3dS(s�Return repo contact information or empty string.

    web.contact is the primary source, but if that is not set, try
    ui.username or $EMAIL as a fallback to display something useful.
    RtcontactRRtEMAILRO(RDtenvironR(tconfig((s:/sys/lib/python2.7/site-packages/mercurial/hgweb/common.pytget_contact�scCsPt|j�}|jjd�|kr6tt��n|jjd|f�dS(NtHTTP_IF_NONE_MATCHtETag(RXtmtimeRRRtHTTP_NOT_MODIFIEDR*tappend(RRttag((s:/sys/lib/python2.7/site-packages/mercurial/hgweb/common.pytcaching�s(RaRYRDR]R}tHTTP_BAD_REQUESTRRRcRR_RR$t	permhooksR&RtobjectR/R%RRCRKRMRoRtRyR�(((s:/sys/lib/python2.7/site-packages/mercurial/hgweb/common.pyt<module>	s*$			.					$	

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.