/usr/lib/python3/dist-packages/twisted/python/__pycache__
NameSizeModeActions
compat.cpython-310.pyc153980644editdlrm
components.cpython-310.pyc143640644editdlrm
constants.cpython-310.pyc4680644editdlrm
context.cpython-310.pyc46570644editdlrm
deprecate.cpython-310.pyc252210644editdlrm
failure.cpython-310.pyc189600644editdlrm
fakepwd.cpython-310.pyc72920644editdlrm
filepath.cpython-310.pyc520500644editdlrm
formmethod.cpython-310.pyc127170644editdlrm
htmlizer.cpython-310.pyc35820644editdlrm
lockfile.cpython-310.pyc51380644editdlrm
log.cpython-310.pyc230160644editdlrm
logfile.cpython-310.pyc104590644editdlrm
modules.cpython-310.pyc254690644editdlrm
monkey.cpython-310.pyc23150644editdlrm
procutils.cpython-310.pyc13890644editdlrm
randbytes.cpython-310.pyc37350644editdlrm
rebuild.cpython-310.pyc55780644editdlrm
reflect.cpython-310.pyc191270644editdlrm
release.cpython-310.pyc15250644editdlrm
roots.cpython-310.pyc89330644editdlrm
runtime.cpython-310.pyc56170644editdlrm
sendmsg.cpython-310.pyc25800644editdlrm
shortcut.cpython-310.pyc24640644editdlrm
syslog.cpython-310.pyc33680644editdlrm
systemd.cpython-310.pyc30510644editdlrm
text.cpython-310.pyc42690644editdlrm
threadable.cpython-310.pyc35200644editdlrm
threadpool.cpython-310.pyc105020644editdlrm
url.cpython-310.pyc2790644editdlrm
urlpath.cpython-310.pyc92820644editdlrm
usage.cpython-310.pyc286350644editdlrm
util.cpython-310.pyc279390644editdlrm
versions.cpython-310.pyc3560644editdlrm
win32.cpython-310.pyc48410644editdlrm
zippath.cpython-310.pyc91460644editdlrm
zipstream.cpython-310.pyc88260644editdlrm
_appdirs.cpython-310.pyc8620644editdlrm
_inotify.cpython-310.pyc25800644editdlrm
_pydoctor.cpython-310.pyc57500644editdlrm
_release.cpython-310.pyc181330644editdlrm
_shellcomp.cpython-310.pyc188550644editdlrm
_textattributes.cpython-310.pyc106420644editdlrm
_tzhelper.cpython-310.pyc33850644editdlrm
_url.cpython-310.pyc2690644editdlrm
__init__.cpython-310.pyc5460644editdlrm
Edit: /usr/lib/python3/dist-packages/twisted/python/__pycache__/logfile.cpython-310.pyc (10459B)
o ¯b‡'ã@s˜dZddlZddlZddlZddlZddlmZmZmZddl m Z Gdd„dƒZ Gdd„de ƒZ e   e ¡Gd d „d e ƒZe   e¡Gd d „d ƒZdS) z! A rotating, browsable log file. éN)ÚBinaryIOÚOptionalÚcast)Ú threadablec @s~eZdZdZddgZ ddededeeddfd d „Ze d d „ƒZ d d„Z dd„Z dd„Z dd„Zdd„Zdd„Zdd„ZdS)Ú BaseLogFilez< The base class for a log file that can be rotated. ÚwriteÚrotateNÚnameÚ directoryÚ defaultModeÚreturncCs`||_||_tj ||¡|_|dur'tj |j¡r't t |j¡tj¡|_ n||_ |  ¡dS)a Create a log file. @param name: name of the file @param directory: directory holding the file @param defaultMode: permissions used to create the file. Default to current permissions of the file if the file exists. N) r r ÚosÚpathÚjoinÚexistsÚstatÚS_IMODEÚST_MODEr Ú _openFile)Úselfr r r ©rú8/usr/lib/python3/dist-packages/twisted/python/logfile.pyÚ__init__s ÿ zBaseLogFile.__init__cOs4tj |¡}|tj |¡tj |¡g|¢Ri|¤ŽS)z= Construct a log file from a full file path. )r rÚabspathÚbasenameÚdirname)ÚclsÚfilenameÚargsÚkwargsÚlogPathrrrÚ fromFullPath2s (zBaseLogFile.fromFullPathcCst‚)zc Override with a method to that returns true if the log should be rotated. )ÚNotImplementedError©rrrrÚ shouldRotate:szBaseLogFile.shouldRotatec CsÐd|_tj |j¡rttt|jddƒƒ|_|j dd¡n.|j dur@t  d¡}zttt|jddƒƒ|_Wt  |¡nt  |¡wttt|jddƒƒ|_|j durfz t  |j|j ¡WdSt yeYdSwdS)z[ Open the log file. The log file is always opened in binary mode. Fzrb+réNiÿzwb+) Úclosedr rrrrÚopenÚ_fileÚseekr ÚumaskÚchmodÚOSError)rÚoldUmaskrrrrAs"    þýzBaseLogFile._openFilecCs<| ¡r | ¡| ¡t|tƒr| d¡}|j |¡dS)z¢ Write some data to the file. @param data: The data to write. Text will be encoded as UTF-8. @type data: L{bytes} or L{unicode} Úutf8N)r$ÚflushrÚ isinstanceÚstrÚencoder(r©rÚdatarrrr\s   zBaseLogFile.writecCs|j ¡dS)z! Flush the file. N)r(r/r#rrrr/jszBaseLogFile.flushcCsd|_|j ¡|`dS)z[ Close the file. The file cannot be used once it has been closed. TN)r&r(Úcloser#rrrr5ps zBaseLogFile.closecCs| ¡| ¡dS)a" Reopen the log file. This is mainly useful if you use an external log rotation tool, which moves under your feet. Note that on Windows you probably need a specific API to rename the file, as it's not supported to simply use os.rename, for example. N)r5rr#rrrÚreopenzs zBaseLogFile.reopencCs t|jƒS)z> Return a LogReader for the current log file. )Ú LogReaderrr#rrrÚ getCurrentLog…s zBaseLogFile.getCurrentLog©N)Ú__name__Ú __module__Ú __qualname__Ú__doc__Ú synchronizedr1rÚintrÚ classmethodr!r$rrr/r5r6r8rrrrrs,ÿÿÿÿ þ  rc@sXeZdZdZ   ddd„Zdd„Zdd „Zd d „Zd d „Zdd„Z dd„Z dd„Z dS)ÚLogFilezf A log file that can be rotated. A rotateLength of None disables automatic log rotation. é@BNcCs t ||||¡||_||_dS)a` Create a log file rotating on length. @param name: file name. @type name: C{str} @param directory: path of the log file. @type directory: C{str} @param rotateLength: size of the log file where it rotates. Default to 1M. @type rotateLength: C{int} @param defaultMode: mode used to create the file. @type defaultMode: C{int} @param maxRotatedFiles: if not None, max number of log files the class creates. Warning: it removes all log files above this number. @type maxRotatedFiles: C{int} N)rrÚ rotateLengthÚmaxRotatedFiles)rr r rCr rDrrrr“s zLogFile.__init__cCst |¡|j ¡|_dSr9)rrr(ÚtellÚsizer#rrrr¯s zLogFile._openFilecCs|jo|j|jkS)zL Rotate when the log file size is larger than rotateLength. )rCrFr#rrrr$³szLogFile.shouldRotatecCs*d|j|f}tj |¡stdƒ‚t|ƒS)zK Given an integer, return a LogReader for an old log file. ú%s.%dúno such logfile exists)rr rÚ ValueErrorr7©rÚ identifierrrrrÚgetLog¹s zLogFile.getLogcCs"t ||¡|jt|ƒ7_dS)z. Write some data to the file. N)rrrFÚlenr3rrrrÂs z LogFile.writecCs¶t |jtj¡rt |jtj¡sdS| ¡}| ¡|D])}|jdur3||jkr3t d|j|f¡qt  d|j|fd|j|df¡q|j   ¡t  |jd|j¡|  ¡dS)z° Rotate the file and create a new one. If it's not possible to open new logfile, this will fail silently, and continue logging to old logfile. NrGéz%s.1) r Úaccessr ÚW_OKrÚlistLogsÚreverserDÚremoveÚrenamer(r5r)rÚlogsÚirrrrÉs &  zLogFile.rotatec Cs\g}t d|j¡D]}zt| d¡dƒ}|r| |¡Wq ty'Yq w| ¡|S)zM Return sorted list of integers - the old logs' identifiers. z%s.*Ú.éÿÿÿÿ)Úglobrr?ÚsplitÚappendrIÚsort)rÚresultr ÚcounterrrrrQÝs € ÿzLogFile.listLogscCót |¡}|d=|S)NrF©rÚ __getstate__©rÚstaterrrraìó zLogFile.__getstate__)rBNN) r:r;r<r=rrr$rLrrrQrarrrrrAŒs  ú  rAc@sPeZdZdZdd„Zdd„Zdd„Zdd „Zd d „Zd d „Z dd„Z dd„Z dS)Ú DailyLogFilezAA log file that is rotated daily (at or after midnight localtime)cCs&t |¡| t |j¡d¡|_dS)Né)rrÚtoDater rrÚlastDater#rrrrøs zDailyLogFile._openFilecCs| ¡|jkS)z1Rotate when the date has changed since last write)rgrhr#rrrr$üszDailyLogFile.shouldRotatecGstj|Ždd…S)aConvert a unixtime to (year, month, day) localtime tuple, or return the current (year, month, day) localtime tuple. This function primarily exists so you may overload it with gmtime, or some cruft to make unit testing possible. Né)ÚtimeÚ localtime)rrrrrrgszDailyLogFile.toDatec Cs<z d tt|ƒ¡WStyd tt| |¡ƒ¡YSw)z>Return the suffix given a (year, month, day) tuple or unixtimeÚ_)rÚmapr1Ú BaseExceptionrg)rÚ tupledaterrrÚsuffix s  þzDailyLogFile.suffixcCsJ| |¡|jkr | ¡S|j›d| |¡›}tj |¡s!tdƒ‚t|ƒS)z:Given a unix time, return a LogReader for an old log file.rWrH) rgrhr8rrpr rrIr7rJrrrrLs  zDailyLogFile.getLogcCs"t ||¡t|j| ¡ƒ|_dS)zWrite some data to the log fileN)rrÚmaxrhrgr3rrrrs zDailyLogFile.writecCspt |jtj¡rt |jtj¡sdS|j›d| |j¡›}tj |¡r&dS|j  ¡t  |j|¡|  ¡dS)z§Rotate the file and create a new one. If it's not possible to open new logfile, this will fail silently, and continue logging to old logfile. NrW) r rOr rPrrprhrr(r5rTr)rÚnewpathrrrr#s    zDailyLogFile.rotatecCr_)Nrhr`rbrrrra2rdzDailyLogFile.__getstate__N) r:r;r<r=rr$rgrprLrrrarrrrreõs   rec@s*eZdZdZdd„Zd dd„Zdd„Zd S) r7zRead from a log file.cCst|ƒ|_dS)zŽ Open the log file for reading. The comments about binary-mode for L{BaseLogFile._openFile} also apply here. N)r'r()rr rrrr>szLogReader.__init__é cCs4g}t|ƒD]}|j ¡}|s|S| |¡q|S)zRead a list of lines from the log file. This doesn't returns all of the files lines - call it multiple times. )Úranger(Úreadliner[)rÚlinesr]rVÚlinerrrÚ readLinesGs   ÿzLogReader.readLinescCs|j ¡dSr9)r(r5r#rrrr5TszLogReader.closeN)rs)r:r;r<r=rrxr5rrrrr7;s  r7)r=rYr rrjÚtypingrrrÚtwisted.pythonrrrAÚ synchronizerer7rrrrÚs w f C