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

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


��c@s"ddlZddlZddlZddlmZddlmZmZmZm	Z	m
Z
ddlmZmZddl
mZmZmZmZmZmZmZmZmZddlmZmZddlmZddlZd�Zd	�Zd
�Zd�Z de!fd
��YZ"dS(i�N(t_(tuithgtscmutiltutilt	templater(terrortencoding(	t
ErrorResponset	get_mtimet
staticfilet	paritygentismembertget_contacttHTTP_OKtHTTP_NOT_FOUNDtHTTP_SERVER_ERROR(thgwebtmakebreadcrumb(twsgirequestcCs5g|D]*\}}tj|�jd�|f^qS(Nt/(Rtpconverttstrip(titemstnametpath((s@/sys/lib/python2.7/site-packages/mercurial/hgweb/hgwebdir_mod.pyt
cleannamesscCs�g}x�t|�D]�\}}tjj|�\}}yitd6td6|}Wn'tk
r||j||f�qnXtjjtjj	|��}t
j|dtd|�}|jt
|||��qW|S(Nt*s**t	followsymtrecurse(RtosRtsplittFalsetTruetKeyErrortappendtnormpathtabspathRt	walkrepostextendturlrepos(tpathstrepostprefixtroottrootheadtroottailR((s@/sys/lib/python2.7/site-packages/mercurial/hgweb/hgwebdir_mod.pyt	findreposs
ccs_xX|D]P}tjj|�}|dtj|t|��jd�jd�|fVqWdS(s�yield url paths and filesystem paths from a list of repo paths

    >>> conv = lambda seq: [(v, util.pconvert(p)) for v,p in seq]
    >>> conv(urlrepos('hg', '/opt', ['/opt/r', '/opt/r/r', '/opt']))
    [('hg/r', '/opt/r'), ('hg/r/r', '/opt/r/r'), ('hg', '/opt')]
    >>> conv(urlrepos('', '/opt', ['/opt/r', '/opt/r/r', '/opt']))
    [('r', '/opt/r'), ('r/r', '/opt/r/r'), ('', '/opt')]
    RN(RRR$RRtlentlstripR(R+R-R)R((s@/sys/lib/python2.7/site-packages/mercurial/hgweb/hgwebdir_mod.pyR((s	
cCsqtj|�}|jpd}|jr3|j}n|jp?d}|jd�s^d|}n|t|�|fS(s�
    Extract CGI variables from baseurl

    >>> geturlcgivars("http://host.org/base", "80")
    ('host.org', '80', '/base')
    >>> geturlcgivars("http://host.org:8000/base", "80")
    ('host.org', '8000', '/base')
    >>> geturlcgivars('/base', 8000)
    ('', '8000', '/base')
    >>> geturlcgivars("base", '8000')
    ('', '8000', '/base')
    >>> geturlcgivars("http://host", '8000')
    ('host', '8000', '/')
    >>> geturlcgivars("http://host/", '8000')
    ('host', '8000', '/')
    tR(RturlthosttportRt
startswithtstr(tbaseurlR5tuRR((s@/sys/lib/python2.7/site-packages/mercurial/hgweb/hgwebdir_mod.pyt
geturlcgivars6s	
thgwebdircBseeZdZdd�Zd�Zd�Zd�Zd�Zd�Z	dd�Z
d	�Zd
�ZRS(icCs2||_||_d|_d|_|j�dS(Ni(tconftbaseuitlastrefreshtNonetmotdtrefresh(tselfR<R=((s@/sys/lib/python2.7/site-packages/mercurial/hgweb/hgwebdir_mod.pyt__init__Ts
				cCsc|j|jtj�kr dS|jr;|jj�}n2tj�}|jddd�|jddd�t|jt	t
tf�s>idd6}tj
j|j�s�tjtd�|j��n|j|jd	|d
t�g}x�|jd�D]<\}}x-|jd|�D]}|j||f�qWq�Ht|jt
tf�rb|j}n$t|jt	�r�|jj�}nt|�}x�|jd�D]�\}}	tj|�}x|tj|	dt�D]e}tj
j|�}
tj|
�}|j|�r|t|�}n|j|jd
�|
f�q�Wq�W||_ ||_|jj!ddt"j"�t"_"|jj!ddd�|_#|jj!ddd�|_%|jj!ddd�|_&|j&r�t'|j&�|_&n|jj!dd�|_(|jj!ddd�}|jd
�r+|d}n|j)d
�rG|d }n||_*tj�|_dS(NRtreport_untrustedtofftnonttyttrueshgweb-pathsR)sconfig file %s not found!tremapttrusttcollectionsRRtwebRtstyletpapert	templateststripesiR8R+R2i�(+R>trefreshintervalttimeR=tcopyRt	setconfigt
isinstanceR<tdicttlistttupleRRtexistsRtAbortRt
readconfigR!tconfigitemst
configlistR#RR/RRR&R$R6R0R1R*tconfigRRLR?ttemplatepathtstripecounttintt_baseurltendswithR+(RBR9tmapR)RtignoredRR*R+R,trepo((s@/sys/lib/python2.7/site-packages/mercurial/hgweb/hgwebdir_mod.pyRA[s\	
$			

	cCsPtjjdd�jd�s-td��nddljj}|j|�dS(NtGATEWAY_INTERFACER2sCGI/1.sJThis function is only intended to be called while running as a CGI script.i�(	RtenvirontgetR6tRuntimeErrortmercurial.hgweb.wsgicgiRtwsgicgitlaunch(RBRk((s@/sys/lib/python2.7/site-packages/mercurial/hgweb/hgwebdir_mod.pytrun�scCst||�}|j|�S(N(Rtrun_wsgi(RBtenvtrespondtreq((s@/sys/lib/python2.7/site-packages/mercurial/hgweb/hgwebdir_mod.pyt__call__�scCs�|jjd�}|jdddt�}|rM|sIt|||�rMtS|jdddt�}|s~t|||�r�tStS(sCheck allow_read and deny_read config options of a repo's ui object
        to determine user permissions.  By default, with neither option set (or
        both empty), allow all users to read the repo.  There are two ways a
        user can be denied read access:  (1) deny_read is not empty, and the
        user is unauthenticated or deny_read contains user (or *), and (2)
        allow_read is not empty and the user is not in allow_read.  Return True
        if user is allowed to read the repo, else return False.tREMOTE_USERRKt	deny_readt	untrustedt
allow_read(RoRhR\R!RR (RBRRqtuserRtRv((s@/sys/lib/python2.7/site-packages/mercurial/hgweb/hgwebdir_mod.pytread_allowed�s	cCszy�|j�|jjdd�jd�}|j|�}|ddtj�}tj|�}|jd�sd|jkr?|jd�r�|d}n|jdd	}|j	j
d
dddt�}|s+|j
p�j
�}t|t�r|g}ng|D]}tjj|d�^q}nt|||�gS|se|jt|�|j||�St|j�}	|}
x�|
rX|	j|
�}|r,|
|jd<y,tj|j	|�}t|�j|�SWq,tk
r�
|
j}tt |��q,t!j"k
r(}
tt t|
���q,Xn|
j#d�}|d	krKPn|
| }
q}W|d}g|	D]}|j|�rj|^qjr�|jt|�|j|||�S|jt$|�|d
d|�SWn9tk
r
}|j||�|dd|j%pd�SXWdd}XdS(Nt	PATH_INFOR2RtmimetypeRsstatic/tstaticiiRKRut	REPO_NAMEtnotfoundReR(&RARoRhRRRt	stringifyR6tformRR]R?R R^RTR7RRtjoinR
RpRt	makeindexRUR*Rt
repositoryRRntIOErrortstrerrorRRRt	RepoErrortrfindRtmessage(RBRqtvirtualttmpltctypetfnameR{ttptpR*tvirtualrepotrealRetinsttmsgtuptsubdirtrterr((s@/sys/lib/python2.7/site-packages/mercurial/hgweb/hgwebdir_mod.pyRn�sf

	+	
	
(R2c
snd��d���fd��dtf�dtd���fd�}�j�ddddg}�\}}d	�jkr��jd	d
}|jd�}|r�|d}n||kr�d}q�ng|D]9}d
|d|r�|kr�pd|ff^q�}	�j��j�j�|dd|d|dtd|�j�d|d|t	|	��S(NcSs�|jdddt�}g}x{dddgD]j}|d
|ksd|jdd|d
dt�r.|ji|d
d6|d
d6|d6|d6�q.q.W|S(NRKt
allow_archiveRutzips.ziptgzs.tar.gztbz2s.tar.bz2itallowttypeit	extensiontnodeR3(szips.zip(sgzs.tar.gz(sbz2s.tar.bz2(R\R!t
configboolR#(RtnodeidR3tallowedtarchivesti((s@/sys/lib/python2.7/site-packages/mercurial/hgweb/hgwebdir_mod.pytarchivelist�s'	R2c;sr�jjddt�}�jjddt�}t�}t�}x)�jD]\}}|j|�smqLn|t|�}t}d|kr|s�qLn|jd�}	|	d}
|s�q|
|kr�qLq|
|kr�qt}|
}dj	|	d�}|t|�d }n|g}d�j
krP|jd�j
djd��n�j
drw|jd�j
d�nt
jd	ddj	|�d�}
|rIy t|�tj�df}Wntk
r�qLnXtd
dddd
|dd|d|
ddddd|d|d|ddgdt�}|j|�|VqLn�jj��y#�jtjj	|dd��Wn3tk
r�}�jtd�||f�qLnXd�fd�}�jdddt�r�Ln�j���s�nytj�j|�}WnXt k
r?�jtd�|�qLn.t!j"k
rl�jtd�|�qLnXy#t|j#�tj�df}Wntk
r�qLnXt$|�}|ddd�}|dd
|�}td
|p�d|j%�p�d
|d|d|
d|pdd|j%�p(dd|d|d|dd��d|
��
}|j|�|VqLWdS(NRKtdescendtcollapseRiiRytSCRIPT_NAMEs/+tcontactR2tcontact_sortRt	name_sortR3tdescriptiontdescription_sortt
lastchangetlastchange_sortR�tisdirectorys.hgthgrcserror reading %s/.hg/hgrc: %s
cs�j|||dt�S(NRu(R]R!(tsectionRtdefault(R9(s@/sys/lib/python2.7/site-packages/mercurial/hgweb/hgwebdir_mod.pyRhMsthiddenRus!error accessing repository at %s
tunknownttip(&RR�R!R tsetR*R6R0RR�RotinserttrstriptretsubR	RtmakedatetOSErrorRUtaddRRRZRRt	ExceptiontwarnRR?RxRR�R�RR�tspathR
tupper(R�RcR�R�t	seenrepostseendirsRRt	directoryt	namepartstrootnamet	discardedtpartsR3tdtrowteRhR�R�R�(R�RqRB(R9s@/sys/lib/python2.7/site-packages/mercurial/hgweb/hgwebdir_mod.pyt
rawentriess�		
	#
" 

	
#
#

c;s��d||�}|rX�||fkrXd|�t|d�fd�d|�}nx5t|t�j��D]\}}||d<|VqqWdS(NR�s%s_sorttkeycs|�S(N((tx(tsortkey(s@/sys/lib/python2.7/site-packages/mercurial/hgweb/hgwebdir_mod.pyt<lambda>{streversetparity(tsortedR�RR_(t
sortcolumnt
descendingR�RctrowsR�R�(R�RBtsortdefault(R�s@/sys/lib/python2.7/site-packages/mercurial/hgweb/hgwebdir_mod.pytentriesvs
%
RR�R�R�tsortit-issort_%ss%s%stindexR�R�tpathdefRR�R�(
R?R RARR6tupdatereqenvRoRR+RU(
RBRqR�R�R�tsortableR�R�tcolumnR�((R�R�RqRBR�s@/sys/lib/python2.7/site-packages/mercurial/hgweb/hgwebdir_mod.pyR��s,	
s

C
	c	s��fd�}�fd�}��fd�}dt�fd���j|j�|jjdd�}|jd�s�|d7}ni}|jjddg�d	�d
d�df}tj|�j	�\}}	||d	kr�|d<n|dd
krdpd
}
t
j||
�}�d
dd�}�d
dd�}
�d
d�pZ|d}|jd�sy|d7}ntj|	di|d6|d6|d6|d6|d6|
d6|d6|d6���S(Nc;s�ddtj|�VdS(NtheaderR(R(Rc(R�(s@/sys/lib/python2.7/site-packages/mercurial/hgweb/hgwebdir_mod.pyR��sc;s�d|�VdS(Ntfooter((Rc(R�(s@/sys/lib/python2.7/site-packages/mercurial/hgweb/hgwebdir_mod.pyR��sc;s/�jdk	r�jVn�ddd�VdS(NRKR@R2(R@R?(Rc(R]RB(s@/sys/lib/python2.7/site-packages/mercurial/hgweb/hgwebdir_mod.pyR@�scs�jj||||�S(N(RR](R�RR�Ru(RB(s@/sys/lib/python2.7/site-packages/mercurial/hgweb/hgwebdir_mod.pyR]�sR�R2RRLiRKRMi�t?t&tlogourlshttp://mercurial.selenic.com/tlogoimgs
hglogo.pngt	staticurlsstatic/tdefaultsR�R�R@R3tsessionvars(R?R!R�RoRhRbRRtstylemapR^twebutilR�(RBRqR�R�R@R3tvarststylesRLtmapfiletstartR�R�R�R�((R]RBR�s@/sys/lib/python2.7/site-packages/mercurial/hgweb/hgwebdir_mod.pyR�s@
	



cCsS|jdk	rOt|j|d�\}}}||d<||d<||d<ndS(NtSERVER_PORTtSERVER_NAMER�(RaR?R:(RBRoRR5R((s@/sys/lib/python2.7/site-packages/mercurial/hgweb/hgwebdir_mod.pyR��s


N(
t__name__t
__module__RPR?RCRARmRrRxRnR�RR�(((s@/sys/lib/python2.7/site-packages/mercurial/hgweb/hgwebdir_mod.pyR;Qs	5				E�4(#RR�RQtmercurial.i18nRt	mercurialRRRRRRRtcommonRR	R
RRR
RRRt	hgweb_modRRtrequestRR�RR/R(R:tobjectR;(((s@/sys/lib/python2.7/site-packages/mercurial/hgweb/hgwebdir_mod.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 [email protected].