; hkDc@sdkZdkZdkZdkZdkZdkZdkZdkZdkZy ei Z Wne j odZ nXe edo dZ nei dZdZ y eiZWne j oddZnXy eiZWne j odZnXy eiZWn+e j od Zd Zd ZnXy eiZWne j od ZnXd ZdS(NcCsw| odSnti}g}xA|iD]3\}}|i||d|t |q,Wt i |dSdS(s6Encode a dictionary as application/x-url-form-encoded.ss=s&N( sdictsurllibs quote_plussquoteskeyvaluesitemsskeysvaluesappendsstrsstringsjoin(sdictsquotesvalueskeyskeyvalue((s lib/compat.pys urlencode!s  +sstrptimecCsti|dd dfSdS(s"Parse a CVS-style date/time value.s%Y/%m/%d %H:%M:%SiiN(stimesstrptimestimestr(stimestr((s lib/compat.pys cvs_strptime/ssK([0-9]{4})/([0-9][0-9])/([0-9][0-9]) ([0-9][0-9]):([0-9][0-9]):([0-9][0-9])cCsPti|}|o*ttt|idddfSn tddS(s"Parse a CVS-style date/time value.iisdate is not in cvs formatN(s _re_rev_datesmatchstimestrstuplesmapsintsgroupss ValueError(stimestrsmatch((s lib/compat.pys cvs_strptime5s *icCs_tii|\}}|o|otii| ot||nti||dS(N( sosspathssplitsheadstailsexistssmakedirssmodesmkdir(spathsmodesheadstail((s lib/compat.pysmakedirsCs"cCs|tjoti}nti|}ddddddddg|d |d d d d dddddddddg |dd|d|d|d|dfSdS(Ns#%s, %02d %s %04d %02d:%02d:%02d GMTsMonsTuesWedsThusFrisSatsSuniisJansFebsMarsAprsMaysJunsJulsAugsSepsOctsNovsDeciiiii(stimevalsNonestimesgmtime(stimeval((s lib/compat.pys formatdateOs cCsH|d}|d}|d|d|d|d|d|dSdS(sRReturn number of leap years in range [year1, year2). Assume year1 <= year2.iiidiN(syear1syear2(syear1syear2((s lib/compat.pysleapdaysas  ic Cs|d \}}} }} }d|ttt|}x(t d|D]}|t i |}qGW|djo t i|o|d}n|| d}|d|}|d| } | d|}|SdS(sBUnrelated but handy function to calculate Unix timestamp from GMT.iimiiii<N(stuplesyearsmonthsdayshoursminutessecondsEPOCHsleapdayssdayssrangesiscalendarsmdayssisleapshourssminutessseconds( stupleshoursisdayssmonthshoursssecondsssecondsyearsminutessdaysminute((s lib/compat.pystimegmjscCsxmtdD]_}ti}yti|d|SWq tj o&}|i t i joq nq Xq Wt t i dfdS(Ni is(No usable temporary directory name found( srangesistempfilesmktempsdirsossmkdirsOSErrorseserrnosEEXISTsIOError(sesisdir((s lib/compat.pysmkdtemps   cCsGdk}t|id o&d|ifdY}||_ndS(Ns close_requests TCPServercBstZdZdZRS(NcCs!|i|||i|dS(sVCall finish_request. Overridden by ForkingMixIn and ThreadingMixIn. N(sselfsfinish_requestsrequestsclient_addresss close_request(sselfsrequestsclient_address((s lib/compat.pysprocess_requestscCs|idS(s)Called to clean up an individual request.N(srequestsclose(sselfsrequest((s lib/compat.pys close_requests(s__name__s __module__sprocess_requests close_request(((s lib/compat.pys TCPServers (s SocketServershasattrs TCPServer(s SocketServers TCPServer((s lib/compat.pysfor_standalones (surllibsstringstimescalendarsresossrfc822stempfileserrnos urlencodesAttributeErrorshasattrs cvs_strptimescompiles _re_rev_datesmakedirss formatdatestimegmsleapdayssEPOCHsmkdtempsfor_standalone(s urlencodesleapdaysstimegmsstringsrfc822stempfileserrnosmakedirss formatdatesurllibs cvs_strptimesresEPOCHsfor_standalonestimescalendars _re_rev_datesossmkdtemp((s lib/compat.pys?sF