�
�c@s�ddkZddkZddkZdZdZdZdZdZdZdZ d e
fd
��YZd�Zd�Z
d
�Zd�Zdd�Zd�ZdS(i�Ni�i�i�i�i�i�i�t
ErrorResponsecBseZdgd�ZRS(cCsLti|�||_||_|dj o
||_nt|�|_dS(N(t Exceptiont__init__tcodetheaderstNonetmessaget_statusmessage(tselfRRR((s)/sys/lib/python/mercurial/hgweb/common.pyRs
N(t__name__t
__module__RR(((s)/sys/lib/python/mercurial/hgweb/common.pyRscCs-ddkl}|i}|i|d�dS(Ni�(tBaseHTTPRequestHandlertErrors
Unknown errori(sErrors
Unknown error(tBaseHTTPServerRt responsestget(RRR((s)/sys/lib/python/mercurial/hgweb/common.pyRs cCsd|t|�fS(Ns%d %s(R(R((s)/sys/lib/python/mercurial/hgweb/common.pyt
statusmessage"scCs�tii|d�}tiitii|d��ptii|d�}ntii|d�}tii|�oti|�iSnti|�iSdS(Ns.hgtdatatstores
00changelog.i(tostpathtjointisdirtexistststattst_mtime(t repo_patht
store_pathtcl_path((s)/sys/lib/python/mercurial/hgweb/common.pyt get_mtime%s"c
Cs�|id�}xb|D]Z}|dtitifjp0ti|jp tidj oti|jodSqqWtii|�}t |t
�o
|g}nx;|D]3}tii||�}tii|�oPq�q�Wy`ti|�t
i|�dpd}|it|dtii|��t|d�i�SWnktj
ottd��nKtj
o>} | itijott��q�tt| i��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/tis
text/plaintlengthtrbsillegal filenameN(tsplitRtcurdirtpardirtseptaltsepRRRt
isinstancetstrRRt mimetypest
guess_typetrespondtHTTP_OKtgetsizetopentreadt TypeErrorRtHTTP_SERVER_ERRORtOSErrorterrnotENOENTtHTTP_NOT_FOUNDtstrerror(
t directorytfnametreqtpartstparttfpathtdRtctterr((s)/sys/lib/python/mercurial/hgweb/common.pyt
staticfile/s2 0
"iccs�|o+|o$|||}|||d@}n
d}d}xCto;|V|d7}|o!||jod|}d}qAqAWdS(s5count parity of horizontal stripes for easier readingiiN(tTrue(tstripecounttoffsettcounttparity((s)/sys/lib/python/mercurial/hgweb/common.pyt paritygenQs
cCs7|dd�p'|dd�ptiid�pdS(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.
twebtcontacttuitusernametEMAILR(RtenvironR(tconfig((s)/sys/lib/python/mercurial/hgweb/common.pytget_contactas(R3R)RR,tHTTP_BAD_REQUESTtHTTP_UNAUTHORIZEDtHTTP_FORBIDDENR5tHTTP_METHOD_NOT_ALLOWEDR1RRRRRR@RFRN(((s)/sys/lib/python/mercurial/hgweb/common.pys<module> s$
"
|