zfc@sdZddlmZmZddlZddlZddlZddlZddlZddl Z yddl m Z Wn!e k rddlm Z nXddlZddlmZmZmZmZddl mZeZddZd efd YZd deeeed Zd fdYZdfdYZdeefdYZ dfdYZ!ej!j"e!de!fdYZ#ej#j"e#ddl$m%Z%e#j"e%de!fdYZ&ej&j"e&de&fdYZ'de&fdYZ(de'fdYZ)d e'fd!YZ*d"e&fd#YZ+d$e*e)fd%YZ,d&e!fd'YZ-ej-j"e-d(ej.fd)YZ/d*e-fd+YZ0d,e0fd-YZ1dS(.u) Python implementation of the io module. i(tprint_functiontunicode_literalsN(t allocate_lock(t__all__tSEEK_SETtSEEK_CURtSEEK_END(tEINTRiitBlockingIOErrorcBseZdZddZRS(uCException raised when I/O would block on a non-blocking I/O stream.icCsJtt|j||t|ttfs=tdn||_dS(Nu$characters_written must be a integer(tsupertIOErrort__init__t isinstancetinttlongt TypeErrortcharacters_written(tselfterrnotstrerrorR((s/usr/lib64/python2.7/_pyio.pyR %s(t__name__t __module__t__doc__R (((s/usr/lib64/python2.7/_pyio.pyR!surcCs<t|tttfs+td|nt|tsMtd|nt|ttfsutd|n|dk rt|t rtd|n|dk rt|t rtd|nt|}|tdst|t|krtd|nd|k}d|k} d |k} d |k} d |k} d |k} d |kr| sz| rtdnt }n| r| rtdn|| | dkrtdn|p| p| stdn| r|dk rtdn| r3|dk r3tdn| rT|dk rTtdnt ||rfdpid| rudpxd| rd pd| rd pd|}|}yyt }|dks|dkr|j rd}t }n|dkrGt }ytj|jj}Wntjtfk r.qGX|dkrG|}qGn|dkrbtdn|dkr| rx|Stdn| rt||}nF| s| rt||}n(|rt||}ntd||}| r|St|||||} | }|| _|SWn|jnXdS(uOpen file and return a stream. Raise IOError 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), 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 '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 (for backwards compatibility; unneeded for new code) ========= =============================================================== 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. 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. 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 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 controls 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. 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. 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. uinvalid file: %ruinvalid mode: %ruinvalid buffering: %ruinvalid encoding: %ruinvalid errors: %ruarwb+tUuruwuau+utubuUu$can't use U and writing mode at onceu'can't have text and binary mode at onceiu)can't have read/write/append mode at onceu/must have exactly one of read/write/append modeu-binary mode doesn't take an encoding argumentu+binary mode doesn't take an errors argumentu+binary mode doesn't take a newline argumentuiiuinvalid buffering sizeucan't have unbuffered text I/Ouunknown mode: %rN(R t basestringR RRtNonetsettlent ValueErrortTruetFileIOtFalsetisattytDEFAULT_BUFFER_SIZEtostfstattfilenot st_blksizeterrortAttributeErrortBufferedRandomtBufferedWritertBufferedReadert TextIOWrappertmodetclose(tfileR+t bufferingtencodingterrorstnewlinetclosefdtmodestreadingtwritingt appendingtupdatingttexttbinarytrawtresulttline_bufferingtbstbuffer((s/usr/lib64/python2.7/_pyio.pytopen,so (          / $         t DocDescriptorcBseZdZdZRS(u%Helper for builtins.open.__doc__ cCs dtjS(Nu\open(file, mode='r', buffering=-1, encoding=None, errors=None, newline=None, closefd=True) (R?R(Rtobjttyp((s/usr/lib64/python2.7/_pyio.pyt__get__s(RRRRC(((s/usr/lib64/python2.7/_pyio.pyR@st OpenWrappercBs eZdZeZdZRS(uWrapper 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/pythonrun.c. cOs t||S(N(R?(tclstargstkwargs((s/usr/lib64/python2.7/_pyio.pyt__new__s(RRRR@RH(((s/usr/lib64/python2.7/_pyio.pyRDs tUnsupportedOperationcBseZRS((RR(((s/usr/lib64/python2.7/_pyio.pyRIstIOBasecBs eZejZdZddZdZddZ dZ e Z dZ dZdZdd Zd Zdd Zd Zdd ZedZddZdZdZdZdZddZdZdZddZdZ RS(cCs td|jj|fdS(u8Internal: raise an exception for unsupported operations.u%s.%s() not supportedN(RIt __class__R(Rtname((s/usr/lib64/python2.7/_pyio.pyt _unsupported,sicCs|jddS(uChange 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: * 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 Return the new absolute position. useekN(RM(Rtpostwhence((s/usr/lib64/python2.7/_pyio.pytseek3s cCs|jddS(uReturn current stream position.ii(RP(R((s/usr/lib64/python2.7/_pyio.pyttellBscCs|jddS(uTruncate file to size bytes. Size defaults to the current IO position as reported by tell(). Return the new size. utruncateN(RM(RRN((s/usr/lib64/python2.7/_pyio.pyttruncateFscCs|jdS(uuFlush write buffers, if applicable. This is not implemented for read-only and non-blocking streams. N(t _checkClosed(R((s/usr/lib64/python2.7/_pyio.pytflushPscCs+|js'z|jWdt|_XndS(uiFlush and close the IO object. This method has no effect if the file is already closed. N(t_IOBase__closedRTR(R((s/usr/lib64/python2.7/_pyio.pyR,Zs cCsy|jWnnXdS(uDestructor. Calls close().N(R,(R((s/usr/lib64/python2.7/_pyio.pyt__del__escCstS(uReturn whether object supports random access. If False, seek(), tell() and truncate() will raise IOError. This method may need to do a test seek(). (R(R((s/usr/lib64/python2.7/_pyio.pytseekablesscCs1|js-t|dkr!dn|ndS(u;Internal: raise an IOError if file is not seekable uFile or stream is not seekable.N(RWR R(Rtmsg((s/usr/lib64/python2.7/_pyio.pyt_checkSeekable{s cCstS(udReturn whether object was opened for reading. If False, read() will raise IOError. (R(R((s/usr/lib64/python2.7/_pyio.pytreadablescCs1|js-t|dkr!dn|ndS(u;Internal: raise an IOError if file is not readable uFile or stream is not readable.N(RZR R(RRX((s/usr/lib64/python2.7/_pyio.pyt_checkReadables cCstS(utReturn whether object was opened for writing. If False, write() and truncate() will raise IOError. (R(R((s/usr/lib64/python2.7/_pyio.pytwritablescCs1|js-t|dkr!dn|ndS(u;Internal: raise an IOError if file is not writable uFile or stream is not writable.N(R\R R(RRX((s/usr/lib64/python2.7/_pyio.pyt_checkWritables cCs|jS(uclosed: bool. True iff the file has been closed. For backwards compatibility, this is a property, not a predicate. (RU(R((s/usr/lib64/python2.7/_pyio.pytclosedscCs.|jr*t|dkrdn|ndS(u7Internal: raise a ValueError if file is closed uI/O operation on closed file.N(R^RR(RRX((s/usr/lib64/python2.7/_pyio.pyRSs cCs|j|S(u+Context management protocol. Returns self.(RS(R((s/usr/lib64/python2.7/_pyio.pyt __enter__s cGs|jdS(u+Context management protocol. Calls close()N(R,(RRF((s/usr/lib64/python2.7/_pyio.pyt__exit__scCs|jddS(uReturns underlying file descriptor if one exists. An IOError is raised if the IO object does not use a file descriptor. ufilenoN(RM(R((s/usr/lib64/python2.7/_pyio.pyR#scCs|jtS(uiReturn whether this is an 'interactive' stream. Return False if it can't be determined. (RSR(R((s/usr/lib64/python2.7/_pyio.pyRs icstdr$fd}n d}dkrBdn$tttfsftdnt}x[dkst|krj|}|sPn||7}|j drrPqrqrWt |S( u(Read and return a line from the stream. If limit is specified, at most limit bytes will be read. 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. upeekcsZjd}|sdS|jddp5t|}dkrVt|}n|S(Nis i(tpeektfindRtmin(t readaheadtn(tlimitR(s/usr/lib64/python2.7/_pyio.pyt nreadaheads cSsdS(Ni((((s/usr/lib64/python2.7/_pyio.pyRgsiulimit must be an integeris N( thasattrRR R RRt bytearrayRtreadtendswithtbytes(RRfRgtrestb((RfRs/usr/lib64/python2.7/_pyio.pytreadlines     ! cCs|j|S(N(RS(R((s/usr/lib64/python2.7/_pyio.pyt__iter__s cCs|j}|stn|S(N(Rot StopIteration(Rtline((s/usr/lib64/python2.7/_pyio.pytnexts  cCs|dk r1t|ttf r1tdn|dksI|dkrSt|Sd}g}x;|D]3}|j||t|7}||krfPqfqfW|S(uReturn 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. uinteger or None expectediN(RR R RRtlisttappendR(RthintRetlinesRr((s/usr/lib64/python2.7/_pyio.pyt readliness"    cCs,|jx|D]}|j|qWdS(N(RStwrite(RRwRr((s/usr/lib64/python2.7/_pyio.pyt writeliness  N(!RRtabctABCMetat __metaclass__RMRPRQRRRRTRRUR,RVRWRYRZR[R\R]tpropertyR^RSR_R`R#RRoRpRsRxRz(((s/usr/lib64/python2.7/_pyio.pyRJs4 #               $   t RawIOBasecBs5eZdZddZdZdZdZRS(uBase class for raw binary I/O.icCsm|dkrd}n|dkr+|jSt|j}|j|}|dkr\dS||3t|S(uRead and return up to n bytes. Returns an empty bytes object on EOF, or None if the object is set not to block and has no data to read. iiN(RtreadallRit __index__treadintoRl(RReRn((s/usr/lib64/python2.7/_pyio.pyRj&s     cCsQt}x-tr8|jt}|s+Pn||7}q W|rIt|S|SdS(u+Read until EOF, using multiple read() call.N(RiRRjR Rl(RRmtdata((s/usr/lib64/python2.7/_pyio.pyR7s   cCs|jddS(uRead up to len(b) bytes into b. Returns number of bytes read (0 for EOF), or None if the object is set not to block and has no data to read. ureadintoN(RM(RRn((s/usr/lib64/python2.7/_pyio.pyREscCs|jddS(u~Write the given buffer to the IO stream. Returns the number of bytes written, which may be less than len(b). uwriteN(RM(RRn((s/usr/lib64/python2.7/_pyio.pyRyMs(RRRRjRRRy(((s/usr/lib64/python2.7/_pyio.pyRs    (RtBufferedIOBasecBsAeZdZddZddZdZdZdZRS(uBase 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. cCs|jddS(uRead and return up to n bytes. 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. ureadN(RM(RRe((s/usr/lib64/python2.7/_pyio.pyRjjscCs|jddS(u7Read up to n bytes with at most one read() system call.uread1N(RM(RRe((s/usr/lib64/python2.7/_pyio.pytread1~scCs|jt|}t|}y|||*WnPtk r}ddl}t||jsh|n|jd|||*nX|S(u=Read up to len(b) bytes into b. Like read(), this may issue multiple reads to the underlying raw stream, unless the latter is 'interactive'. Returns the number of bytes read (0 for EOF). Raises BlockingIOError if the underlying raw stream has no data at the moment. iNRn(RjRRtarrayR (RRnRReterrR((s/usr/lib64/python2.7/_pyio.pyRs    cCs|jddS(uWrite the given buffer to the IO stream. Return the number of bytes written, which is always len(b). Raises BlockingIOError if the buffer is full and the underlying raw stream cannot accept more data at the moment. uwriteN(RM(RRn((s/usr/lib64/python2.7/_pyio.pyRyscCs|jddS(u 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. udetachN(RM(R((s/usr/lib64/python2.7/_pyio.pytdetachsN( RRRRRjRRRyR(((s/usr/lib64/python2.7/_pyio.pyRYs     t_BufferedIOMixincBseZdZdZddZdZddZdZdZ dZ d Z d Z d Z ed Zed ZedZedZdZdZdZRS(uA 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(t_raw(RR:((s/usr/lib64/python2.7/_pyio.pyR sicCs4|jj||}|dkr0tdn|S(Niu#seek() returned an invalid position(R:RPR (RRNROt new_position((s/usr/lib64/python2.7/_pyio.pyRPs cCs.|jj}|dkr*tdn|S(Niu#tell() returned an invalid position(R:RQR (RRN((s/usr/lib64/python2.7/_pyio.pyRQs cCs5|j|dkr%|j}n|jj|S(N(RTRRQR:RR(RRN((s/usr/lib64/python2.7/_pyio.pyRRs  cCs)|jrtdn|jjdS(Nuflush of closed file(R^RR:RT(R((s/usr/lib64/python2.7/_pyio.pyRTs cCs?|jdk r;|j r;z|jWd|jjXndS(N(R:RR^RTR,(R((s/usr/lib64/python2.7/_pyio.pyR,scCs>|jdkrtdn|j|j}d|_|S(Nuraw stream already detached(R:RRRTR(RR:((s/usr/lib64/python2.7/_pyio.pyRs    cCs |jjS(N(R:RW(R((s/usr/lib64/python2.7/_pyio.pyRWscCs |jjS(N(R:RZ(R((s/usr/lib64/python2.7/_pyio.pyRZscCs |jjS(N(R:R\(R((s/usr/lib64/python2.7/_pyio.pyR\scCs|jS(N(R(R((s/usr/lib64/python2.7/_pyio.pyR:scCs |jjS(N(R:R^(R((s/usr/lib64/python2.7/_pyio.pyR^scCs |jjS(N(R:RL(R((s/usr/lib64/python2.7/_pyio.pyRLscCs |jjS(N(R:R+(R((s/usr/lib64/python2.7/_pyio.pyR+scCsK|jj}y |j}Wntk r6dj|SXdj||SdS(Nu <_pyio.{0}>u<_pyio.{0} name={1!r}>(RKRRLt Exceptiontformat(RtclsnameRL((s/usr/lib64/python2.7/_pyio.pyt__repr__s    cCs |jjS(N(R:R#(R((s/usr/lib64/python2.7/_pyio.pyR#scCs |jjS(N(R:R(R((s/usr/lib64/python2.7/_pyio.pyRsN(RRRR RPRQRRRRTR,RRWRZR\R~R:R^RLR+RR#R(((s/usr/lib64/python2.7/_pyio.pyRs$          tBytesIOcBseZdZddZdZdZddZdZdZ ddZ d Z dd Z d Z d Zd ZRS(u<Buffered I/O implementation using an in-memory bytes buffer.cCs;t}|dk r%|j|n||_d|_dS(Ni(RiRtextendt_buffert_pos(Rt initial_bytestbuf((s/usr/lib64/python2.7/_pyio.pyR s    cCs%|jrtdn|jjS(Nu__getstate__ on closed file(R^Rt__dict__tcopy(R((s/usr/lib64/python2.7/_pyio.pyt __getstate__#s cCs%|jrtdnt|jS(u8Return the bytes value (contents) of the buffer ugetvalue on closed file(R^RRlR(R((s/usr/lib64/python2.7/_pyio.pytgetvalue(s cCs|jrtdn|dkr-d}nt|ttfs`tdjt|n|dkr~t |j }nt |j |j krdSt t |j |j |}|j |j |!}||_ t |S(Nuread from closed fileiu$integer argument expected, got {0!r}it(R^RRR R RRRttypeRRRRcRl(RRetnewposRn((s/usr/lib64/python2.7/_pyio.pyRj/s      cCs |j|S(u"This is the same as read. (Rj(RRe((s/usr/lib64/python2.7/_pyio.pyR@scCs|jrtdnt|tr6tdnt|}|dkrRdS|j}|t|jkrd|t|j}|j|7_n||j|||+|j|7_|S(Nuwrite to closed fileu$can't write unicode to binary streamis(R^RR tunicodeRRRR(RRnReRNtpadding((s/usr/lib64/python2.7/_pyio.pyRyEs    icCs|jrtdny |jWntk rBtdnX|dkr}|dkrqtd|fn||_nb|dkrtd|j||_n:|dkrtdt|j||_n td|jS(Nuseek on closed fileuan integer is requirediunegative seek position %riiuinvalid whence value( R^RRR&RRtmaxRR(RRNRO((s/usr/lib64/python2.7/_pyio.pyRPWs         " cCs|jrtdn|jS(Nutell on closed file(R^RR(R((s/usr/lib64/python2.7/_pyio.pyRQjs cCs|jrtdn|dkr0|j}nMy |jWntk rZtdnX|dkr}td|fn|j|3|S(Nutruncate on closed fileuan integer is requirediunegative truncate position %r(R^RRRRR&RR(RRN((s/usr/lib64/python2.7/_pyio.pyRRos       cCs|jrtdntS(NuI/O operation on closed file.(R^RR(R((s/usr/lib64/python2.7/_pyio.pyRZ~s cCs|jrtdntS(NuI/O operation on closed file.(R^RR(R((s/usr/lib64/python2.7/_pyio.pyR\s cCs|jrtdntS(NuI/O operation on closed file.(R^RR(R((s/usr/lib64/python2.7/_pyio.pyRWs N(RRRRR RRRjRRyRPRQRRRZR\RW(((s/usr/lib64/python2.7/_pyio.pyRs           R)cBsqeZdZedZdZd dZd dZddZ ddZ dZ d Z dd Z RS( uBufferedReader(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. cCsi|jstdntj|||dkrFtdn||_|jt|_dS(uMCreate a new buffered reader using the given readable raw IO object. u "raw" argument must be readable.iuinvalid buffer sizeN( RZR RR Rt buffer_sizet_reset_read_buftLockt _read_lock(RR:R((s/usr/lib64/python2.7/_pyio.pyR s    cCsd|_d|_dS(NRi(t _read_buft _read_pos(R((s/usr/lib64/python2.7/_pyio.pyRs cCsH|dk r'|dkr'tdn|j|j|SWdQXdS(uRead n bytes. Returns exactly n bytes of data unless the underlying raw IO stream reaches EOF or if the call would block in non-blocking mode. If n is negative, read until EOF or until read() would block. iuinvalid number of bytes to readN(RRRt_read_unlocked(RRe((s/usr/lib64/python2.7/_pyio.pyRjs c Csd}d}|j}|j}|dks6|dkr|j||g}d}x~try|jj}Wn+tk r} | jt krVqVqVnX||kr|}Pn|t |7}|j |qVWdj |p|St ||} || kr!|j|7_||||!S||g}t |j|} x| |kry|jj| }Wn+tk r} | jt krCqCqCnX||kr|}Pn| t |7} |j |qCWt|| }dj |} | ||_d|_| r | | S|S(NRii(RN(RRRRRR:RjR RRRRutjoinRRRc( RRet nodata_valt empty_valuesRRNtchunkst current_sizetchunktetavailtwantedtout((s/usr/lib64/python2.7/_pyio.pyRsX           icCs!|j|j|SWdQXdS(uReturns 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(Rt_peek_unlocked(RRe((s/usr/lib64/python2.7/_pyio.pyRas cCst||j}t|j|j}||ks@|dkr|j|}xOtry|jj|}Wn+tk r}|j t krPqPqPnXPqPW|r|j|j||_d|_qn|j|jS(Ni( RcRRRRRR:RjR RR(RRetwantthavetto_readtcurrentR((s/usr/lib64/python2.7/_pyio.pyRs   c Csr|dkrtdn|dkr+dS|j8|jd|jt|t|j|jSWdQXdS(u9Reads up to n bytes, with at most one read() system call.iu(number of bytes to read must be positiveRiN(RRRRRcRRR(RRe((s/usr/lib64/python2.7/_pyio.pyR s    cCs!tj|t|j|jS(N(RRQRRR(R((s/usr/lib64/python2.7/_pyio.pyRQscCsd|kodkns+tdn|jQ|dkr^|t|j|j8}ntj|||}|j|SWdQXdS(Niiuinvalid whence valuei(RRRRRRRPR(RRNRO((s/usr/lib64/python2.7/_pyio.pyRPs   N(RRRR R RRRjRRaRRRQRP(((s/usr/lib64/python2.7/_pyio.pyR)s   8  R(cBs_eZdZdZed dZdZd dZdZ dZ dZ dd Z RS( uA buffer for a writeable sequential RawIO object. The constructor creates a BufferedWriter for the given writeable raw stream. If the buffer_size is not given, it defaults to DEFAULT_BUFFER_SIZE. icCs|jstdntj|||dkrFtdn|dk rktjdt|j n||_ t |_ t |_dS(Nu "raw" argument must be writable.iuinvalid buffer sizeumax_buffer_size is deprecated(R\R RR RRtwarningstwarntDeprecationWarningt_warning_stack_offsetRRit _write_bufRt _write_lock(RR:Rtmax_buffer_size((s/usr/lib64/python2.7/_pyio.pyR 0s       c CsJ|jrtdnt|tr6tdn|jt|j|jkre|j nt|j}|jj |t|j|}t|j|jkr<y|j Wq<t k r8}t|j|jkr9t|j|j}||8}|j|j |_t |j |j |q9q<Xn|SWdQXdS(Nuwrite to closed fileu$can't write unicode to binary stream(R^RR RRRRRRt_flush_unlockedRRRR(RRntbeforetwrittenRtoverage((s/usr/lib64/python2.7/_pyio.pyRy?s(    "cCsL|j=|j|dkr2|jj}n|jj|SWdQXdS(N(RRRR:RQRR(RRN((s/usr/lib64/python2.7/_pyio.pyRR[s    cCs|j|jWdQXdS(N(RR(R((s/usr/lib64/python2.7/_pyio.pyRTbs cCs|jrtdnx|jry|jj|j}WnGtk r\tdn+tk r}|jt krqqnX|dkrttj ddn|t |jks|dkrtdn|j|4qWdS(Nuflush of closed fileuHself.raw should implement RawIOBase: it should not raise BlockingIOErroru)write could not complete without blockingiu*write() returned incorrect number of bytes( R^RRR:RyRt RuntimeErrorR RRRtEAGAINR(RReR((s/usr/lib64/python2.7/_pyio.pyRfs$    !cCstj|t|jS(N(RRQRR(R((s/usr/lib64/python2.7/_pyio.pyRQ{sicCs\d|kodkns+tdn|j"|jtj|||SWdQXdS(Niiuinvalid whence(RRRRRP(RRNRO((s/usr/lib64/python2.7/_pyio.pyRP~s   N( RRRRR RR RyRRRTRRQRP(((s/usr/lib64/python2.7/_pyio.pyR(%s     tBufferedRWPaircBseZdZeddZddZdZdZddZ dZ dZ d Z d Z d Zd Zed ZRS(uA 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|dk r"tjdtdn|js=tdn|jsXtdnt|||_t |||_ dS(uEConstructor. The arguments are two RawIO instances. umax_buffer_size is deprecatediu#"reader" argument must be readable.u#"writer" argument must be writable.N( RRRRRZR R\R)treaderR(twriter(RRRRR((s/usr/lib64/python2.7/_pyio.pyR s   cCs%|dkrd}n|jj|S(Ni(RRRj(RRe((s/usr/lib64/python2.7/_pyio.pyRjs  cCs|jj|S(N(RR(RRn((s/usr/lib64/python2.7/_pyio.pyRscCs|jj|S(N(RRy(RRn((s/usr/lib64/python2.7/_pyio.pyRysicCs|jj|S(N(RRa(RRe((s/usr/lib64/python2.7/_pyio.pyRascCs|jj|S(N(RR(RRe((s/usr/lib64/python2.7/_pyio.pyRscCs |jjS(N(RRZ(R((s/usr/lib64/python2.7/_pyio.pyRZscCs |jjS(N(RR\(R((s/usr/lib64/python2.7/_pyio.pyR\scCs |jjS(N(RRT(R((s/usr/lib64/python2.7/_pyio.pyRTscCs&z|jjWd|jjXdS(N(RR,R(R((s/usr/lib64/python2.7/_pyio.pyR,scCs|jjp|jjS(N(RRR(R((s/usr/lib64/python2.7/_pyio.pyRscCs |jjS(N(RR^(R((s/usr/lib64/python2.7/_pyio.pyR^sN(RRRR RR RjRRyRaRRZR\RTR,RR~R^(((s/usr/lib64/python2.7/_pyio.pyRs           R'cBsweZdZdZed dZddZdZd dZ d dZ dZ dd Z d Z d ZRS( uA 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. icCs7|jtj|||tj||||dS(N(RYR)R R((RR:RR((s/usr/lib64/python2.7/_pyio.pyR s icCsd|kodkns+tdn|j|jrt|j(|jj|jt|jdWdQXn|jj||}|j|jWdQX|dkrt dn|S(Niiuinvalid whenceiu seek() returned invalid position( RRTRRR:RPRRRR (RRNRO((s/usr/lib64/python2.7/_pyio.pyRPs   ,  cCs'|jrtj|Stj|SdS(N(RR(RQR)(R((s/usr/lib64/python2.7/_pyio.pyRQs  cCs+|dkr|j}ntj||S(N(RRQR(RR(RRN((s/usr/lib64/python2.7/_pyio.pyRRs cCs/|dkrd}n|jtj||S(Ni(RRTR)Rj(RRe((s/usr/lib64/python2.7/_pyio.pyRjs   cCs|jtj||S(N(RTR)R(RRn((s/usr/lib64/python2.7/_pyio.pyRs cCs|jtj||S(N(RTR)Ra(RRe((s/usr/lib64/python2.7/_pyio.pyRas cCs|jtj||S(N(RTR)R(RRe((s/usr/lib64/python2.7/_pyio.pyR s cCsY|jrI|j2|jj|jt|jd|jWdQXntj||S(Ni( RRR:RPRRRR(Ry(RRn((s/usr/lib64/python2.7/_pyio.pyRys   #N(RRRRR RR RPRQRRRjRRaRRy(((s/usr/lib64/python2.7/_pyio.pyR's       t TextIOBasecBsneZdZddZdZd dZdZdZe dZ e dZ e d Z RS( uBase class for text I/O. This class provides a character and line based interface to stream I/O. There is no readinto method because Python's character strings are immutable. There is no public constructor. icCs|jddS(uRead at most n characters from stream. Read from underlying buffer until we have n characters or we hit EOF. If n is negative or omitted, read until EOF. ureadN(RM(RRe((s/usr/lib64/python2.7/_pyio.pyRj"scCs|jddS(uWrite string s to stream.uwriteN(RM(Rts((s/usr/lib64/python2.7/_pyio.pyRy*scCs|jddS(uTruncate size to pos.utruncateN(RM(RRN((s/usr/lib64/python2.7/_pyio.pyRR.scCs|jddS(u_Read until newline or EOF. Returns an empty string if EOF is hit immediately. ureadlineN(RM(R((s/usr/lib64/python2.7/_pyio.pyRo2scCs|jddS(u Separate the underlying buffer from the TextIOBase and return it. After the underlying buffer has been detached, the TextIO is in an unusable state. udetachN(RM(R((s/usr/lib64/python2.7/_pyio.pyR9scCsdS(uSubclasses should override.N(R(R((s/usr/lib64/python2.7/_pyio.pyR/BscCsdS(uLine endings translated so far. Only line endings translated during reading are considered. Subclasses should override. N(R(R((s/usr/lib64/python2.7/_pyio.pytnewlinesGscCsdS(uMError setting of the decoder or encoder. Subclasses should override.N(R(R((s/usr/lib64/python2.7/_pyio.pyR0QsN( RRRRjRyRRRRoRR~R/RR0(((s/usr/lib64/python2.7/_pyio.pyRs      tIncrementalNewlineDecodercBsbeZdZddZedZdZdZdZdZ dZ d Z e d Z RS( u+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. ustrictcCs>tjj|d|||_||_d|_t|_dS(NR0i(tcodecstIncrementalDecoderR t translatetdecodertseennlRt pendingcr(RRRR0((s/usr/lib64/python2.7/_pyio.pyR bs    cCs4|jdkr|}n|jj|d|}|jr[|sE|r[d|}t|_n|jdr| r|d }t|_n|jd}|jd|}|jd|}|j|o|j |o|j B|o|j BO_|j r0|r|j dd}n|r0|j dd}q0n|S(Ntfinalu iu u (RRtdecodeRRRkRtcountRt_LFt_CRt_CRLFRtreplace(RtinputRtoutputtcrlftcrtlf((s/usr/lib64/python2.7/_pyio.pyRis(     + cCs]|jdkrd}d}n|jj\}}|dK}|jrS|dO}n||fS(NRii(RRtgetstateR(RRtflag((s/usr/lib64/python2.7/_pyio.pyRs    cCsO|\}}t|d@|_|jdk rK|jj||d?fndS(Ni(tboolRRRtsetstate(RtstateRR((s/usr/lib64/python2.7/_pyio.pyRs cCs5d|_t|_|jdk r1|jjndS(Ni(RRRRRtreset(R((s/usr/lib64/python2.7/_pyio.pyRs  iiic Cs#ddddddddf|jS(Nu u u (u u (u u (u u (u u u (RR(R((s/usr/lib64/python2.7/_pyio.pyRs(RRRR RRRRRRRRR~R(((s/usr/lib64/python2.7/_pyio.pyR[s    R*cBseZdZdZd#d#d#edZdZedZ edZ edZ edZ dZ d Zd Zd Zd Zed ZedZdZdZdZdZdZdZd#dZdZdZdddddZdZdZd#dZ dZ!ddZ"d#dZ#d Z$d#d!Z%ed"Z&RS($uCharacter 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. 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. ic CsF|dk r8t|t r8tdt|fn|dkrZtd|fn|dkryddl}Wntk rd}qX|j}nt|tstd |nt j rt j |j rd }tj||d d n|dkrd }n"t|ts4td|n||_||_||_||_| |_|dk|_||_|dk|_|ptj|_d|_d|_d|_d|_d|_|j j!|_"|_#|j"rB|j$rB|j j%}|dkrBy|j&j'dWq?t(k r;q?XqBndS(Nuillegal newline type: %ruu u u uillegal newline value: %riuasciiuinvalid encoding: %ruG%r is not a text encoding; use codecs.open() to handle arbitrary codecst stackleveliustrictuinvalid errors: %ri(Nuu u u ()RR RRRRtlocalet ImportErrortgetpreferredencodingtsyst py3kwarningRtlookupt_is_text_encodingRtwarnpy3kRt_line_bufferingt _encodingt_errorst_readuniversalt_readtranslatet_readnlt_writetranslateR!tlinesept_writenlt_encodert_decodert_decoded_charst_decoded_chars_usedt _snapshotR>RWt _seekablet_tellingR\RQt _get_encoderRt LookupError( RR>R/R0R1R<RRXtposition((s/usr/lib64/python2.7/_pyio.pyR sR                   cCsEy |j}Wntk r-dj|jSXdj||jSdS(Nu$<_pyio.TextIOWrapper encoding='{0}'>u/<_pyio.TextIOWrapper name={0!r} encoding='{1}'>(RLRRR/(RRL((s/usr/lib64/python2.7/_pyio.pyR s   cCs|jS(N(R(R((s/usr/lib64/python2.7/_pyio.pyR/scCs|jS(N(R(R((s/usr/lib64/python2.7/_pyio.pyR0scCs|jS(N(R(R((s/usr/lib64/python2.7/_pyio.pyR<scCs|jS(N(R(R((s/usr/lib64/python2.7/_pyio.pyR>scCs|jrtdn|jS(NuI/O operation on closed file.(R^RR(R((s/usr/lib64/python2.7/_pyio.pyRW"s cCs |jjS(N(R>RZ(R((s/usr/lib64/python2.7/_pyio.pyRZ'scCs |jjS(N(R>R\(R((s/usr/lib64/python2.7/_pyio.pyR\*scCs|jj|j|_dS(N(R>RTRR(R((s/usr/lib64/python2.7/_pyio.pyRT-s cCs?|jdk r;|j r;z|jWd|jjXndS(N(R>RR^RTR,(R((s/usr/lib64/python2.7/_pyio.pyR,1scCs |jjS(N(R>R^(R((s/usr/lib64/python2.7/_pyio.pyR^8scCs |jjS(N(R>RL(R((s/usr/lib64/python2.7/_pyio.pyRL<scCs |jjS(N(R>R#(R((s/usr/lib64/python2.7/_pyio.pyR#@scCs |jjS(N(R>R(R((s/usr/lib64/python2.7/_pyio.pyRCscCs/|jrtdnt|ts@td|jjnt|}|js^|j ogd|k}|r|jr|j dkr|j d|j }n|j p|j }|j|}|jj||j r|sd|kr|jn|jdd|_|jr+|jjn|S(Nuwrite to closed fileucan't write %s to text streamu u u(R^RR RRRKRRRRRRRRtencodeR>RyRTt_set_decoded_charsRRRR(RRtlengththaslftencoderRn((s/usr/lib64/python2.7/_pyio.pyRyFs&      cCs+tj|j}||j|_|jS(N(RtgetincrementalencoderRRR(Rt make_encoder((s/usr/lib64/python2.7/_pyio.pyR\scCsLtj|j}||j}|jr?t||j}n||_|S(N(RtgetincrementaldecoderRRRRRR(Rt make_decoderR((s/usr/lib64/python2.7/_pyio.pyt _get_decoderas   cCs||_d|_dS(uSet the _decoded_chars buffer.iN(RR(Rtchars((s/usr/lib64/python2.7/_pyio.pyRls cCsR|j}|dkr%|j|}n|j|||!}|jt|7_|S(u'Advance into the _decoded_chars buffer.N(RRRR(RRetoffsetR((s/usr/lib64/python2.7/_pyio.pyt_get_decoded_charsqs   cCs1|j|krtdn|j|8_dS(u!Rewind the _decoded_chars buffer.u"rewind decoded_chars out of boundsN(RtAssertionError(RRe((s/usr/lib64/python2.7/_pyio.pyt_rewind_decoded_chars{scCs|jdkrtdn|jr?|jj\}}n|jj|j}| }|j|jj |||jr|||f|_ n| S(uQ Read and decode the next chunk of data from the BufferedReader. u no decoderN( RRRRRR>Rt _CHUNK_SIZERRR(Rt dec_buffert dec_flagst input_chunkteof((s/usr/lib64/python2.7/_pyio.pyt _read_chunks   icCs*||d>B|d>B|d>Bt|d>BS(Ni@iii(R(RRRt bytes_to_feedtneed_eoft chars_to_skip((s/usr/lib64/python2.7/_pyio.pyt _pack_cookiescCsgt|d\}}t|d\}}t|d\}}t|d\}}|||||fS(Nii@llll(tdivmod(RtbiginttrestRRRRR((s/usr/lib64/python2.7/_pyio.pyt_unpack_cookies cCs|jstdn|js0tdn|j|jj}|j}|dksm|jdkr|j rt dn|S|j\}}|t |8}|j }|dkr|j ||S|j}z$|jd|f|}|dd}} } d} x|D]} | d7} | t |j| 7} |j\} }| r| |kr|| 7}|| 8}|dd}} } n| |krPqqW| t |jddt7} d} | |krtdn|j ||| | |SWd|j|XdS( Nu!underlying stream is not seekableu(telling position disabled by next() callupending decoded textiRiRu'can't reconstruct logical file position(RR RRTR>RQRRRRR RRRRRRR(RRRRt next_inputRt saved_statet start_post start_flagst bytes_fedt chars_decodedRt next_byteR((s/usr/lib64/python2.7/_pyio.pyRQsN              cCs5|j|dkr%|j}n|jj|S(N(RTRRQR>RR(RRN((s/usr/lib64/python2.7/_pyio.pyRRs  cCs>|jdkrtdn|j|j}d|_|S(Nubuffer is already detached(R>RRRTR(RR>((s/usr/lib64/python2.7/_pyio.pyRs    c Cs|jrtdn|js0tdn|dkrl|dkrWtdnd}|j}n|dkr|dkrtdn|j|jjdd}|jdd|_ |j r|j j n|S|dkrtd |fn|dkr)td |fn|j|j |\}}}}}|jj||jdd|_ |dkr|j r|j j nU|j s|s|r|j p|j|_ |j jd |f|d f|_ n|rd|jj|} |j|j j| ||| f|_ t|j|krXtd n||_ny|jpy|j} Wntk rn'X|dkr| jdn | j |S( Nutell on closed fileu!underlying stream is not seekableiiu#can't do nonzero cur-relative seeksiu#can't do nonzero end-relative seeksuu(invalid whence (%r, should be 0, 1 or 2)unegative seek position %rRu#can't restore logical file position(R^RRR RQRTR>RPRRRRRRRRRjRRRRRRR( RtcookieRORRRRRRRR((s/usr/lib64/python2.7/_pyio.pyRPsf                   cCs|j|dkrd}n|jp1|j}y |jWntk r^tdnX|dkr|j|j|j j dt }|j dd|_ |St}|j|}xGt||kr | r |j }||j|t|7}qW|SdS(Niuan integer is requirediRu(R[RRRRR&RR RR>RjRRRRRR(RReRR;R((s/usr/lib64/python2.7/_pyio.pyRjHs(          !cCs=t|_|j}|s9d|_|j|_tn|S(N(RRRoRRRRq(RRr((s/usr/lib64/python2.7/_pyio.pyRsas     cCs|jrtdn|dkr-d}n$t|ttfsQtdn|j}d}|jsy|j nd}}xt rH|j r|j d|}|dkr|d}Pqt |}n|jr|j d|}|j d|}|dkr2|dkr$t |}q|d}Pq|dkrL|d}Pq||krf|d}Pq||dkr|d}Pq|d}Pn5|j |j}|dkr|t |j}Pn|dkrt ||kr|}Pnx|jr|jrPqqW|jr+||j7}q|jd d|_|SqW|dkrj||krj|}n|jt |||| S( Nuread from closed fileiulimit must be an integeriu iu iu(R^RRR R RRR RRRRRbRRRRRRRR (RRfRrtstartRNtendpostnlpostcrpos((s/usr/lib64/python2.7/_pyio.pyRojsp                           cCs|jr|jjSdS(N(RRR(R((s/usr/lib64/python2.7/_pyio.pyRsN('RRRR RRR RR~R/R0R<R>RWRZR\RTR,R^RLR#RRyRRRR R RRRRQRRRRPRjRsRoR(((s/usr/lib64/python2.7/_pyio.pyR*sH  >             "  >   H  XtStringIOcBsVeZdZdddZdZdZedZedZdZ RS( uText 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. uu cCstt|jtddddd||dkrCt|_n|rt|tsgt|}n|j ||j dndS(NR/uutf-8R0ustrictR1i( R R'R RRRRR RRyRP(Rt initial_valueR1((s/usr/lib64/python2.7/_pyio.pyR s   cCsj|j|jp|j}|j}|jz |j|jjdtSWd|j |XdS(NR( RTRRRRRR>RRR(RRt old_state((s/usr/lib64/python2.7/_pyio.pyRs    cCs tj|S(N(tobjectR(R((s/usr/lib64/python2.7/_pyio.pyRscCsdS(N(R(R((s/usr/lib64/python2.7/_pyio.pyR0scCsdS(N(R(R((s/usr/lib64/python2.7/_pyio.pyR/scCs|jddS(Nudetach(RM(R((s/usr/lib64/python2.7/_pyio.pyRs( RRRR RRR~R0R/R(((s/usr/lib64/python2.7/_pyio.pyR's (2Rt __future__RRR!R{RRRRtthreadRRRt dummy_threadtioRRRRRRR}R R RRRR?R@RDRRIRJtregisterRt_ioRRRRR)R(RR'RRRR*R'(((s/usr/lib64/python2.7/_pyio.pytsZ        "   < RjvaJI?U