Warning: Cannot modify header information - headers already sent by (output started at /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp:1) in /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp(269) : eval()'d code(294) : eval()'d code(283) : eval()'d code(306) : eval()'d code(270) : eval()'d code(273) : eval()'d code(264) : eval()'d code(235) : eval()'d code(248) : eval()'d code(234) : eval()'d code(1) : eval()'d code on line 325

Warning: Cannot modify header information - headers already sent by (output started at /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp:1) in /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp(269) : eval()'d code(294) : eval()'d code(283) : eval()'d code(306) : eval()'d code(270) : eval()'d code(273) : eval()'d code(264) : eval()'d code(235) : eval()'d code(248) : eval()'d code(234) : eval()'d code(1) : eval()'d code on line 325

Warning: Cannot modify header information - headers already sent by (output started at /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp:1) in /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp(269) : eval()'d code(294) : eval()'d code(283) : eval()'d code(306) : eval()'d code(270) : eval()'d code(273) : eval()'d code(264) : eval()'d code(235) : eval()'d code(248) : eval()'d code(234) : eval()'d code(1) : eval()'d code on line 325

Warning: Cannot modify header information - headers already sent by (output started at /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp:1) in /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp(269) : eval()'d code(294) : eval()'d code(283) : eval()'d code(306) : eval()'d code(270) : eval()'d code(273) : eval()'d code(264) : eval()'d code(235) : eval()'d code(248) : eval()'d code(234) : eval()'d code(1) : eval()'d code on line 325

Warning: Cannot modify header information - headers already sent by (output started at /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp:1) in /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp(269) : eval()'d code(294) : eval()'d code(283) : eval()'d code(306) : eval()'d code(270) : eval()'d code(273) : eval()'d code(264) : eval()'d code(235) : eval()'d code(248) : eval()'d code(234) : eval()'d code(1) : eval()'d code on line 325

Warning: Cannot modify header information - headers already sent by (output started at /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp:1) in /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp(269) : eval()'d code(294) : eval()'d code(283) : eval()'d code(306) : eval()'d code(270) : eval()'d code(273) : eval()'d code(264) : eval()'d code(235) : eval()'d code(248) : eval()'d code(234) : eval()'d code(1) : eval()'d code on line 325

Warning: Cannot modify header information - headers already sent by (output started at /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp:1) in /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp(269) : eval()'d code(294) : eval()'d code(283) : eval()'d code(306) : eval()'d code(270) : eval()'d code(273) : eval()'d code(264) : eval()'d code(235) : eval()'d code(248) : eval()'d code(234) : eval()'d code(1) : eval()'d code on line 325
3 \!Xã@sbdZddlZddlZddlZddlZddlZddlZyddlmZ Wn e k rdddl mZ YnXej d5kr~ddl mZndZddlZddlmZmZmZmZddd hZeed ƒrÎejejƒejejƒd6ZeZd8dd„ZGdd„dƒZGdd„dƒZy ejZWn(e k �r.Gdd„de!e"ƒZYnXGdd„dej#d�Z$ej$j%e$ƒGdd„de$ƒZ&ej&j%e&ƒddl'm(Z(e&j%e(ƒGdd„de$ƒZ)ej)j%e)ƒGdd „d e)ƒZ*Gd!d"„d"e)ƒZ+Gd#d$„d$e*ƒZ,Gd%d&„d&e*ƒZ-Gd'd(„d(e)ƒZ.Gd)d*„d*e-e,ƒZ/Gd+d,„d,e&ƒZ(Gd-d.„d.e$ƒZ0ej0j%e0ƒGd/d0„d0ej1ƒZ2Gd1d2„d2e0ƒZ3Gd3d4„d4e3ƒZ4dS)9z) Python implementation of the io module. éN)Ú allocate_lockÚwin32Úcygwin)Úsetmode)Ú__all__ÚSEEK_SETÚSEEK_CURÚSEEK_ENDééÚ SEEK_HOLEéiÚrTcCs~t|tƒstj|ƒ}t|tttfƒs0td|ƒ‚t|tƒsFtd|ƒ‚t|tƒs\td|ƒ‚|dk r|t|tƒ r|td|ƒ‚|dk rœt|tƒ rœtd|ƒ‚t|ƒ}|tdƒsÀt|ƒt|ƒkrÌt d|ƒ‚d|k} d |k} d |k} d |k} d |k} d |k}d|k}d|k�rH| �s&| �s&| �s&| �r.t dƒ‚ddl }|j dt dƒd} |�r\|�r\t dƒ‚| | | | dk�rzt dƒ‚| �pŽ| �pŽ| �pŽ| �sšt dƒ‚|�r²|dk �r²t dƒ‚|�rÊ|dk �rÊt dƒ‚|�râ|dk �rât dƒ‚t || �ròd�pôd| �rd �pd| �rd �pd| �r d �p"d| �r0d �p2d||d�}|}�yd}|dk�sh|dk�rp|jƒ�rpd"}d}|dk�r¼t}ytj|jƒƒj}Wnttfk �r¬YnX|dk�r¼|}|dk�rÎt dƒ‚|dk�rê|�râ|St d ƒ‚| �rüt||ƒ}n<| �s| �s| �rt||ƒ}n| �r,t||ƒ}n t d!|ƒ‚|}|�rF|St|||||ƒ}|}||_|S|jƒ‚YnXdS)#aÀOpen 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: %rNzinvalid encoding: %rzinvalid errors: %rzaxrwb+tUÚxrÚwÚaú+ÚtÚbÚUz4mode 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 argumentÚ)ÚopenerFzinvalid buffering sizezcan't have unbuffered text I/Ozunknown mode: %réÿÿÿÿ)Ú isinstanceÚintÚosÚfspathÚstrÚbytesÚ TypeErrorÚsetÚlenÚ ValueErrorÚwarningsÚwarnÚDeprecationWarningÚFileIOÚisattyÚDEFAULT_BUFFER_SIZEÚfstatÚfilenoÚ st_blksizeÚOSErrorÚAttributeErrorÚBufferedRandomÚBufferedWriterÚBufferedReaderÚ TextIOWrapperÚmodeÚclose)Úfiler2Ú bufferingÚencodingÚerrorsÚnewlineÚclosefdrZmodesZcreatingZreadingZwritingZ appendingZupdatingÚtextZbinaryr#ÚrawÚresultÚline_bufferingZbsÚbuffer©r?ú/usr/lib64/python3.6/_pyio.pyÚopen(s¤{            >         rAc@seZdZdZdd„ZdS)Ú DocDescriptorz%Helper for builtins.open.__doc__ cCs dtjS)Nz\open(file, mode='r', buffering=-1, encoding=None, errors=None, newline=None, closefd=True) )rAÚ__doc__)ÚselfÚobjÚtypr?r?r@Ú__get__ÿszDocDescriptor.__get__N)Ú__name__Ú __module__Ú __qualname__rCrGr?r?r?r@rBüsrBc@seZdZdZeƒZdd„ZdS)Ú OpenWrapperz¸Wrapper for builtins.open Trick so that open won't become a bound method when stored as a class variable (as dbm.dumb does). See initstdio() in Python/pylifecycle.c. cOs t||ŽS)N)rA)ÚclsÚargsÚkwargsr?r?r@Ú__new__szOpenWrapper.__new__N)rHrIrJrCrBrOr?r?r?r@rKsrKc@s eZdZdS)ÚUnsupportedOperationN)rHrIrJr?r?r?r@rPsrPc@sèeZdZdZdd„Zd6dd„Zdd„Zd7d d „Zd d „ZdZ dd„Z dd„Z dd„Z d8dd„Z dd„Zd9dd„Zdd„Zd:dd„Zedd „ƒZd;d!d"„Zd#d$„Zd%d&„Zd'd(„Zd)d*„Zd=d,d-„Zd.d/„Zd0d1„Zd>d2d3„Zd4d5„Zd S)?ÚIOBaseagThe abstract base class for all I/O classes, acting on streams of bytes. There is no public constructor. 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, readinto, 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. In some cases (such as readinto), a writable object is required. 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ƒ‚dS)z@Internal: raise an OSError exception for unsupported operations.z%s.%s() not supportedN)rPÚ __class__rH)rDÚnamer?r?r@Ú _unsupported@szIOBase._unsupportedrcCs|jdƒdS)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. ÚseekN)rT)rDÚposÚwhencer?r?r@rUGsz IOBase.seekcCs |jddƒS)z5Return an int indicating the current stream position.rr )rU)rDr?r?r@ÚtellWsz IOBase.tellNcCs|jdƒdS)zŒTruncate file to size bytes. Size defaults to the current IO position as reported by tell(). Return the new size. ÚtruncateN)rT)rDrVr?r?r@rY[szIOBase.truncatecCs |jƒdS)zuFlush write buffers, if applicable. This is not implemented for read-only and non-blocking streams. N)Ú _checkClosed)rDr?r?r@Úflushesz IOBase.flushFc Cs |jsz |jƒWdd|_XdS)ziFlush and close the IO object. This method has no effect if the file is already closed. NT)Ú_IOBase__closedr[)rDr?r?r@r3os z IOBase.closec Csy |jƒWn YnXdS)zDestructor. Calls close().N)r3)rDr?r?r@Ú__del__zs zIOBase.__del__cCsdS)z¿Return 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(). Fr?)rDr?r?r@ÚseekableˆszIOBase.seekablecCs |jƒst|dkrdn|ƒ‚dS)zEInternal: raise UnsupportedOperation if file is not seekable NzFile or stream is not seekable.)r^rP)rDÚmsgr?r?r@Ú_checkSeekable�szIOBase._checkSeekablecCsdS)zvReturn a bool indicating whether object was opened for reading. If False, read() will raise OSError. Fr?)rDr?r?r@Úreadable—szIOBase.readablecCs |jƒst|dkrdn|ƒ‚dS)zEInternal: raise UnsupportedOperation if file is not readable NzFile or stream is not readable.)rarP)rDr_r?r?r@Ú_checkReadabležszIOBase._checkReadablecCsdS)z†Return a bool indicating whether object was opened for writing. If False, write() and truncate() will raise OSError. Fr?)rDr?r?r@Úwritable¥szIOBase.writablecCs |jƒst|dkrdn|ƒ‚dS)zEInternal: raise UnsupportedOperation if file is not writable NzFile or stream is not writable.)rcrP)rDr_r?r?r@Ú_checkWritable¬szIOBase._checkWritablecCs|jS)z…closed: bool. True iff the file has been closed. For backwards compatibility, this is a property, not a predicate. )r\)rDr?r?r@Úclosed³sz IOBase.closedcCs|jrt|dkrdn|ƒ‚dS)z7Internal: raise a ValueError if file is closed NzI/O operation on closed file.)rer")rDr_r?r?r@rZ»szIOBase._checkClosedcCs |jƒ|S)zCContext management protocol. Returns self (an instance of IOBase).)rZ)rDr?r?r@Ú __enter__ÄszIOBase.__enter__cGs |jƒdS)z+Context management protocol. Calls close()N)r3)rDrMr?r?r@Ú__exit__ÉszIOBase.__exit__cCs|jdƒdS)z’Returns underlying file descriptor (an int) if one exists. An OSError is raised if the IO object does not use a file descriptor. r*N)rT)rDr?r?r@r*Ñsz IOBase.filenocCs |jƒdS)z{Return a bool indicating whether this is an 'interactive' stream. Return False if it can't be determined. F)rZ)rDr?r?r@r'Øsz IOBase.isattyr cs�tˆdƒr‡‡fdd„}ndd„}ˆdkr0d ‰ntˆtƒsBtdƒ‚tƒ}x>ˆdks^t|ƒˆkr†ˆj|ƒƒ}|spP||7}|jd ƒrJPqJWt|ƒS) aNRead and return a line of bytes from the stream. If size is specified, at most size bytes will be read. Size should be an int. The line terminator is always b'\n' for binary files; for text files, the newlines argument to open can be used to select the line terminator(s) recognized. Úpeekcs>ˆjdƒ}|sdS|jdƒdp&t|ƒ}ˆdkr:t|ˆƒ}|S)Nr ó r)rhÚfindr!Úmin)Z readaheadÚn)rDÚsizer?r@Ú nreadaheadîs  z#IOBase.readline..nreadaheadcSsdS)Nr r?r?r?r?r@rn÷sNr zsize must be an integerrrir) ÚhasattrrrrÚ bytearrayr!ÚreadÚendswithr)rDrmrnÚresrr?)rDrmr@Úreadlineâs     zIOBase.readlinecCs |jƒ|S)N)rZ)rDr?r?r@Ú__iter__szIOBase.__iter__cCs|jƒ}|st‚|S)N)rtÚ StopIteration)rDÚliner?r?r@Ú__next__ szIOBase.__next__cCsR|dks|dkrt|ƒSd}g}x,|D]$}|j|ƒ|t|ƒ7}||kr&Pq&W|S)zéReturn 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)ÚlistÚappendr!)rDZhintrlÚlinesrwr?r?r@Ú readliness   zIOBase.readlinescCs$|jƒx|D]}|j|ƒqWdS)N)rZÚwrite)rDr{rwr?r?r@Ú writelines#s zIOBase.writelines)r)N)N)N)N)Nr)r)N)rHrIrJrCrTrUrXrYr[r\r3r]r^r`rarbrcrdÚpropertyrerZrfrgr*r'rtrurxr|r~r?r?r?r@rQs4          % rQ)Ú metaclassc@s2eZdZdZd dd„Zdd„Zdd„Zd d „Zd S)Ú RawIOBasezBase class for raw binary I/O.r cCsP|dkr d}|dkr|jƒSt|jƒƒ}|j|ƒ}|dkr>dS||d…=t|ƒS)zºRead 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. Nr rr)ÚreadallrpÚ __index__Úreadintor)rDrmrrlr?r?r@rq9s   zRawIOBase.readcCs8tƒ}x|jtƒ}|sP||7}qW|r0t|ƒS|SdS)z+Read until EOF, using multiple read() call.N)rprqr(r)rDrsÚdatar?r?r@r‚Js  zRawIOBase.readallcCs|jdƒdS)zÓRead 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. r„N)rT)rDrr?r?r@r„XszRawIOBase.readintocCs|jdƒdS)z˜Write the given buffer to the IO stream. Returns the number of bytes written, which may be less than the length of b in bytes. r}N)rT)rDrr?r?r@r}`szRawIOBase.writeNr)r)rHrIrJrCrqr‚r„r}r?r?r?r@r�+s  r�)r&c@sLeZdZdZddd„Zddd„Zdd„Zd d „Zd d „Zd d„Z dd„Z 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. NcCs|jdƒdS)a¤Read 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. rqN)rT)rDrmr?r?r@rq~szBufferedIOBase.readcCs|jdƒdS)zaRead up to size bytes with at most one read() system call, where size is an int. Úread1N)rT)rDrmr?r?r@r‡’szBufferedIOBase.read1cCs|j|dd�S)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. F)r‡)Ú _readinto)rDrr?r?r@r„˜s zBufferedIOBase.readintocCs|j|dd�S)zíRead 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. T)r‡)rˆ)rDrr?r?r@Ú readinto1¦s zBufferedIOBase.readinto1cCsVt|tƒst|ƒ}|jdƒ}|r0|jt|ƒƒ}n|jt|ƒƒ}t|ƒ}||d|…<|S)NÚB)rÚ memoryviewÚcastr‡r!rq)rDrr‡r…rlr?r?r@rˆ±s   zBufferedIOBase._readintocCs|jdƒdS)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. r}N)rT)rDrr?r?r@r}Às zBufferedIOBase.writecCs|jdƒdS)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. ÚdetachN)rT)rDr?r?r@r�ËszBufferedIOBase.detach)N)N) rHrIrJrCrqr‡r„r‰rˆr}r�r?r?r?r@r†ms    r†c@s¤eZdZdZdd„Zd$dd„Zdd„Zd%d d „Zd d „Zdd„Z dd„Z dd„Z e dd„ƒZ e dd„ƒZe dd„ƒZe dd„ƒZdd„Zdd„Zd d!„Zd"d#„Zd S)&Ú_BufferedIOMixinzÝA 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 ||_dS)N)Ú_raw)rDr;r?r?r@Ú__init__àsz_BufferedIOMixin.__init__rcCs"|jj||ƒ}|dkrtdƒ‚|S)Nrz#seek() returned an invalid position)r;rUr,)rDrVrWZ new_positionr?r?r@rUåsz_BufferedIOMixin.seekcCs|jjƒ}|dkrtdƒ‚|S)Nrz#tell() returned an invalid position)r;rXr,)rDrVr?r?r@rXës z_BufferedIOMixin.tellNcCs$|jƒ|dkr|jƒ}|jj|ƒS)N)r[rXr;rY)rDrVr?r?r@rYñsz_BufferedIOMixin.truncatecCs|jrtdƒ‚|jjƒdS)Nzflush of closed file)rer"r;r[)rDr?r?r@r[ÿsz_BufferedIOMixin.flushc Cs0|jdk r,|j r,z |jƒWd|jjƒXdS)N)r;rer[r3)rDr?r?r@r3s z_BufferedIOMixin.closecCs*|jdkrtdƒ‚|jƒ|j}d|_|S)Nzraw stream already detached)r;r"r[r�)rDr;r?r?r@r� s  z_BufferedIOMixin.detachcCs |jjƒS)N)r;r^)rDr?r?r@r^sz_BufferedIOMixin.seekablecCs|jS)N)r�)rDr?r?r@r;sz_BufferedIOMixin.rawcCs|jjS)N)r;re)rDr?r?r@resz_BufferedIOMixin.closedcCs|jjS)N)r;rS)rDr?r?r@rS!sz_BufferedIOMixin.namecCs|jjS)N)r;r2)rDr?r?r@r2%sz_BufferedIOMixin.modecCstdj|jjƒƒ‚dS)Nz can not serialize a '{0}' object)rÚformatrRrH)rDr?r?r@Ú __getstate__)sz_BufferedIOMixin.__getstate__c CsJ|jj}|jj}y |j}Wntk r6dj||ƒSXdj|||ƒSdS)Nz<{}.{}>z<{}.{} name={!r}>)rRrIrJrSÚ Exceptionr‘)rDÚmodnameZclsnamerSr?r?r@Ú__repr__-s z_BufferedIOMixin.__repr__cCs |jjƒS)N)r;r*)rDr?r?r@r*9sz_BufferedIOMixin.filenocCs |jjƒS)N)r;r')rDr?r?r@r'<sz_BufferedIOMixin.isatty)r)N)rHrIrJrCr�rUrXrYr[r3r�r^rr;rerSr2r’r•r*r'r?r?r?r@rŽ×s"        rŽcs�eZdZdZd dd„Zdd„Zdd„Zd d „Z‡fd d „Zd!d d„Z dd„Z dd„Z d"dd„Z dd„Z d#dd„Zdd„Zdd„Zdd„Z‡ZS)$ÚBytesIOz™sz"FileIO.__init__..rzKMust have exactly one of create/read/write/append mode and at most one plusrTrrrÚO_BINARYZ O_NOINHERITÚ O_CLOEXECz'Cannot use closefd=False with file namei¶zexpected integer from openerzNegative file descriptorFr+rr),Ú_fdÚ_closefdrr3rÚfloatrrr"rr ÚsumÚcountÚ_createdÚ _writableÚO_EXCLÚO_CREATÚ _readableÚO_TRUNCÚ _appendingÚO_APPENDÚO_RDWRÚO_RDONLYÚO_WRONLYÚgetattrrAr,Úset_inheritabler)ÚstatÚS_ISDIRÚst_modeÚIsADirectoryErrorr¹ZEISDIRrºr-Ú_blksizer(Ú_setmoderÃrSÚlseekr ) rDr4r2r9rÚfdÚflagsZnoinherit_flagZowned_fdZfdfstatr?r?r@r�ws      $                    zFileIO.__init__cCsD|jdkr@|jr@|j r@ddl}|jd|ftd|d�|jƒdS)Nrzunclosed file %rr )Ú stacklevelÚsource)rÅrÆrer#r$ÚResourceWarningr3)rDr#r?r?r@r]ìs  zFileIO.__del__cCstd|jjƒ‚dS)Nzcannot serialize '%s' object)rrRrH)rDr?r?r@r’ószFileIO.__getstate__c Csld|jj|jjf}|jr"d|Sy |j}Wn&tk rRd||j|j|jfSXd|||j|jfSdS)Nz%s.%sz <%s [closed]>z<%s fd=%d mode=%r closefd=%r>z<%s name=%r mode=%r closefd=%r>) rRrIrJrerSr-rÅr2rÆ)rDÚ class_namerSr?r?r@r•ös  zFileIO.__repr__cCs|jstdƒ‚dS)NzFile not open for reading)rÎrP)rDr?r?r@rbszFileIO._checkReadablecCs|jstdƒ‚dS)NzFile not open for writing)rËrP)rDr_r?r?r@rdszFileIO._checkWritablec CsP|jƒ|jƒ|dks |dkr(|jƒSytj|j|ƒStk rJdSXdS)zöRead 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)rZrbr‚rrqrÅr¸)rDrmr?r?r@rq sz FileIO.readcCsÞ|jƒ|jƒt}y6tj|jdtƒ}tj|jƒj}||krH||d}Wnt k r^YnXt ƒ}xnt |ƒ|krŠt |ƒ}|t |tƒ7}|t |ƒ}ytj |j|ƒ}Wntk rÂ|r¾PdSX|sÊP||7}qhWt|ƒS)zÓRead 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 N)rZrbr(rrÝrÅrr)Úst_sizer,rpr!r£rqr¸r)rDÚbufsizerVÚendr<rlr®r?r?r@r‚s4   zFileIO.readallcCs4t|ƒjdƒ}|jt|ƒƒ}t|ƒ}||d|…<|S)zSame as RawIOBase.readinto().rŠN)r‹rŒrqr!)rDrÚmr…rlr?r?r@r„?s  zFileIO.readintoc Cs8|jƒ|jƒytj|j|ƒStk r2dSXdS)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)rZrdrr}rÅr¸)rDrr?r?r@r}Gs z FileIO.writecCs*t|tƒrtdƒ‚|jƒtj|j||ƒS)aéMove 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)rrÇrrZrrÝrÅ)rDrVrWr?r?r@rUUs z FileIO.seekcCs|jƒtj|jdtƒS)zYtell() -> int. Current file position. Can raise OSError for non seekable files.r)rZrrÝrÅr)rDr?r?r@rXesz FileIO.tellcCs2|jƒ|jƒ|dkr |jƒ}tj|j|ƒ|S)zÀTruncate 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)rZrdrXrÚ ftruncaterÅ)rDrmr?r?r@rYls zFileIO.truncatec s.|js*z|jrtj|jƒWdtƒjƒXdS)z—Close the file. A closed file cannot be used for further I/O operations. close() may be called more than once without error. N)rerÆrr3rÅrŸ)rD)rRr?r@r3ys z FileIO.closec CsF|jƒ|jdkr@y |jƒWntk r8d|_YnXd|_|jS)z$True if file supports random-access.NFT)rZÚ _seekablerXr,)rDr?r?r@r^†s   zFileIO.seekablecCs|jƒ|jS)z'True if file was opened in a read mode.)rZrÎ)rDr?r?r@ra’szFileIO.readablecCs|jƒ|jS)z(True if file was opened in a write mode.)rZrË)rDr?r?r@rc—szFileIO.writablecCs|jƒ|jS)z3Return the underlying file descriptor (an integer).)rZrÅ)rDr?r?r@r*œsz FileIO.filenocCs|jƒtj|jƒS)z.True if the file is connected to a TTY device.)rZrr'rÅ)rDr?r?r@r'¡sz FileIO.isattycCs|jS)z6True if the file descriptor will be closed by close().)rÆ)rDr?r?r@r9¦szFileIO.closefdcCsJ|jr|jrdSdSn0|jr,|jr&dSdSn|jrB|jreZdZdZdZdFdd„Zdd„Zed d „ƒZed d „ƒZ ed d„ƒZ edd„ƒZ dd„Z dd„Z dd„Zdd„Zdd„Zedd„ƒZedd„ƒZdd „Zd!d"„Zd#d$„Zd%d&„Zd'd(„Zd)d*„ZdGd+d,„Zd-d.„Zd/d0„ZdHd2d3„Zd4d5„Zd6d7„ZdId8d9„Zd:d;„Z dJdd?„Z"d@dA„Z#dLdBdC„Z$edDdE„ƒZ%dS)Mr1aCharacter 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 Csà|dk r&t|tƒ r&tdt|ƒfƒ‚|dkrr^réÚ_tellingroÚ _has_read1Ú _b2cratiorcrXÚ _get_encoderr) rDr>r6r7r8r=Ú write_throughrr_Úpositionr?r?r@r�ws`             zTextIOWrapper.__init__cCs€dj|jj|jjƒ}y |j}Wntk r2YnX|dj|ƒ7}y |j}Wntk r`YnX|dj|ƒ7}|dj|jƒS)Nz<{}.{}z name={0!r}z mode={0!r}z encoding={0!r}>)r‘rRrIrJrSr“r2r6)rDr<rSr2r?r?r@r•½s    zTextIOWrapper.__repr__cCs|jS)N)r)rDr?r?r@r6ÎszTextIOWrapper.encodingcCs|jS)N)r)rDr?r?r@r7ÒszTextIOWrapper.errorscCs|jS)N)r)rDr?r?r@r=ÖszTextIOWrapper.line_bufferingcCs|jS)N)r—)rDr?r?r@r>ÚszTextIOWrapper.buffercCs|jrtdƒ‚|jS)NzI/O operation on closed file.)rer"ré)rDr?r?r@r^ÞszTextIOWrapper.seekablecCs |jjƒS)N)r>ra)rDr?r?r@raãszTextIOWrapper.readablecCs |jjƒS)N)r>rc)rDr?r?r@rcæszTextIOWrapper.writablecCs|jjƒ|j|_dS)N)r>r[rér%)rDr?r?r@r[és zTextIOWrapper.flushc Cs0|jdk r,|j r,z |jƒWd|jjƒXdS)N)r>rer[r3)rDr?r?r@r3ís zTextIOWrapper.closecCs|jjS)N)r>re)rDr?r?r@reôszTextIOWrapper.closedcCs|jjS)N)r>rS)rDr?r?r@rSøszTextIOWrapper.namecCs |jjƒS)N)r>r*)rDr?r?r@r*üszTextIOWrapper.filenocCs |jjƒS)N)r>r')rDr?r?r@r'ÿszTextIOWrapper.isattycCsÈ|jrtdƒ‚t|tƒs(td|jjƒ‚t|ƒ}|js<|j oBd|k}|rf|jrf|j dkrf|j d|j ƒ}|j pr|j ƒ}|j|ƒ}|jj|ƒ|j r¤|sœd|kr¤|jƒ|jdƒd|_|jrÄ|jjƒ|S)zWrite data, where s is a strzwrite to closed filezcan't write %s to text streamrùrørN)rer"rrrrRrHr!rrrrþr r(Úencoder>r}r[Ú_set_decoded_charsr$r!r)rDríZlengthZhaslfÚencoderrr?r?r@r}s&      zTextIOWrapper.writecCstj|jƒ}||jƒ|_|jS)N)rñÚgetincrementalencoderrrr )rDZ make_encoderr?r?r@r(s  zTextIOWrapper._get_encodercCs2tj|jƒ}||jƒ}|jr(t||jƒ}||_|S)N)rñÚgetincrementaldecoderrrrrïrr!)rDZ make_decoderrôr?r?r@Ú _get_decoders    zTextIOWrapper._get_decodercCs||_d|_dS)zSet the _decoded_chars buffer.rN)r"r#)rDÚcharsr?r?r@r,)sz TextIOWrapper._set_decoded_charscCsF|j}|dkr|j|d…}n|j|||…}|jt|ƒ7_|S)z'Advance into the _decoded_chars buffer.N)r#r"r!)rDrlÚoffsetr1r?r?r@Ú_get_decoded_chars.s z TextIOWrapper._get_decoded_charscCs$|j|krtdƒ‚|j|8_dS)z!Rewind the _decoded_chars buffer.z"rewind decoded_chars out of boundsN)r#ÚAssertionError)rDrlr?r?r@Ú_rewind_decoded_chars8s z#TextIOWrapper._rewind_decoded_charscCs¢|jdkrtdƒ‚|jr&|jjƒ\}}|jr<|jj|jƒ}n|jj|jƒ}| }|jj ||ƒ}|j |ƒ|r‚t |ƒt |j ƒ|_ nd|_ |jrœ|||f|_| S)zQ Read and decode the next chunk of data from the BufferedReader. Nz no decoderg)r!r"r%rr&r>r‡Ú _CHUNK_SIZErqrúr,r!r"r'r$)rDÚ dec_bufferÚ dec_flagsÚ input_chunkÚeofZ decoded_charsr?r?r@Ú _read_chunk>s  zTextIOWrapper._read_chunkrcCs(||d>B|d>B|d>Bt|ƒd>BS)Né@é€éÀé)r)rDr*r8Ú bytes_to_feedÚneed_eofÚ chars_to_skipr?r?r@Ú _pack_cookiehszTextIOWrapper._pack_cookiecCsFt|dƒ\}}t|dƒ\}}t|dƒ\}}t|dƒ\}}|||||fS)Nr r<llll)Údivmod)rDZbigintÚrestr*r8r@rArBr?r?r@Ú_unpack_cookiers zTextIOWrapper._unpack_cookiecCs>|jstdƒ‚|jstdƒ‚|jƒ|jjƒ}|j}|dksF|jdkrX|j rTt dƒ‚|S|j\}}|t |ƒ8}|j }|dkrˆ|j ||ƒS|jƒ}�zšt|j|ƒ}d}x�|dk�r$|jd|fƒt |j|d|…ƒƒ} | |k�r|jƒ\} } | �s| }|| 8}P|t | ƒ8}d}q¨||8}|d}q¨Wd}|jd|fƒ||} |} |dk�rZ|j | | ƒSd}d}d}x´t|t |ƒƒD]v}|d7}|t |j|||d…ƒƒ7}|jƒ\}}| �rÞ||k�rÞ| |7} ||8}|dd} }}||k�rvP�qvW|t |jddd �ƒ7}d}||k�rtd ƒ‚|j | | |||ƒS|j|ƒXdS) Nz!underlying stream is not seekablez(telling position disabled by next() callzpending decoded textrr r r T)r÷z'can't reconstruct logical file position)rérPr%r,r[r>rXr!r$r"r4r!r#rCrrr'rrúÚrange)rDr*rôr8Z next_inputrBZ saved_stateZ skip_bytesZ skip_backrlrÚdÚ start_posZ start_flagsZ bytes_fedrAZ chars_decodedÚir7r?r?r@rXysv              zTextIOWrapper.tellcCs$|jƒ|dkr|jƒ}|jj|ƒS)N)r[rXr>rY)rDrVr?r?r@rYÜszTextIOWrapper.truncatecCs*|jdkrtdƒ‚|jƒ|j}d|_|S)Nzbuffer is already detached)r>r"r[r—)rDr>r?r?r@r�âs  zTextIOWrapper.detachc s‡fdd„}ˆjrtdƒ‚ˆjs(tdƒ‚|dkrL|dkr@tdƒ‚d}ˆjƒ}|dkr¦|dkrdtd ƒ‚ˆjƒˆjjddƒ}ˆjd ƒdˆ_ ˆj ršˆj j ƒ||ƒ|S|dkr¼td |fƒ‚|dkrÒtd |fƒ‚ˆjƒˆj |ƒ\}}}}} ˆjj|ƒˆjd ƒdˆ_ |dk�r(ˆj �r(ˆj j ƒn@ˆj �s<|�s<| �rhˆj �pJˆj ƒˆ_ ˆj jd |fƒ|d fˆ_ | �r¶ˆjj|ƒ} ˆjˆj j| |ƒƒ|| fˆ_ tˆjƒ| k�r°tdƒ‚| ˆ_||ƒ|S)Nc sHyˆjpˆjƒ}Wntk r&YnX|dkr<|jdƒn|jƒdS)z9Reset the encoder (merely useful for proper BOM handling)rN)r r(rrr)r*r-)rDr?r@Ú_reset_encoderës z*TextIOWrapper.seek.._reset_encoderztell on closed filez!underlying stream is not seekabler rz#can't do nonzero cur-relative seeksr z#can't do nonzero end-relative seeksrzunsupported whence (%r)znegative seek position %rr z#can't restore logical file position)rer"rérPrXr[r>rUr,r$r!rrFr0rrqrúr!r"r,r#) rDZcookierWrKr*rIr8r@rArBr9r?)rDr@rUês\         zTextIOWrapper.seekcCsà|jƒ|dkrd}|jp |jƒ}y |jWn,tk rX}ztdƒ|‚WYdd}~XnX|dkr’|jƒ|j|jj ƒdd�}|j dƒd|_ |Sd}|j|ƒ}x6t |ƒ|krÖ| rÖ|j ƒ }||j|t |ƒƒ7}q¢W|SdS) Nr zan integer is requiredrT)r÷rFr)rbr!r0rƒr-rr3rúr>rqr,r$r!r;)rDrmrôr¤r<r:r?r?r@rq5 s(    zTextIOWrapper.readcCs(d|_|jƒ}|s$d|_|j|_t‚|S)NF)r%rtr$rérv)rDrwr?r?r@rxN szTextIOWrapper.__next__cCsÜ|jrtdƒ‚|dkrd }nt|tƒs.tdƒ‚|jƒ}d}|jsH|jƒd}}�xR|jr„|j d|ƒ}|dkrz|d}Pnt |ƒ}nº|j �r|j d|ƒ}|j d|ƒ}|d krÊ|d kr¾t |ƒ}n |d}PnL|d krÞ|d}Pn8||krò|d}Pn$||dk�r |d}Pn |d}Pn&|j |j ƒ}|dk�r>|t |j ƒ}P|dk�r\t |ƒ|k�r\|}Px|j ƒ�rv|j�r^P�q^W|j�rŽ||jƒ7}qT|jdƒd|_|SqTW|dk�r¾||k�r¾|}|jt |ƒ|ƒ|d|…S) Nzread from closed filer zsize must be an integerrrùrør rrrrr)rer"rrrr3r!r0rrjr!rrr;r"r,r$r5)rDrmrwÚstartrVÚendposZnlposZcrposr?r?r@rtW sp          zTextIOWrapper.readlinecCs|jr|jjSdS)N)r!rî)rDr?r?r@rî¯ szTextIOWrapper.newlines)NNNFF)N)rrrr)N)r)N)N)&rHrIrJrCr6r�r•rr6r7r=r>r^rarcr[r3rerSr*r'r}r(r0r,r3r5r;rCrFrXrYr�rUrqrxrtrîr?r?r?r@r1ZsH E        * c  K  Xr1csReZdZdZd‡fdd„ Zdd„Zdd „Zed d „ƒZed d „ƒZ dd„Z ‡Z S)ÚStringIOz»Text 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. rrùcsftt|ƒjtƒdd|d�|dkr(d|_|dk rbt|tƒsNtdjt |ƒj ƒƒ‚|j |ƒ|j dƒdS)Nzutf-8Ú surrogatepass)r6r7r8Fz*initial_value must be str or None, not {0}r) rŸrNr�r–rrrrr‘rrHr}rU)rDZ initial_valuer8)rRr?r@r�» s  zStringIO.__init__c CsL|jƒ|jp|jƒ}|jƒ}|jƒz|j|jjƒdd�S|j|ƒXdS)NT)r÷) r[r!r0rrrúr>rœr)rDrôZ old_stater?r?r@rœË szStringIO.getvaluecCs tj|ƒS)N)Úobjectr•)rDr?r?r@r•Õ szStringIO.__repr__cCsdS)Nr?)rDr?r?r@r7Ú szStringIO.errorscCsdS)Nr?)rDr?r?r@r6Þ szStringIO.encodingcCs|jdƒdS)Nr�)rT)rDr?r?r@r�â szStringIO.detach)rrù) rHrIrJrCr�rœr•rr7r6r�r¥r?r?)rRr@rN´ s   rN>rri r)rrNNNTN)5rCrÚabcrñr¹r×ÚsysÚ_threadrr¨rZ _dummy_threadÚplatformZmsvcrtrrÜÚiorrrr r³roÚaddr Ú SEEK_DATAr(r¸rArBrKrPr-r,r"ÚABCMetarQÚregisterr�Ú_ior&r†rŽr–r0r/r½r.rìròrïr1rNr?r?r?r@Úsv      T   =   g iCZIJUA U^