o ?Ogq@stdZddlZddlZddlZddlZddlZddlZddlmZ ej dvr,ddl m Z ndZ ddlZddlmZmZmZmZhdZeedrSeejeejd ZeZeed p_ejjZeZd7d d Ze  d8ddZ ddZ!zej"Z"Wn e#ye!Z"YnwddZ$zej%Z%Wne#yGddde&e'Z%YnwGdddej(dZ)ej)*e)Gddde)Z+ej+*e+ddl,m-Z-e+*e-Gdd d e)Z.ej.*e.Gd!d"d"e.Z/Gd#d$d$e.Z0Gd%d&d&e/Z1Gd'd(d(e/Z2Gd)d*d*e.Z3Gd+d,d,e2e1Z4Gd-d.d.e+Z-Gd/d0d0e)Z5ej5*e5Gd1d2d2ej6Z7Gd3d4d4e5Z8Gd5d6d6e8Z9dS)9z) Python implementation of the io module. N) allocate_lock>Zwin32cygwin)setmode)__all__SEEK_SETSEEK_CURSEEK_END>r SEEK_HOLEi Zgettotalrefcountr cCs2|durd}tjjrddl}|dt|d|S)a A helper function to choose the text encoding. When encoding is not None, just return it. Otherwise, return the default text encoding (i.e. "locale"). This function emits an EncodingWarning if *encoding* is None and sys.flags.warn_default_encoding is true. This can be used in APIs with an encoding=None parameter that pass it to TextIOWrapper or open. However, please consider using encoding="utf-8" for new APIs. Nlocalerz"'encoding' argument not specified.r )sysflagswarn_default_encodingwarningswarnEncodingWarning)encoding stacklevelrr,/opt/alt/python310/lib64/python3.10/_pyio.py text_encoding+srrTc Cspt|ts t|}t|tttfstd|t|ts#td|t|ts.td||dur=t|ts=td||durLt|tsLtd|t|}|tds^t|t|krdt d|d|v} d |v} d |v} d |v} d |v} d |v}d|v}d|vr| s| s| s| rt dddl }| dt dd} |r|rt d| | | | dkrt d| s| s| s| st d|r|durt d|r|durt d|r|durt d|r|dkrddl }| dt dt|| rdpd| rd pd| rd pd| r d p d| rd pd||d}|}zd}|dks,|dkr0|r0d }d}|dkrUt}z t|j}Wn ttfyMYnw|dkrU|}|dkr^t d!|dkrm|ri|WSt d"| rvt||}n| s| s| rt||}n| rt||}nt d#||}|r|WSt|}t|||||}|}||_|WS|)$aOpen file and return a stream. Raise OSError upon failure. file is either a text or byte string giving the name (and the path if the file isn't in the current working directory) of the file to be opened or an integer file descriptor of the file to be wrapped. (If a file descriptor is given, it is closed when the returned I/O object is closed, unless closefd is set to False.) mode is an optional string that specifies the mode in which the file is opened. It defaults to 'r' which means open for reading in text mode. Other common values are 'w' for writing (truncating the file if it already exists), 'x' for exclusive creation of a new file, and 'a' for appending (which on some Unix systems, means that all writes append to the end of the file regardless of the current seek position). In text mode, if encoding is not specified the encoding used is platform dependent. (For reading and writing raw bytes use binary mode and leave encoding unspecified.) The available modes are: ========= =============================================================== Character Meaning --------- --------------------------------------------------------------- 'r' open for reading (default) 'w' open for writing, truncating the file first 'x' create a new file and open it for writing 'a' open for writing, appending to the end of the file if it exists 'b' binary mode 't' text mode (default) '+' open a disk file for updating (reading and writing) 'U' universal newline mode (deprecated) ========= =============================================================== The default mode is 'rt' (open for reading text). For binary random access, the mode 'w+b' opens and truncates the file to 0 bytes, while 'r+b' opens the file without truncation. The 'x' mode implies 'w' and raises an `FileExistsError` if the file already exists. Python distinguishes between files opened in binary and text modes, even when the underlying operating system doesn't. Files opened in binary mode (appending 'b' to the mode argument) return contents as bytes objects without any decoding. In text mode (the default, or when 't' is appended to the mode argument), the contents of the file are returned as strings, the bytes having been first decoded using a platform-dependent encoding or using the specified encoding if given. 'U' mode is deprecated and will raise an exception in future versions of Python. It has no effect in Python 3. Use newline to control universal newlines mode. buffering is an optional integer used to set the buffering policy. Pass 0 to switch buffering off (only allowed in binary mode), 1 to select line buffering (only usable in text mode), and an integer > 1 to indicate the size of a fixed-size chunk buffer. When no buffering argument is given, the default buffering policy works as follows: * Binary files are buffered in fixed-size chunks; the size of the buffer is chosen using a heuristic trying to determine the underlying device's "block size" and falling back on `io.DEFAULT_BUFFER_SIZE`. On many systems, the buffer will typically be 4096 or 8192 bytes long. * "Interactive" text files (files for which isatty() returns True) use line buffering. Other text files use the policy described above for binary files. encoding is the str name of the encoding used to decode or encode the file. This should only be used in text mode. The default encoding is platform dependent, but any encoding supported by Python can be passed. See the codecs module for the list of supported encodings. errors is an optional string that specifies how encoding errors are to be handled---this argument should not be used in binary mode. Pass 'strict' to raise a ValueError exception if there is an encoding error (the default of None has the same effect), or pass 'ignore' to ignore errors. (Note that ignoring encoding errors can lead to data loss.) See the documentation for codecs.register for a list of the permitted encoding error strings. newline is a string controlling how universal newlines works (it only applies to text mode). It can be None, '', '\n', '\r', and '\r\n'. It works as follows: * On input, if newline is None, universal newlines mode is enabled. Lines in the input can end in '\n', '\r', or '\r\n', and these are translated into '\n' before being returned to the caller. If it is '', universal newline mode is enabled, but line endings are returned to the caller untranslated. If it has any of the other legal values, input lines are only terminated by the given string, and the line ending is returned to the caller untranslated. * On output, if newline is None, any '\n' characters written are translated to the system default line separator, os.linesep. If newline is '', no translation takes place. If newline is any of the other legal values, any '\n' characters written are translated to the given string. closedfd is a bool. If closefd is False, the underlying file descriptor will be kept open when the file is closed. This does not work when a file name is given and must be True in that case. The newly created file is non-inheritable. A custom opener can be used by passing a callable as *opener*. The underlying file descriptor for the file object is then obtained by calling *opener* with (*file*, *flags*). *opener* must return an open file descriptor (passing os.open as *opener* results in functionality similar to passing None). open() returns a file object whose type depends on the mode, and through which the standard file operations such as reading and writing are performed. When open() is used to open a file in a text mode ('w', 'r', 'wt', 'rt', etc.), it returns a TextIOWrapper. When used to open a file in a binary mode, the returned class varies: in read binary mode, it returns a BufferedReader; in write binary and append binary modes, it returns a BufferedWriter, and in read/write mode, it returns a BufferedRandom. It is also possible to use a string or bytearray as a file for both reading and writing. For strings StringIO can be used like a file opened in a text mode, and for bytes a BytesIO can be used like a file opened in a binary mode. zinvalid file: %rzinvalid mode: %rzinvalid buffering: %rNinvalid encoding: %rinvalid errors: %rzaxrwb+tUxrwa+tbUz4mode U cannot be combined with 'x', 'w', 'a', or '+'rz'U' mode is deprecatedr Tz'can't have text and binary mode at oncer z)can't have read/write/append mode at oncez/must have exactly one of read/write/append modez-binary mode doesn't take an encoding argumentz+binary mode doesn't take an errors argumentz+binary mode doesn't take a newline argumentzaline buffering (buffering=1) isn't supported in binary mode, the default buffer size will be used)openerFrzinvalid buffering sizezcan't have unbuffered text I/Ozunknown mode: %r) isinstanceintosfspathstrbytes TypeErrorsetlen ValueErrorrrDeprecationWarningRuntimeWarningFileIOisattyDEFAULT_BUFFER_SIZEfstatfileno st_blksizeOSErrorAttributeErrorBufferedRandomBufferedWriterBufferedReaderr TextIOWrappermodeclose)filer= bufferingrerrorsnewlineclosefdr$ZmodesZcreatingZreadingZwritingZ appendingZupdatingtextZbinaryrrawresultline_bufferingZbsbufferrrropenHs |                       rIcCs ddl}|dtdt|dS)azOpens the provided file with mode ``'rb'``. This function should be used when the intent is to treat the contents as executable code. ``path`` should be an absolute path. When supported by the runtime, this function can be hooked in order to allow embedders more control over code files. This functionality is not supported on the current runtime. rNz(_pyio.open_code() may not be using hooksr rb)rrr0rI)pathrrrr_open_code_with_warning$s   rLcCs0|dkrddl}|jdtddtatSt|)N OpenWrapperrz+OpenWrapper is deprecated, use open insteadr )r)rrr/rIrMr8)namerrrr __getattr__:srOc@s eZdZdS)UnsupportedOperationN)__name__ __module__ __qualname__rrrrrPOsrPc@seZdZdZddZd6ddZddZd7d d Zd d ZdZ ddZ ddZ ddZ d7ddZ ddZd7ddZddZd7ddZedd Zd7d!d"Zd#d$Zd%d&Zd'd(Zd)d*Zd8d,d-Zd.d/Zd0d1Zd7d2d3Zd4d5Zd S)9IOBaseaThe abstract base class for all I/O classes. This class provides dummy implementations for many methods that derived classes can override selectively; the default implementations represent a file that cannot be read, written or seeked. Even though IOBase does not declare read or write because their signatures will vary, implementations and clients should consider those methods part of the interface. Also, implementations may raise UnsupportedOperation when operations they do not support are called. The basic type used for binary data read from or written to a file is bytes. Other bytes-like objects are accepted as method arguments too. Text I/O classes work with str data. Note that calling any method (even inquiries) on a closed stream is undefined. Implementations may raise OSError in this case. IOBase (and its subclasses) support the iterator protocol, meaning that an IOBase object can be iterated over yielding the lines in a stream. IOBase also supports the :keyword:`with` statement. In this example, fp is closed after the suite of the with statement is complete: with open('spam.txt', 'r') as fp: fp.write('Spam and eggs!') cCstd|jj|f)z@Internal: raise an OSError exception for unsupported operations.z%s.%s() not supported)rP __class__rQ)selfrNrrr _unsupportedus zIOBase._unsupportedrcC|ddS)a$Change stream position. Change the stream position to byte offset pos. Argument pos is interpreted relative to the position indicated by whence. Values for whence are ints: * 0 -- start of stream (the default); offset should be zero or positive * 1 -- current stream position; offset may be negative * 2 -- end of stream; offset is usually negative Some operating systems / file systems could provide additional values. Return an int indicating the new absolute position. seekNrWrVposwhencerrrrY|sz IOBase.seekcCs |ddS)z5Return an int indicating the current stream position.rr )rYrVrrrtell z IOBase.tellNcCrX)zTruncate file to size bytes. Size defaults to the current IO position as reported by tell(). Return the new size. truncateNrZrVr\rrrrazIOBase.truncatecC |dS)zuFlush write buffers, if applicable. This is not implemented for read-only and non-blocking streams. N _checkClosedr^rrrflushs z IOBase.flushFcCs(|jsz |Wd|_dSd|_wdS)ziFlush and close the IO object. This method has no effect if the file is already closed. TN)_IOBase__closedrgr^rrrr>s  z IOBase.closecCsTz|j}Wn tyYdSw|rdStr|dSz|WdSYdS)zDestructor. Calls close().N)closedr8_IOBASE_EMITS_UNRAISABLEr>)rVrirrr__del__s   zIOBase.__del__cCdS)zReturn a bool indicating whether object supports random access. If False, seek(), tell() and truncate() will raise OSError. This method may need to do a test seek(). Frr^rrrseekableszIOBase.seekablecC"|st|dur d|dS)zEInternal: raise UnsupportedOperation if file is not seekable NzFile or stream is not seekable.)rmrPrVmsgrrr_checkSeekablezIOBase._checkSeekablecCrl)zvReturn a bool indicating whether object was opened for reading. If False, read() will raise OSError. Frr^rrrreadablezIOBase.readablecCrn)zEInternal: raise UnsupportedOperation if file is not readable NzFile or stream is not readable.)rsrProrrr_checkReadablerrzIOBase._checkReadablecCrl)zReturn a bool indicating whether object was opened for writing. If False, write() and truncate() will raise OSError. Frr^rrrwritablertzIOBase.writablecCrn)zEInternal: raise UnsupportedOperation if file is not writable NzFile or stream is not writable.)rvrProrrr_checkWritablerrzIOBase._checkWritablecC|jS)zclosed: bool. True iff the file has been closed. For backwards compatibility, this is a property, not a predicate. )rhr^rrrrisz IOBase.closedcCs |jrt|dur d|dS)z7Internal: raise a ValueError if file is closed NI/O operation on closed file.rir.rorrrrfszIOBase._checkClosedcC ||S)zCContext management protocol. Returns self (an instance of IOBase).rer^rrr __enter__szIOBase.__enter__cGrd)z+Context management protocol. Calls close()N)r>)rVargsrrr__exit__ r`zIOBase.__exit__cCrX)zReturns underlying file descriptor (an int) if one exists. An OSError is raised if the IO object does not use a file descriptor. r5NrZr^rrrr5z IOBase.filenocCrd)z{Return a bool indicating whether this is an 'interactive' stream. Return False if it can't be determined. Frer^rrrr2sz IOBase.isattyrcstdr fdd}ndd}durdnzj}Wnty+tdw|t}dksd}|s dS|ddpt|}dkrt|}|S)Nr  r)rfindr-min)Z readaheadnrVsizerr nreadahead0s  z#IOBase.readline..nreadaheadcSrlNr rrrrrr9sNr is not an integerrr) hasattr __index__r8r+ bytearrayr-readendswithr*)rVrr size_indexresr!rrrreadline$s.      zIOBase.readlinecCr{Nrer^rrr__iter__NszIOBase.__iter__cCs|}|st|Sr)r StopIterationrVlinerrr__next__RszIOBase.__next__cCsR|dus|dkr t|Sd}g}|D]}|||t|7}||kr&|Sq|S)zReturn a list of lines from the stream. hint can be specified to control the number of lines read: no more lines will be read if the total size (in bytes/characters) of all lines so far exceeds hint. Nr)listappendr-)rVZhintrlinesrrrr readlinesXs  zIOBase.readlinescCs ||D]}||qdS)zWrite a list of lines to the stream. Line separators are not added, so it is usual for each of the lines provided to have a line separator at the end. N)rfwrite)rVrrrrr writelinesjs zIOBase.writelinesrrr)rQrRrS__doc__rWrYr_rargrhr>rkrmrqrsrurvrwpropertyrirfr|r~r5r2rrrrrrrrrrTSs8           *  rT) metaclassc@s2eZdZdZd ddZddZddZd d Zd S) RawIOBasezBase class for raw binary I/O.rcCsP|durd}|dkr|St|}||}|durdS||d=t|S)zRead and return up to size bytes, where size is an int. Returns an empty bytes object on EOF, or None if the object is set not to block and has no data to read. Nrr)readallrrreadintor*)rVrr!rrrrrs   zRawIOBase.readcCs2t} |t}|s n||7}q|rt|S|S)z+Read until EOF, using multiple read() call.)rrr3r*)rVrdatarrrrs zRawIOBase.readallcCrX)zRead bytes into a pre-allocated bytes-like object b. Returns an int representing the number of bytes read (0 for EOF), or None if the object is set not to block and has no data to read. rNrZrVr!rrrrrczRawIOBase.readintocCrX)zWrite the given buffer to the IO stream. Returns the number of bytes written, which may be less than the length of b in bytes. rNrZrrrrrrczRawIOBase.writeNr)rQrRrSrrrrrrrrrrws   r)r1c@sLeZdZdZdddZdddZddZd d Zd d Zd dZ ddZ dS)BufferedIOBaseaBase class for buffered IO objects. The main difference with RawIOBase is that the read() method supports omitting the size argument, and does not have a default implementation that defers to readinto(). In addition, read(), readinto() and write() may raise BlockingIOError if the underlying raw stream is in non-blocking mode and not ready; unlike their raw counterparts, they will never return None. A typical implementation should not inherit from a RawIOBase implementation, but wrap one. rcCrX)aRead and return up to size bytes, where size is an int. If the argument is omitted, None, or negative, reads and returns all data until EOF. If the argument is positive, and the underlying raw stream is not 'interactive', multiple raw reads may be issued to satisfy the byte count (unless EOF is reached first). But for interactive raw streams (XXX and for pipes?), at most one raw read will be issued, and a short result does not imply that EOF is imminent. Returns an empty bytes array on EOF. Raises BlockingIOError if the underlying raw stream has no data at the moment. rNrZrrrrrszBufferedIOBase.readcCrX)zaRead up to size bytes with at most one read() system call, where size is an int. read1NrZrrrrrszBufferedIOBase.read1cC|j|ddS)afRead bytes into a pre-allocated bytes-like object b. Like read(), this may issue multiple reads to the underlying raw stream, unless the latter is 'interactive'. Returns an int representing the number of bytes read (0 for EOF). Raises BlockingIOError if the underlying raw stream has no data at the moment. Fr _readintorrrrrs zBufferedIOBase.readintocCr)zRead bytes into buffer *b*, using at most one system call Returns an int representing the number of bytes read (0 for EOF). Raises BlockingIOError if the underlying raw stream has no data at the moment. Trrrrrr readinto1 zBufferedIOBase.readinto1cCsVt|ts t|}|d}|r|t|}n|t|}t|}||d|<|S)NB)r% memoryviewcastrr-r)rVr!rrrrrrrs   zBufferedIOBase._readintocCrX)aWrite the given bytes buffer to the IO stream. Return the number of bytes written, which is always the length of b in bytes. Raises BlockingIOError if the buffer is full and the underlying raw stream cannot accept more data at the moment. rNrZrrrrr rzBufferedIOBase.writecCrX)z Separate the underlying raw stream from the buffer and return it. After the raw stream has been detached, the buffer is in an unusable state. detachNrZr^rrrrzBufferedIOBase.detachNr) rQrRrSrrrrrrrrrrrrrs    rc@seZdZdZddZd$ddZddZd%d d Zd d ZddZ ddZ ddZ e ddZ e ddZe ddZe ddZddZddZd d!Zd"d#Zd S)&_BufferedIOMixinzA mixin implementation of BufferedIOBase with an underlying raw stream. This passes most requests on to the underlying raw stream. It does *not* provide implementations of read(), readinto() or write(). cCs ||_dSr_rawrVrErrr__init__, z_BufferedIOMixin.__init__rcCs"|j||}|dkrtd|S)Nrz#seek() returned an invalid position)rErYr7)rVr\r]Z new_positionrrrrY1sz_BufferedIOMixin.seekcCs|j}|dkr td|S)Nrz#tell() returned an invalid position)rEr_r7rbrrrr_7s z_BufferedIOMixin.tellNcCs4||||dur|}|j|Sr)rfrwrgr_rErarbrrrra=s  z_BufferedIOMixin.truncatecCs|jrtd|jdS)Nflush on closed file)rir.rErgr^rrrrgNsz_BufferedIOMixin.flushcC>|jdur|jsz |W|jdS|jwdSdSr)rErirgr>r^rrrr>Ss  z_BufferedIOMixin.closecC*|jdur td||j}d|_|S)Nzraw stream already detached)rEr.rgrrrrrr[ z_BufferedIOMixin.detachcC |jSr)rErmr^rrrrmerz_BufferedIOMixin.seekablecCrxrrr^rrrrEhz_BufferedIOMixin.rawcC|jjSr)rErir^rrrrilz_BufferedIOMixin.closedcCrr)rErNr^rrrrNprz_BufferedIOMixin.namecCrr)rEr=r^rrrr=trz_BufferedIOMixin.modecCtd|jjdNzcannot pickle z objectr+rUrQr^rrr __getstate__xz_BufferedIOMixin.__getstate__cCsH|jj}|jj}z|j}Wntyd||YSwd|||S)Nz<{}.{}>z<{}.{} name={!r}>)rUrRrSrNr8format)rVmodnameZclsnamerNrrr__repr__{s  z_BufferedIOMixin.__repr__cCrr)rEr5r^rrrr5rz_BufferedIOMixin.filenocCrr)rEr2r^rrrr2rz_BufferedIOMixin.isattyrr)rQrRrSrrrYr_rargr>rrmrrErirNr=rrr5r2rrrrr#s,        rcseZdZdZdZd!ddZddZddZd d Zfd d Z d"ddZ d"ddZ ddZ d#ddZ ddZd!ddZddZddZdd ZZS)$BytesIOzr^rUrrr>s  z BytesIO.closercCs|jrtd|durd}nz|j}Wnty!t|dw|}|dkr.t|j}t|j|jkr8dStt|j|j|}|j|j|}||_t |S)Nread from closed filerrr) rir.rr8r+r-rrrr*)rVrrZnewposr!rrrrs$   z BytesIO.readcCs ||S)z"This is the same as read. )rrrrrr z BytesIO.read1cCs|jrtdt|trtdt| }|j}Wdn1s"wY|dkr-dS|j}|t|j krGd|t|j }|j |7_ ||j |||<|j|7_|S)Nwrite to closed file can't write str to binary streamr) rir.r%r)r+rnbytesrr-r)rVr!Zviewrr\Zpaddingrrrrs   z BytesIO.writercCs|jrtdz|j}Wntyt|dw|}|dkr3|dkr-td|f||_|jS|dkrCtd|j||_|jS|dkrUtdt|j||_|jStd)Nzseek on closed filerrnegative seek position %rr r zunsupported whence value) rir.rr8r+rmaxr-r)rVr\r] pos_indexrrrrYs(  z BytesIO.seekcC|jrtd|jS)Ntell on closed file)rir.rr^rrrr_z BytesIO.tellcCsr|jrtd|dur|j}n"z|j}Wnty"t|dw|}|dkr1td|f|j|d=|S)Nztruncate on closed filerrznegative truncate position %r)rir.rrr8r+r)rVr\rrrrras   zBytesIO.truncatecC|jrtddSNryTrzr^rrrrs zBytesIO.readablecCrrrzr^rrrrvrzBytesIO.writablecCrrrzr^rrrrmrzBytesIO.seekablerrr)rQrRrSrrrrrrr>rrrrYr_rarsrvrm __classcell__rrrrrs"      rc@sxeZdZdZefddZddZddZdd d Zdd d Z dddZ dddZ dddZ ddZ ddZdddZdS)r;aBufferedReader(raw[, buffer_size]) A buffer for a readable, sequential BaseRawIO object. The constructor creates a BufferedReader for the given readable raw stream and buffer_size. If buffer_size is omitted, DEFAULT_BUFFER_SIZE is used. cCsF|stdt|||dkrtd||_|t|_dS)zMCreate a new buffered reader using the given readable raw IO object. z "raw" argument must be readable.rinvalid buffer sizeN) rsr7rrr. buffer_size_reset_read_bufLock _read_lockrVrErrrrr(s  zBufferedReader.__init__cCrr)rErsr^rrrrs5rzBufferedReader.readablecCsd|_d|_dS)Nrr) _read_buf _read_posr^rrrr8s zBufferedReader._reset_read_bufNcCsL|dur |dkr td|j ||WdS1swYdS)zRead size bytes. Returns exactly size bytes of data unless the underlying raw IO stream reaches EOF or if the call would block in non-blocking mode. If size is negative, read until EOF or until read() would block. Nrzinvalid number of bytes to read)r.r_read_unlockedrrrrr<s $zBufferedReader.readc Csd}d}|j}|j}|dus|dkr^|t|jdr5|j}|dur-||dp,dS||d|S||dg}d} |j}||vrK|}n |t|7}||q?d |p]|St||} || krw|j|7_||||S||dg}t |j |} | |kr|j| }||vr|}n| t|7} ||| |kst || }d |} | |d|_d|_| r| d|S|S)Nr)rNrrr) rrrrrErrr-rjoinrrr) rVrZ nodata_valZ empty_valuesrr\chunkZchunksZ current_sizeavailZwantedoutrrrrIsR           zBufferedReader._read_unlockedrcCs4|j ||WdS1swYdS)zReturns buffered bytes without advancing the position. The argument indicates a desired minimal number of bytes; we do at most one raw read to satisfy it. We never return more than self.buffer_size. N)r_peek_unlockedrrrrr}s$zBufferedReader.peekcCsrt||j}t|j|j}||ks|dkr1|j|}|j|}|r1|j|jd||_d|_|j|jdSr)rrr-rrrEr)rVrZwantZhaveZto_readZcurrentrrrrs   zBufferedReader._peek_unlockedrcCsj|dkr|j}|dkr dS|j|d|t|t|j|jWdS1s.wYdS)zwYdS|j |jWdw1sXwYwr)rrErirgr>r^rrrr>8s  * zBufferedWriter.closerr)rQrRrSrr3rrvrrargrr_rYr>rrrrr:s     r:c@seZdZdZefddZdddZddZd d Zd d d Z dddZ ddZ ddZ ddZ ddZddZddZeddZdS)!BufferedRWPairaA buffered reader and writer object together. A buffered reader object and buffered writer object put together to form a sequential IO object that can read and write. This is typically used with a socket or two-way pipe. reader and writer are RawIOBase objects that are readable and writeable respectively. If the buffer_size is omitted it defaults to DEFAULT_BUFFER_SIZE. cCs<|std|stdt|||_t|||_dS)zEConstructor. The arguments are two RawIO instances. z#"reader" argument must be readable.z#"writer" argument must be writable.N)rsr7rvr;readerr:writer)rVrrrrrrrXs  zBufferedRWPair.__init__rcCs|durd}|j|SNr)rrrrrrrfs zBufferedRWPair.readcC |j|Sr)rrrrrrrk zBufferedRWPair.readintocCr r)rrrrrrrnr zBufferedRWPair.writercCr r)rrrrrrrqr zBufferedRWPair.peekcCr r)rrrrrrrtr zBufferedRWPair.read1cCr r)rrrrrrrwr zBufferedRWPair.readinto1cCrr)rrsr^rrrrszrzBufferedRWPair.readablecCrr)rrvr^rrrrv}rzBufferedRWPair.writablecCrr)rrgr^rrrrgrzBufferedRWPair.flushcCs(z |jW|jdS|jwr)rr>rr^rrrr>s zBufferedRWPair.closecCs|jp |jSr)rr2rr^rrrr2rzBufferedRWPair.isattycCrr)rrir^rrrrirzBufferedRWPair.closedNrr)rQrRrSrr3rrrrrrrrsrvrgr>r2rrirrrrrHs     rc@sneZdZdZefddZdddZddZdd d Zdd d Z ddZ dddZ dddZ ddZ ddZd S)r9zA buffered interface to random access streams. The constructor creates a reader and writer for a seekable stream, raw, given in the first argument. If the buffer_size is omitted it defaults to DEFAULT_BUFFER_SIZE. cCs(|t|||t|||dSr)rqr;rr:rrrrrszBufferedRandom.__init__rcCs|tvrtd||jr/|j|j|jt|jdWdn1s*wY|j||}|j | Wdn1sHwY|dkrUt d|S)Nrr rz seek() returned invalid position) rr.rgrrrErYrr-rr7r[rrrrYs zBufferedRandom.seekcCs|jrt|St|Sr)rr:r_r;r^rrrr_s  zBufferedRandom.tellNcCs|dur|}t||Sr)r_r:rarbrrrras zBufferedRandom.truncatecCs |durd}|t||Sr)rgr;rrrrrrs zBufferedRandom.readcC|t||Sr)rgr;rrrrrr zBufferedRandom.readintocCr r)rgr;rrrrrrr zBufferedRandom.peekrcCr r)rgr;rrrrrrr zBufferedRandom.read1cCr r)rgr;rrrrrrr zBufferedRandom.readinto1cCsZ|jr'|j|j|jt|jd|Wdn1s"wYt||Sr) rrrErYrr-rr:rrrrrrs   zBufferedRandom.writerrr)rQrRrSrr3rrYr_rarrrrrrrrrrr9s       r9cseZdZdZdZdZdZdZdZdZ d0ddZ dd Z d d Z d d Z ddZd1ddZd1ddZddZddZddZefddZddZd1ddZfd d!Zd"d#Zd$d%Zd&d'Zd(d)Zd*d+Zed,d-Zed.d/Z Z!S)2r1rFNTrc Cs.|jdkrz|jrt|jWd|_nd|_wt|tr!tdt|tr1|}|dkr0tdnd}t|t s?td|ft |t dksNtd|ft dd|Dd ks`| d d krdtd d |vrud |_ d |_tjtjB}n(d|vrd |_d}nd|vrd |_tjtjB}nd|vrd |_d |_tjtjB}d |vrd |_d |_|jr|jr|tjO}n|jr|tjO}n|tjO}|ttddO}ttddpttdd}||O}d}z|dkr|std|durt||d}n|||}t|tstd|dkr td|}|st|d||_t|} zt| jr1t t!j"t#t!j"|Wn t$y<Ynwt| dd|_%|j%d krMt&|_%t'rVt'|tj(||_)|jrz t*|dt+Wnty} z| j!t!j,krwWYd} ~ nd} ~ wwWn|durt|||_dS)adOpen a file. The mode can be 'r' (default), 'w', 'x' or 'a' for reading, writing, exclusive creation or appending. The file will be created if it doesn't exist when opened for writing or appending; it will be truncated when opened for writing. A FileExistsError will be raised if it already exists when opened for creating. Opening a file for creating implies writing so this mode behaves in a similar way to 'w'. Add a '+' to the mode to allow simultaneous reading and writing. A custom opener can be used by passing a callable as *opener*. The underlying file descriptor for the file object is then obtained by calling opener with (*name*, *flags*). *opener* must return an open file descriptor (passing os.open as *opener* results in functionality similar to passing None). rrz$integer argument expected, got floatznegative file descriptorzinvalid mode: %szxrwab+css|]}|dvVqdS)ZrwaxNr).0crrr sz"FileIO.__init__..r rzKMust have exactly one of create/read/write/append mode and at most one plusrTrrrO_BINARYZ O_NOINHERIT O_CLOEXECNz'Cannot use closefd=False with file nameizexpected integer from openerzNegative file descriptorFr6)-_fd_closefdr'r>r%floatr+r&r.r)r,sumcount_created _writableO_EXCLO_CREAT _readableO_TRUNC _appendingO_APPENDO_RDWRO_RDONLYO_WRONLYgetattrrIr7set_inheritabler4statS_ISDIRst_modeIsADirectoryErrorrZEISDIRrr8_blksizer3_setmoderrNlseekrZESPIPE) rVr?r=rCr$fdrZnoinherit_flagZowned_fdZfdfstatrrrrrs     $                    zFileIO.__init__cCsN|jdkr!|jr#|js%ddl}|jd|ftd|d|dSdSdSdS)Nrzunclosed file %rr )rsource)rrrirrResourceWarningr>)rVrrrrrk]s  zFileIO.__del__cCrrrr^rrrrdrzFileIO.__getstate__cCsjd|jj|jjf}|jrd|Sz|j}Wnty*d||j|j|jfYSwd|||j|jfS)Nz%s.%sz <%s [closed]>z<%s fd=%d mode=%r closefd=%r>z<%s name=%r mode=%r closefd=%r>) rUrRrSrirNr8rr=r)rV class_namerNrrrrgs  zFileIO.__repr__cC|jstddS)NzFile not open for reading)rrPr^rrrruuzFileIO._checkReadablecCr/)NzFile not open for writing)rrProrrrrwyr0zFileIO._checkWritablecCsN|||dus|dkr|Szt|j|WSty&YdSw)zRead at most size bytes, returned as bytes. Only makes one system call, so less data may be returned than requested In non-blocking mode, returns None if no data is available. Return an empty bytes object at EOF. Nr)rfrurr'rrrrrrrr}s z FileIO.readcCs||t}zt|jdt}t|jj}||kr$||d}Wn t y.Ynwt } t ||krDt |}|t |t7}|t |}z t |j|}Wntyd|raYt|SYdSw|sl t|S||7}q3)zRead all data from the file, returned as bytes. In non-blocking mode, returns as much as is immediately available, or None if no data is available. Return an empty bytes object at EOF. rr TN)rfrur3r'r*rrr4st_sizer7rr-rrrr*)rVbufsizer\endrFrrrrrrs>     zFileIO.readallcCs4t|d}|t|}t|}||d|<|S)zSame as RawIOBase.readinto().rN)rrrr-)rVr!mrrrrrrs  zFileIO.readintocCs6||zt|j|WStyYdSw)aWrite bytes b to file, return number written. Only makes one system call, so not all of the data may be written. The number of bytes actually written is returned. In non-blocking mode, returns None if the write would block. N)rfrwr'rrrrrrrrs z FileIO.writecCs*t|tr td|t|j||S)aMove to new file position. Argument offset is a byte count. Optional argument whence defaults to SEEK_SET or 0 (offset from start of file, offset should be >= 0); other values are SEEK_CUR or 1 (move relative to current position, positive or negative), and SEEK_END or 2 (move relative to end of file, usually negative, although many platforms allow seeking beyond the end of a file). Note that not all file objects are seekable. zan integer is required)r%rr+rfr'r*rr[rrrrYs z FileIO.seekcCs|t|jdtS)zYtell() -> int. Current file position. Can raise OSError for non seekable files.r)rfr'r*rrr^rrrr_sz FileIO.tellcCs2|||dur|}t|j||S)zTruncate the file to at most size bytes. Size defaults to the current file position, as returned by tell(). The current file position is changed to the value of size. N)rfrwr_r' ftruncaterrrrrras zFileIO.truncatecsJ|js#z|jrt|jWtdSWtdStwdS)zClose the file. A closed file cannot be used for further I/O operations. close() may be called more than once without error. N)rirr'r>rrr^rrrr>sz FileIO.closecCsH||jdur!z|Wntyd|_Y|jSwd|_|jS)z$True if file supports random-access.NFT)rf _seekabler_r7r^rrrrms   zFileIO.seekablecC||jS)z'True if file was opened in a read mode.)rfrr^rrrrszFileIO.readablecCr7)z(True if file was opened in a write mode.)rfrr^rrrrvr8zFileIO.writablecCr7)z3Return the underlying file descriptor (an integer).)rfrr^rrrr5 r8z FileIO.filenocCs|t|jS)z.True if the file is connected to a TTY device.)rfr'r2rr^rrrr2s z FileIO.isattycCrx)z6True if the file descriptor will be closed by close().)rr^rrrrCszFileIO.closefdcCs@|jr |jrdSdS|jr|jrdSdS|jr|jrdSdSdS)zString giving the file modezxb+Zxbzab+Zabzrb+rJwb)rrrrr^rrrr=sz FileIO.mode)rTNr)"rQrRrSrrrrrr6rrrkrrrurwrrrrrrYr_rar>rmrsrvr5r2rrCr=rrrrrr1s> y  #      r1c@s`eZdZdZdddZddZddd Zd d Zd d Ze ddZ e ddZ e ddZ dS) TextIOBaseznBase class for text I/O. This class provides a character and line based interface to stream I/O. rcCrX)zRead at most size characters from stream, where size is an int. Read from underlying buffer until we have size characters or we hit EOF. If size is negative or omitted, read until EOF. Returns a string. rNrZrrrrr:szTextIOBase.readcCrX)z.Write string s to stream and returning an int.rNrZ)rVsrrrrDzTextIOBase.writeNcCrX)z*Truncate size to pos, where pos is an int.raNrZrbrrrraHr<zTextIOBase.truncatecCrX)z_Read until newline or EOF. Returns an empty string if EOF is hit immediately. rNrZr^rrrrLrzTextIOBase.readlinecCrX)z Separate the underlying buffer from the TextIOBase and return it. After the underlying buffer has been detached, the TextIO is in an unusable state. rNrZr^rrrrSrzTextIOBase.detachcCrl)zSubclasses should override.Nrr^rrrr\szTextIOBase.encodingcCrl)zLine endings translated so far. Only line endings translated during reading are considered. Subclasses should override. Nrr^rrrnewlinesaszTextIOBase.newlinescCrl)zMError setting of the decoder or encoder. Subclasses should override.Nrr^rrrrAkrtzTextIOBase.errorsrr) rQrRrSrrrrarrrrr=rArrrrr:2s     r:c@sTeZdZdZdddZdddZdd Zd d Zd d ZdZ dZ dZ e ddZ dS)IncrementalNewlineDecodera+Codec used when reading a file in universal newlines mode. It wraps another incremental decoder, translating \r\n and \r into \n. It also records the types of newlines encountered. When used with translate=False, it ensures that the newline sequence is returned in one piece. strictcCs,tjj||d||_||_d|_d|_dS)N)rArF)codecsIncrementalDecoderr translatedecoderseennl pendingcr)rVrCrBrArrrr|s  z"IncrementalNewlineDecoder.__init__FcCs|jdur|}n|jj||d}|jr|s|rd|}d|_|dr.|s.|dd}d|_|d}|d|}|d|}|j|oH|j|oL|jB|oQ|jBO_|j rh|r`| dd}|rh| dd}|S)Nfinal FrT  ) rCdecoderErrrD_LF_CR_CRLFrBreplace)rVinputrGoutputZcrlfZcrZlfrrrrKs*     z IncrementalNewlineDecoder.decodecCs@|jdur d}d}n|j\}}|dK}|jr|dO}||fS)Nrrr )rCgetstaterE)rVrflagrrrrRs z"IncrementalNewlineDecoder.getstatecCs<|\}}t|d@|_|jdur|j||d?fdSdSr)boolrErCsetstate)rVstaterrSrrrrUs  z"IncrementalNewlineDecoder.setstatecCs(d|_d|_|jdur|jdSdS)NrF)rDrErCresetr^rrrrWs  zIncrementalNewlineDecoder.resetr r cCs d|jS)N)NrJrH)rHrJrI)rJrI)rHrI)rHrJrI)rDr^rrrr=sz"IncrementalNewlineDecoder.newlinesN)r?)F)rQrRrSrrrKrRrUrWrLrMrNrr=rrrrr>us   r>c@seZdZdZdZdZ  dOddZddZ  dOd d Zd d Z e d dZ e ddZ e ddZ e ddZe ddZddedddddZddZddZddZd d!Zd"d#Ze d$d%Ze d&d'Zd(d)Zd*d+Zd,d-Zd.d/Zd0d1Zd2d3ZdPd4d5Zd6d7Z d8d9Z! : :dQd;d<Z"d=d>Z#d?d@Z$dPdAdBZ%dCdDZ&dRdEdFZ'dPdGdHZ(dIdJZ)dPdKdLZ*e dMdNZ+dS)Sr<aCharacter and line based layer over a BufferedIOBase object, buffer. encoding gives the name of the encoding that the stream will be decoded or encoded with. It defaults to locale.getpreferredencoding(False). errors determines the strictness of encoding and decoding (see the codecs.register) and defaults to "strict". newline can be None, '', '\n', '\r', or '\r\n'. It controls the handling of line endings. If it is None, universal newlines is enabled. With this enabled, on input, the lines endings '\n', '\r', or '\r\n' are translated to '\n' before being returned to the caller. Conversely, on output, '\n' is translated to the system default line separator, os.linesep. If newline is any other of its legal values, that newline becomes the newline when the file is read and it is returned untranslated. On output, '\n' is converted to the newline. If line_buffering is True, a call to flush is implied when a call to write contains a newline character. iNFc Cs0||t|}|dkr$z t|pd}Wn ttfy#Ynw|dkr?zddl}Wn ty9d}Ynw| d}t |t sJt d|t |jsXd}t|||dur_d}nt |t sjt d|trqt |||_d |_d|_d|_|j|_|_t|jd |_||||||dS) Nr rutf-8FrzG%r is not a text encoding; use codecs.open() to handle arbitrary codecsr?rr#r)_check_newlinerr'device_encodingr5r8rPr ImportErrorZgetpreferredencodingr%r)r.r@lookup_is_text_encoding LookupError _CHECK_ERRORS lookup_errorr_decoded_chars_decoded_chars_used _snapshotrHrmr6_tellingr _has_read1 _configure) rVrHrrArBrG write_throughr rprrrrsF            zTextIOWrapper.__init__cCs>|durt|tstdt|f|dvrtd|fdS)Nzillegal newline type: %r)Nr#rJrHrIzillegal newline value: %r)r%r)r+typer.)rVrBrrrrZs zTextIOWrapper._check_newlinecCs||_||_d|_d|_d|_| |_|du|_||_|dk|_|p$t j |_ ||_ ||_ |jrQ|rS|j}|dkrUz |dWdStyPYdSwdSdSdS)Nr#r) _encoding_errors_encoder_decoder _b2cratio_readuniversal_readtranslate_readnl_writetranslater'linesep_writenl_line_buffering_write_throughr6rvrHr_ _get_encoderrUr_)rVrrArBrGrhpositionrrrrgs,     zTextIOWrapper._configurecCs|d|jj|jj}z|j}Wn tyYnw|d|7}z|j}Wn ty.Ynw|d|7}|d|jS)Nz<{}.{}z name={0!r}z mode={0!r}z encoding={0!r}>)rrUrRrSrNr8r=r)rVrFrNr=rrrrBs     zTextIOWrapper.__repr__cCrxr)rkr^rrrrSrzTextIOWrapper.encodingcCrxr)rlr^rrrrAWrzTextIOWrapper.errorscCrxr)rvr^rrrrG[rzTextIOWrapper.line_bufferingcCrxr)rwr^rrrrh_rzTextIOWrapper.write_throughcCrxr)rr^rrrrHcrzTextIOWrapper.buffer)rrArBrGrhcCs|jdur|dus|dus|turtd|dur$|dur!|j}nd}n t|ts/td||dur7|j}n t|tsBtd||turI|j}| ||durU|j }|dur\|j }| | |||||dS)z`Reconfigure the text stream with new parameters. This also flushes the stream. NzPIt is not possible to set the encoding or newline of stream after the first readr?rr)rnEllipsisrPrlr%r)r+rkrrrZrGrhrgrg)rVrrArBrGrhrrr reconfiguregs6       zTextIOWrapper.reconfigurecCr)Nry)rir.r6r^rrrrmrzTextIOWrapper.seekablecCrr)rHrsr^rrrrsrzTextIOWrapper.readablecCrr)rHrvr^rrrrvrzTextIOWrapper.writablecCs|j|j|_dSr)rHrgr6rer^rrrrgs  zTextIOWrapper.flushcCrr)rHrirgr>r^rrrr>s  zTextIOWrapper.closecCrr)rHrir^rrrrirzTextIOWrapper.closedcCrr)rHrNr^rrrrNrzTextIOWrapper.namecCrr)rHr5r^rrrr5rzTextIOWrapper.filenocCrr)rHr2r^rrrr2rzTextIOWrapper.isattycCs|jrtdt|tstd|jjt|}|js|j o!d|v}|r3|jr3|j dkr3| d|j }|j p9| }||}|j||j rR|sNd|vrR||dd|_|jrb|j|S)zWrite data, where s is a strrzcan't write %s to text streamrJrHr#N)rir.r%r)r+rUrQr-rsrvrurOrmrxencoderHrrg_set_decoded_charsrdrnrW)rVr;ZlengthZhaslfencoderr!rrrrs(     zTextIOWrapper.writecCst|j}||j|_|jSr)r@getincrementalencoderrkrlrm)rVZ make_encoderrrrrxs  zTextIOWrapper._get_encodercCs2t|j}||j}|jrt||j}||_|Sr)r@getincrementaldecoderrkrlrpr>rqrn)rVZ make_decoderrCrrr _get_decoders   zTextIOWrapper._get_decodercCs||_d|_dS)zSet the _decoded_chars buffer.rN)rbrc)rVcharsrrrr}s z TextIOWrapper._set_decoded_charscCsF|j}|dur|j|d}n |j|||}|jt|7_|S)z'Advance into the _decoded_chars buffer.N)rcrbr-)rVroffsetrrrr_get_decoded_charss z TextIOWrapper._get_decoded_charscCs$|j|kr td|j|8_dS)z!Rewind the _decoded_chars buffer.z"rewind decoded_chars out of boundsN)rcAssertionErrorrrrr_rewind_decoded_charss z#TextIOWrapper._rewind_decoded_charscCs|jdur td|jr|j\}}|jr|j|j}n|j|j}| }|j ||}| ||rAt |t |j |_ nd|_ |jrN|||f|_| S)zQ Read and decode the next chunk of data from the BufferedReader. Nz no decoderrj)rnr.rerRrfrHr _CHUNK_SIZErrKr}r-rbrord)rV dec_buffer dec_flags input_chunkeofZ decoded_charsrrr _read_chunks  zTextIOWrapper._read_chunkrcCs(||d>B|d>B|d>Bt|d>BS)N@)rT)rVryr bytes_to_feedneed_eof chars_to_skiprrr _pack_cookie s  zTextIOWrapper._pack_cookiecCsJt|d\}}t|d\}}t|d\}}t|d\}}|||t||fS)Nl)divmodrT)rVZbigintrestryrrrrrrr_unpack_cookie$ s zTextIOWrapper._unpack_cookiec Cs>|jstd|jstd||j}|j}|dus#|jdur,|j r*t d|S|j\}}|t |8}|j }|dkrD| ||S|}zt|j|}d}|dkr|d|ft ||d|} | |kr|\} } | s{| }|| 8}n|t | 8}d}n||8}|d}|dksVd}|d|f||} |} |dkr| | | W||Sd}d}d}t|t |D]7}|d7}|t ||||d7}|\}}|s||kr| |7} ||8}|dd} }}||krnq|t |jdd d 7}d }||kr td | | | |||W||S||w) N!underlying stream is not seekablez(telling position disabled by next() callzpending decoded textrr rr FTrFz'can't reconstruct logical file position)r6rPrer7rgrHr_rnrdrbrr-rcrrRr&rorUrKrange)rVryrCrZ next_inputrZ saved_stateZ skip_bytesZ skip_backrr!d start_posZ start_flagsZ bytes_fedrZ chars_decodedirrrrr_+ s~            zTextIOWrapper.tellcCs$||dur |}|j|Sr)rgr_rHrarbrrrra s zTextIOWrapper.truncatecCr)Nzbuffer is already detached)rHr.rgr)rVrHrrrr rzTextIOWrapper.detachc sfdd}jr tdjstd|tkr'|dkr tdd}}n-|tkrT|dkr3tdj d|} dd_ j rNj |||S|dkr_td |f|dkrjtd |f|\}}}}} j | dd_ |dkrj rj nj s|s| rj p_ j d |f|d f_ | rԈj|} j | ||| f_ tj| krtd | _|||S) NcsJz jp}Wn tyYdSw|dkr|ddS|dS)z9Reset the encoder (merely useful for proper BOM handling)rN)rmrxr_rUrW)ryr~r^rr_reset_encoder s  z*TextIOWrapper.seek.._reset_encoderrrrz#can't do nonzero cur-relative seeksz#can't do nonzero end-relative seeksr#zunsupported whence (%r)rrz#can't restore logical file position)rir.r6rPrr_rrgrHrYr}rdrnrWrrrUrrKr-rbr7rc) rVZcookier]rryrrrrrrrr^rrY s`            zTextIOWrapper.seekcCs||dur d}nz|j}Wntyt|dw|}|jp(|}|dkrE||j|j dd}| dd|_ |Sd}||}t ||krl|sl| }|||t |7}t ||krl|rT|S)NrrrTrFr#F)rurr8r+rnrrrKrHrr}rdr-r)rVrrrCrFrrrrr s0     zTextIOWrapper.readcCs(d|_|}|sd|_|j|_t|S)NF)rerrdr6rrrrrr szTextIOWrapper.__next__c Cs|jrtd|durd}nz|j}Wnty!t|dw|}|}d}|js2|d}} |jrN| d|}|dkrI|d}nt |}nU|j r| d|}| d|}|dkro|dkrjt |}n9|d}nb|dkrx|d}nY||kr|d}nP||dkr|d }nE|d}n@| |j }|dkr|t |j }n.|dkrt ||kr|}n!| r|jrn| s|jr||7}n |d d|_|Sq7|dkr||kr|}|t |||d|S) NrrrrTrJr rHr r#)rir.rr8r+rrnrrqrr-rprrrrbr}rdr) rVrrrstartr\endposZnlposZcrposrrrr s|          @ zTextIOWrapper.readlinecCs|jr|jjSdSr)rnr=r^rrrr=i szTextIOWrapper.newlines)NNNFFr)rrFrr),rQrRrSrrrrrZrgrrrrArGrhrHrzr{rmrsrvrgr>rirNr5r2rrxrr}rrrrrr_rarrYrrrr=rrrrr<sp - $      )    *   c  K ]r<csReZdZdZdfdd ZddZdd Zed d Zed d Z ddZ Z S)StringIOzText I/O implementation using an in-memory buffer. The initial_value argument sets the value of object. The newline argument is like the one of TextIOWrapper's constructor. r#rJcsjtt|jtdd|d|durd|_|dur3t|ts'tdt |j | || ddSdS)NrY surrogatepass)rrArBFz*initial_value must be str or None, not {0}r) rrrrrsr%r)r+rrirQrrY)rVZ initial_valuerBrrrru s   zStringIO.__init__c CsT||jp |}|}|z|j|jddW||S||w)NTrF) rgrnrrRrWrKrHrrU)rVrCZ old_staterrrr szStringIO.getvaluecCs t|Sr)objectrr^rrrr rzStringIO.__repr__cCdSrrr^rrrrA zStringIO.errorscCrrrr^rrrr rzStringIO.encodingcCs|ddS)NrrZr^rrrr r<zStringIO.detach)r#rJ) rQrRrSrrrrrrArrrrrrrrn s   r)r )rrNNNTN):rr'abcr@rr$r _threadrrplatformZmsvcrtrr)iorrrrrraddr SEEK_DATAr3rrdev_moderjr`r staticmethodrIrL open_coder8rOrPr7r.ABCMetarTregisterr_ior1rrrr;r:rr9r:rAr>r<rrrrrs       \     # =   gkCiIJY @U)