
    h                     t    S r SSKrSSKJrJrJr  SSKJr  SSKJ	r	  SSK
Jr  SSKJr  SS	KJr   " S
 S5      rg)z
File-like object that logs.
    N)AnyStrIterableOptional)NamedConstant)Version)deprecatedProperty   )LogLevel)Loggerc            	          \ rS rSrSrSr\" \" SSSS5      5      S 5       r\R                  S 5       r\
R                  S	4S
\S\S\\   SS	4S jjr\S\4S j5       r\S\4S j5       r\S\4S j5       r\SS j5       r\S\4S j5       rSS jrSS jrS\4S jrS\4S jrS\SS	4S jrS\\   SS	4S jr S\!SS	4S jr"\"r#\"r$\"r%\"r&\"r'\"r(\"r)\"r*Sr+g	) LoggingFile   aK  
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                     U R                   $ N
_softspaceselfs    Y/root/1688_scrapy/alibaba-scraper/venv/lib/python3.13/site-packages/twisted/logger/_io.py	softspaceLoggingFile.softspace!   s        c                     Xl         g r   r   )r   values     r   r   r   %   s    r   Nloggerlevelencodingreturnc                     X l         Xl        Uc  [        R                  " 5       U l        OX0l        SU l        SU l        g)z
@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    s       r   __init__LoggingFile.__init__)   s7     
 335DN%Nr   c                     U R                   $ )zU
Read-only property.  Is the file closed?

@return: true if closed, otherwise false.
r)   r   s    r   closedLoggingFile.closed@   s     ||r   c                     U R                   $ )z=
Read-only property.   File encoding.

@return: an encoding.
)r'   r   s    r   r    LoggingFile.encodingI   s     ~~r   c                     g)z/
Read-only property.  File mode.

@return: "w"
w r   s    r   modeLoggingFile.modeR   s     r   c                     g)zG
Read-only property.  Types of newlines encountered.

@return: L{None}
Nr4   r   s    r   newlinesLoggingFile.newlines[   s     r   c                     SR                  U R                  R                  U R                  R                  U R
                  R                  5      $ )zk
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   s    r   r?   LoggingFile.named   s<     ""NN##HHJJOO
 	
r   c                     SU l         g)z4
Close this file so it can no longer be written to.
TNr-   r   s    r   closeLoggingFile.closer   s     r   c                     g)z#
No-op; this file does not buffer.
Nr4   r   s    r   flushLoggingFile.flushx   s     	r   c                     g)zX
Returns an invalid file descriptor, since this is not backed by an FD.

@return: C{-1}
r4   r   s    r   filenoLoggingFile.fileno~   s     r   c                     g)z3
A L{LoggingFile} is not a TTY.

@return: C{False}
Fr4   r   s    r   isattyLoggingFile.isatty   s     r   messagec                 X   U R                   (       a  [        S5      e[        U[        5      (       a  UR	                  U R
                  5      nOUnU R                  U-   R                  S5      nUS   U l        USS nU H(  nU R                  R                  U R                  SUS9  M*     g)z?
Log the given message.

@param message: The message to write.
zI/O operation on closed file
rH   r   z{log_io})r;   log_ioN)r)   
ValueError
isinstancebytesdecoder'   r(   splitr$   emitr   )r   rN   textlineslines        r   writeLoggingFile.write   s     <<;<<gu%%>>$..1DD$++D1RyaDHHMM$**ZME r   rY   c                 8    U H  nU R                  U5        M     g)zR
Log each of the given lines as a separate message.

@param lines: Data to write.
N)r[   )r   rY   rZ   s      r   
writelinesLoggingFile.writelines   s     DJJt r   argsc                     [        S5      e)z?
Template for unsupported operations.

@param args: Arguments.
zunsupported operation)OSError)r   r`   s     r   _unsupportedLoggingFile._unsupported   s     -..r   )r(   r)   r'   r   r   r$   )r!   N),r=   
__module____qualname____firstlineno____doc__r   r   r   r   setterr
   infor   r   r   strr*   propertyboolr.   r    r5   r8   r?   rB   rE   intrI   rL   r   r[   r   r^   objectrc   readnextreadline	readlines
xreadlinesseektelltruncate__static_attributes__r4   r   r   r   r      s    J	2q!45 6      (}}"&	  3-	
 
.    #   c     
c 
 
  FV F F* 0 T /& /T / DDHIJDDHr   r   )rh   r%   typingr   r   r   
constantlyr   incrementalr   twisted.python.deprecater   _levelsr
   _loggerr   r   r4   r   r   <module>r      s0   
  - - $  7  g gr   