o
    ¯bØ  ã                   @   sn   d Z ddlZddlmZmZmZ ddlmZ ddlm	Z	 ddl
mZ ddlmZ dd	lmZ G d
d„ dƒZdS )z
File-like object that logs.
é    N)ÚAnyStrÚIterableÚOptional)ÚNamedConstant)ÚVersion)ÚdeprecatedPropertyé   )ÚLogLevel)ÚLoggerc                	   @   sB  e Zd ZdZdZeeddddƒƒdd„ ƒZejdd„ ƒZe	j
d	fd
ededee dd	fdd„Zedefdd„ƒZedefdd„ƒZedefdd„ƒZed+dd„ƒZedefdd„ƒZd+dd„Zd+dd„Zdefdd„Zdefd d!„Zd"edd	fd#d$„Zd%ee dd	fd&d'„Zd(e dd	fd)d*„Z!e!Z"e!Z#e!Z$e!Z%e!Z&e!Z'e!Z(e!Z)d	S ),ÚLoggingFileac  
    File-like object that turns C{write()} calls into logging events.

    Note that because event formats are L{str}, C{bytes} received via C{write()}
    are converted to C{str}, which is the opposite of what C{file} does.

    @ivar softspace: Attribute to make this class more file-like under Python 2;
        value is zero or one.  Do not use.
    r   ÚTwistedé   é   c                 C   ó   | j S ©N©Ú
_softspace©Úself© r   ú4/usr/lib/python3/dist-packages/twisted/logger/_io.pyÚ	softspace!   s   zLoggingFile.softspacec                 C   s
   || _ d S r   r   )r   Úvaluer   r   r   r   %   s   
NÚloggerÚlevelÚencodingÚreturnc                 C   s6   || _ || _|du rt ¡ | _n|| _d| _d| _dS )a  
        @param logger: the logger to log through.
        @param level: the log level to emit events with.
        @param encoding: The encoding to expect when receiving bytes via
            C{write()}.  If L{None}, use C{sys.getdefaultencoding()}.
        NÚ F)r   ÚlogÚsysÚgetdefaultencodingÚ	_encodingÚ_bufferÚ_closed)r   r   r   r   r   r   r   Ú__init__)   s   
zLoggingFile.__init__c                 C   r   )zm
        Read-only property.  Is the file closed?

        @return: true if closed, otherwise false.
        ©r#   r   r   r   r   Úclosed@   ó   zLoggingFile.closedc                 C   r   )zU
        Read-only property.   File encoding.

        @return: an encoding.
        )r!   r   r   r   r   r   I   r'   zLoggingFile.encodingc                 C   ó   dS )zG
        Read-only property.  File mode.

        @return: "w"
        Úwr   r   r   r   r   ÚmodeR   ó   zLoggingFile.modec                 C   r(   )z_
        Read-only property.  Types of newlines encountered.

        @return: L{None}
        Nr   r   r   r   r   Únewlines[   r+   zLoggingFile.newlinesc                 C   s   d  | jj| jj| jj¡S )z‹
        The name of this file; a repr-style string giving information about its
        namespace.

        @return: A file name.
        z
<{} {}#{}>)ÚformatÚ	__class__Ú__name__r   Ú	namespacer   Únamer   r   r   r   r1   d   s
   ýzLoggingFile.namec                 C   s
   d| _ dS )zD
        Close this file so it can no longer be written to.
        TNr%   r   r   r   r   Úcloser   s   
zLoggingFile.closec                 C   r(   )z3
        No-op; this file does not buffer.
        Nr   r   r   r   r   Úflushx   s   zLoggingFile.flushc                 C   r(   )zp
        Returns an invalid file descriptor, since this is not backed by an FD.

        @return: C{-1}
        éÿÿÿÿr   r   r   r   r   Úfileno~   ó   zLoggingFile.filenoc                 C   r(   )zK
        A L{LoggingFile} is not a TTY.

        @return: C{False}
        Fr   r   r   r   r   Úisatty†   r6   zLoggingFile.isattyÚmessagec                 C   sr   | j rtdƒ‚t|tƒr| | j¡}n|}| j|  d¡}|d | _|dd… }|D ]}| jj	| j
d|d� q*dS )zW
        Log the given message.

        @param message: The message to write.
        zI/O operation on closed fileÚ
r4   r   z{log_io})r-   Úlog_ioN)r#   Ú
ValueErrorÚ
isinstanceÚbytesÚdecoder!   r"   Úsplitr   Úemitr   )r   r8   ÚtextÚlinesÚliner   r   r   ÚwriteŽ   s   

ÿzLoggingFile.writerB   c                 C   s   |D ]}|   |¡ qdS )zj
        Log each of the given lines as a separate message.

        @param lines: Data to write.
        N)rD   )r   rB   rC   r   r   r   Ú
writelines£   s   ÿzLoggingFile.writelinesÚargsc                 G   s   t dƒ‚)zW
        Template for unsupported operations.

        @param args: Arguments.
        zunsupported operation)ÚOSError)r   rF   r   r   r   Ú_unsupported¬   s   zLoggingFile._unsupported)r   N)*r/   Ú
__module__Ú__qualname__Ú__doc__r   r   r   r   Úsetterr	   Úinfor
   r   r   Ústrr$   ÚpropertyÚboolr&   r   r*   r,   r1   r2   r3   Úintr5   r7   r   rD   r   rE   ÚobjectrH   ÚreadÚnextÚreadlineÚ	readlinesÚ
xreadlinesÚseekÚtellÚtruncater   r   r   r   r      sV    


üþýü
û

	r   )rK   r   Útypingr   r   r   Ú
constantlyr   Úincrementalr   Útwisted.python.deprecater   Ú_levelsr	   Ú_loggerr
   r   r   r   r   r   Ú<module>   s   