³ò ÷$•Jc@s¡ddkZddkZddkZdZdZdZdZdZdZdZ d e fd „ƒYZ d „Z d „Z d „Zd„Zdd„Zd„ZdS(iÿÿÿÿNiÈii‘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(tBaseHTTPServerR t responsestget(RR R((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(t stripecounttoffsettcounttparity((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.pyt get_contactas(R3R)RR,tHTTP_BAD_REQUESTtHTTP_UNAUTHORIZEDtHTTP_FORBIDDENR5tHTTP_METHOD_NOT_ALLOWEDR1RRRRRR@RFRN(((s)/sys/lib/python/mercurial/hgweb/common.pys s$   "