Dfc@sdZddlmZmZddlZddlZddlZddlZddlZyddl m Z Wn!e k rddl m Z nXddlZddlmZmZmZmZddlmZeZddZd efd YZd deeeed Zd fdYZdfdYZdeefdYZdfdYZ 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+YZ/d,e/fd-YZ0dS(.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|}t }|dks|dkr|j rd}t }n|dkr>t }ytj|jj}Wntjtfk r%q>X|dkr>|}q>n|dkrYtdn|dkr~| ro|Stdn| rt||}nF| s| rt||}n(|rt||}ntd|| r|St|||||} || _| S(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 TextIOWrappertmode(tfileR+t bufferingtencodingterrorstnewlinetclosefdtmodestreadingtwritingt appendingtupdatingttexttbinarytrawtline_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(RRRRA(((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>RF(((s/usr/lib64/python2.7/_pyio.pyRBs tUnsupportedOperationcBseZRS((RR(((s/usr/lib64/python2.7/_pyio.pyRGstIOBasecBs 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(RGt __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(RK(Rtpostwhence((s/usr/lib64/python2.7/_pyio.pytseek*s cCs|jddS(uReturn current stream position.ii(RN(R((s/usr/lib64/python2.7/_pyio.pyttell9scCs|jddS(uTruncate file to size bytes. Size defaults to the current IO position as reported by tell(). Return the new size. utruncateN(RK(RRL((s/usr/lib64/python2.7/_pyio.pyttruncate=scCs|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.pytflushGscCs+|js'z|jWdt|_XndS(uiFlush and close the IO object. This method has no effect if the file is already closed. N(t_IOBase__closedRRR(R((s/usr/lib64/python2.7/_pyio.pytcloseQs cCsy|jWnnXdS(uDestructor. Calls close().N(RT(R((s/usr/lib64/python2.7/_pyio.pyt__del__\scCstS(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.pytseekablejscCs1|js-t|dkr!dn|ndS(u;Internal: raise an IOError if file is not seekable uFile or stream is not seekable.N(RVR R(Rtmsg((s/usr/lib64/python2.7/_pyio.pyt_checkSeekablers cCstS(udReturn whether object was opened for reading. If False, read() will raise IOError. (R(R((s/usr/lib64/python2.7/_pyio.pytreadablezscCs1|js-t|dkr!dn|ndS(u;Internal: raise an IOError if file is not readable uFile or stream is not readable.N(RYR R(RRW((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(RRW((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. (RS(R((s/usr/lib64/python2.7/_pyio.pytclosedscCs.|jr*t|dkrdn|ndS(u8Internal: raise an ValueError if file is closed uI/O operation on closed file.N(R]RR(RRW((s/usr/lib64/python2.7/_pyio.pyRQs cCs|j|S(u+Context management protocol. Returns self.(RQ(R((s/usr/lib64/python2.7/_pyio.pyt __enter__s cGs|jdS(u+Context management protocol. Calls close()N(RT(RRD((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(RK(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. (RQR(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.pyRfsiulimit must be an integeris N( thasattrRR R RRt bytearrayRtreadtendswithtbytes(RReRftrestb((ReRs/usr/lib64/python2.7/_pyio.pytreadlines     ! cCs|j|S(N(RQ(R((s/usr/lib64/python2.7/_pyio.pyt__iter__s cCs|j}|stn|S(N(Rnt 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(RthintRdtlinesRq((s/usr/lib64/python2.7/_pyio.pyt readliness"    cCs,|jx|D]}|j|qWdS(N(RQtwrite(RRvRq((s/usr/lib64/python2.7/_pyio.pyt writeliness  N(!RRtabctABCMetat __metaclass__RKRNRORRPRRRRSRTRURVRXRYRZR[R\tpropertyR]RQR^R_R#RRnRoRrRwRy(((s/usr/lib64/python2.7/_pyio.pyRHs4 "               $   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(RtreadallRht __index__treadintoRk(RRdRm((s/usr/lib64/python2.7/_pyio.pyRis     cCsQt}x-tr8|jt}|s+Pn||7}q W|rIt|S|SdS(u+Read until EOF, using multiple read() call.N(RhRRiR Rk(RRltdata((s/usr/lib64/python2.7/_pyio.pyR.s   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(RK(RRm((s/usr/lib64/python2.7/_pyio.pyR<scCs|jddS(u~Write the given buffer to the IO stream. Returns the number of bytes written, which may be less than len(b). uwriteN(RK(RRm((s/usr/lib64/python2.7/_pyio.pyRxDs(RRRRiRRRx(((s/usr/lib64/python2.7/_pyio.pyR~s    (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(RK(RRd((s/usr/lib64/python2.7/_pyio.pyRiascCs|jddS(u7Read up to n bytes with at most one read() system call.uread1N(RK(RRd((s/usr/lib64/python2.7/_pyio.pytread1uscCs|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. iNRm(RiRRtarrayR (RRmRRdterrR((s/usr/lib64/python2.7/_pyio.pyRys    cCs|jddS(u Write the given buffer to the IO stream. Return the number of bytes written, which is never less than len(b). Raises BlockingIOError if the buffer is full and the underlying raw stream cannot accept more data at the moment. uwriteN(RK(RRm((s/usr/lib64/python2.7/_pyio.pyRxs cCs|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(RK(R((s/usr/lib64/python2.7/_pyio.pytdetachsN( RRRRRiRRRxR(((s/usr/lib64/python2.7/_pyio.pyRPs     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(RR9((s/usr/lib64/python2.7/_pyio.pyR sicCs4|jj||}|dkr0tdn|S(Niu#seek() returned an invalid position(R9RNR (RRLRMt new_position((s/usr/lib64/python2.7/_pyio.pyRNs cCs.|jj}|dkr*tdn|S(Niu#tell() returned an invalid position(R9ROR (RRL((s/usr/lib64/python2.7/_pyio.pyROs cCs5|j|dkr%|j}n|jj|S(N(RRRROR9RP(RRL((s/usr/lib64/python2.7/_pyio.pyRPs  cCs)|jrtdn|jjdS(Nuflush of closed file(R]RR9RR(R((s/usr/lib64/python2.7/_pyio.pyRRs cCs?|jdk r;|j r;z|jWd|jjXndS(N(R9RR]RRRT(R((s/usr/lib64/python2.7/_pyio.pyRTscCs>|jdkrtdn|j|j}d|_|S(Nuraw stream already detached(R9RRRRR(RR9((s/usr/lib64/python2.7/_pyio.pyRs    cCs |jjS(N(R9RV(R((s/usr/lib64/python2.7/_pyio.pyRVscCs |jjS(N(R9RY(R((s/usr/lib64/python2.7/_pyio.pyRYscCs |jjS(N(R9R[(R((s/usr/lib64/python2.7/_pyio.pyR[scCs|jS(N(R(R((s/usr/lib64/python2.7/_pyio.pyR9scCs |jjS(N(R9R](R((s/usr/lib64/python2.7/_pyio.pyR]scCs |jjS(N(R9RJ(R((s/usr/lib64/python2.7/_pyio.pyRJscCs |jjS(N(R9R+(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}>(RIRRJR&tformat(RtclsnameRJ((s/usr/lib64/python2.7/_pyio.pyt__repr__s    cCs |jjS(N(R9R#(R((s/usr/lib64/python2.7/_pyio.pyR# scCs |jjS(N(R9R(R((s/usr/lib64/python2.7/_pyio.pyR sN(RRRR RNRORRPRRRTRRVRYR[R}R9R]RJR+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(RhRtextendt_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]RRkR(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 RRRttypeRRRRbRk(RRdtnewposRm((s/usr/lib64/python2.7/_pyio.pyRi(s      cCs |j|S(u"This is the same as read. (Ri(RRd((s/usr/lib64/python2.7/_pyio.pyR9scCs|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 streamit(R]RR tunicodeRRRR(RRmRdRLtpadding((s/usr/lib64/python2.7/_pyio.pyRx>s    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(RRLRM((s/usr/lib64/python2.7/_pyio.pyRNPs         " cCs|jrtdn|jS(Nutell on closed file(R]RR(R((s/usr/lib64/python2.7/_pyio.pyROcs 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(RRL((s/usr/lib64/python2.7/_pyio.pyRPhs       cCs|jrtdntS(NuI/O operation on closed file.(R]RR(R((s/usr/lib64/python2.7/_pyio.pyRYws 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.pyRVs N(RRRRR RRRiRRxRNRORPRYR[RV(((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( RYR RR Rt buffer_sizet_reset_read_buftLockt _read_lock(RR9R((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(RRd((s/usr/lib64/python2.7/_pyio.pyRis 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(RRRRRR9RiR RRRRttjoinRRRb( RRdt nodata_valt empty_valuesRRLtchunkst 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(RRd((s/usr/lib64/python2.7/_pyio.pyR`s cCst||j}t|j|j}||ks@|dkr|j|}xOtry|jj|}Wn+tk r}|j t krPqPqPnXPqPW|r|j|j||_d|_qn|j|jS(Ni( RbRRRRRR9RiR RR(RRdtwantthavetto_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(RRRRRbRRR(RRd((s/usr/lib64/python2.7/_pyio.pyRs    cCs!tj|t|j|jS(N(RRORRR(R((s/usr/lib64/python2.7/_pyio.pyROsc Csd|kodkns+tdn|jQ|dkr^|t|j|j8}ntj|||}|j|SWdQXdS(Niiuinvalid whence valuei(RRRRRRRNR(RRLRM((s/usr/lib64/python2.7/_pyio.pyRNs   N(RRRR R RRRiRR`RRRORN(((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_offsetRRht _write_bufRt _write_lock(RR9Rtmax_buffer_size((s/usr/lib64/python2.7/_pyio.pyR )s       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(RRmtbeforetwrittenRtoverage((s/usr/lib64/python2.7/_pyio.pyRx8s(    "cCsL|j=|j|dkr2|jj}n|jj|SWdQXdS(N(RRRR9RORP(RRL((s/usr/lib64/python2.7/_pyio.pyRPTs    cCs|j|jWdQXdS(N(RR(R((s/usr/lib64/python2.7/_pyio.pyRR[s 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]RRR9RxRt RuntimeErrorR RRRtEAGAINR(RRdR((s/usr/lib64/python2.7/_pyio.pyR_s$    !cCstj|t|jS(N(RRORR(R((s/usr/lib64/python2.7/_pyio.pyROtsic Cs\d|kodkns+tdn|j"|jtj|||SWdQXdS(Niiuinvalid whence(RRRRRN(RRLRM((s/usr/lib64/python2.7/_pyio.pyRNws   N( RRRRR RR RxRPRRRRORN(((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( RRRRRYR R[R)treaderR(twriter(RRRRR((s/usr/lib64/python2.7/_pyio.pyR s   cCs%|dkrd}n|jj|S(Ni(RRRi(RRd((s/usr/lib64/python2.7/_pyio.pyRis  cCs|jj|S(N(RR(RRm((s/usr/lib64/python2.7/_pyio.pyRscCs|jj|S(N(RRx(RRm((s/usr/lib64/python2.7/_pyio.pyRxsicCs|jj|S(N(RR`(RRd((s/usr/lib64/python2.7/_pyio.pyR`scCs|jj|S(N(RR(RRd((s/usr/lib64/python2.7/_pyio.pyRscCs |jjS(N(RRY(R((s/usr/lib64/python2.7/_pyio.pyRYscCs |jjS(N(RR[(R((s/usr/lib64/python2.7/_pyio.pyR[scCs |jjS(N(RRR(R((s/usr/lib64/python2.7/_pyio.pyRRscCs|jj|jjdS(N(RRTR(R((s/usr/lib64/python2.7/_pyio.pyRTs cCs|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 RiRRxR`RRYR[RRRTRR}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(RXR)R R((RR9RR((s/usr/lib64/python2.7/_pyio.pyR s ic Csd|kodkns+tdn|j|jrt|j(|jj|jt|jdWdQXn|jj||}|j|jWdQX|dkrt dn|S(Niiuinvalid whenceiu seek() returned invalid position( RRRRRR9RNRRRR (RRLRM((s/usr/lib64/python2.7/_pyio.pyRNs   ,  cCs'|jrtj|Stj|SdS(N(RR(ROR)(R((s/usr/lib64/python2.7/_pyio.pyROs  cCs+|dkr|j}ntj||S(N(RROR(RP(RRL((s/usr/lib64/python2.7/_pyio.pyRPs cCs/|dkrd}n|jtj||S(Ni(RRRR)Ri(RRd((s/usr/lib64/python2.7/_pyio.pyRis   cCs|jtj||S(N(RRR)R(RRm((s/usr/lib64/python2.7/_pyio.pyRs cCs|jtj||S(N(RRR)R`(RRd((s/usr/lib64/python2.7/_pyio.pyR`s cCs|jtj||S(N(RRR)R(RRd((s/usr/lib64/python2.7/_pyio.pyRs cCsY|jrI|j2|jj|jt|jd|jWdQXntj||S(Ni( RRR9RNRRRR(Rx(RRm((s/usr/lib64/python2.7/_pyio.pyRxs   #N(RRRRR RR RNRORPRiRR`RRx(((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(RK(RRd((s/usr/lib64/python2.7/_pyio.pyRiscCs|jddS(uWrite string s to stream.uwriteN(RK(Rts((s/usr/lib64/python2.7/_pyio.pyRx!scCs|jddS(uTruncate size to pos.utruncateN(RK(RRL((s/usr/lib64/python2.7/_pyio.pyRP%scCs|jddS(u_Read until newline or EOF. Returns an empty string if EOF is hit immediately. ureadlineN(RK(R((s/usr/lib64/python2.7/_pyio.pyRn)scCs|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(RK(R((s/usr/lib64/python2.7/_pyio.pyR0scCsdS(uSubclasses should override.N(R(R((s/usr/lib64/python2.7/_pyio.pyR.9scCsdS(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.pytnewlines>scCsdS(uMError setting of the decoder or encoder. Subclasses should override.N(R(R((s/usr/lib64/python2.7/_pyio.pyR/HsN( RRRRiRxRRPRnRR}R.RR/(((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(NR/i(tcodecstIncrementalDecoderR t translatetdecodertseennlRt pendingcr(RRRR/((s/usr/lib64/python2.7/_pyio.pyR Ys    c Cs4|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 (RRtdecodeRRRjRtcountRt_LFt_CRt_CRLFRtreplace(RtinputRtoutputtcrlftcrtlf((s/usr/lib64/python2.7/_pyio.pyR`s(     + 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.pyRRs    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. icCs |dk r8t|t r8tdt|fn|d krZtd|fn|dkryddl}Wntk rd}qX|j}nt|tstd |n|dkrd }n"t|tstd |n||_ ||_ ||_ ||_ | |_ |dk|_||_|dk|_|pYtj|_d|_d|_d|_d |_d|_|jj|_|_|jr|jr|jj}|d kry|jj d Wqt!k rqXqndS(Nuillegal newline type: %ruu u u uillegal newline value: %riuasciiuinvalid encoding: %rustrictuinvalid errors: %ri(Nuu u u ("RR RRRRtlocalet ImportErrortgetpreferredencodingRt_line_bufferingt _encodingt_errorst_readuniversalt_readtranslatet_readnlt_writetranslateR!tlinesept_writenlt_encodert_decodert_decoded_charst_decoded_chars_usedt _snapshotR<RVt _seekablet_tellingR[ROt _get_encoderRt LookupError(RR<R.R/R0R:Rtposition((s/usr/lib64/python2.7/_pyio.pyR sL                   cCsEy |j}Wntk r-dj|jSXdj||jSdS(Nu$<_pyio.TextIOWrapper encoding='{0}'>u/<_pyio.TextIOWrapper name={0!r} encoding='{1}'>(RJR&RR.(RRJ((s/usr/lib64/python2.7/_pyio.pyRs   cCs|jS(N(R(R((s/usr/lib64/python2.7/_pyio.pyR.scCs|jS(N(R(R((s/usr/lib64/python2.7/_pyio.pyR/scCs|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.pyRVs cCs |jjS(N(R<RY(R((s/usr/lib64/python2.7/_pyio.pyRYscCs |jjS(N(R<R[(R((s/usr/lib64/python2.7/_pyio.pyR[scCs|jj|j|_dS(N(R<RRRR(R((s/usr/lib64/python2.7/_pyio.pyRRs cCs?|jdk r;|j r;z|jWd|jjXndS(N(R<RR]RRRT(R((s/usr/lib64/python2.7/_pyio.pyRT#scCs |jjS(N(R<R](R((s/usr/lib64/python2.7/_pyio.pyR]*scCs |jjS(N(R<RJ(R((s/usr/lib64/python2.7/_pyio.pyRJ.scCs |jjS(N(R<R#(R((s/usr/lib64/python2.7/_pyio.pyR#2scCs |jjS(N(R<R(R((s/usr/lib64/python2.7/_pyio.pyR5sc Cs"|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|jnd|_|jr|jjn|S(Nuwrite to closed fileucan't write %s to text streamu u (R]RR RRRIRRRRRRRRtencodeR<RxRRRRRR(RRtlengththaslftencoderRm((s/usr/lib64/python2.7/_pyio.pyRx8s$     cCs+tj|j}||j|_|jS(N(RtgetincrementalencoderRRR(Rt make_encoder((s/usr/lib64/python2.7/_pyio.pyRMscCsLtj|j}||j}|jr?t||j}n||_|S(N(RtgetincrementaldecoderRRRRRR(Rt make_decoderR((s/usr/lib64/python2.7/_pyio.pyt _get_decoderRs   cCs||_d|_dS(uSet the _decoded_chars buffer.iN(RR(Rtchars((s/usr/lib64/python2.7/_pyio.pyt_set_decoded_chars]s cCsR|j}|dkr%|j|}n|j|||!}|jt|7_|S(u'Advance into the _decoded_chars buffer.N(RRRR(RRdtoffsetR((s/usr/lib64/python2.7/_pyio.pyt_get_decoded_charsbs   cCs1|j|krtdn|j|8_dS(u!Rewind the _decoded_chars buffer.u"rewind decoded_chars out of boundsN(RtAssertionError(RRd((s/usr/lib64/python2.7/_pyio.pyt_rewind_decoded_charslscCs|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_chunkrs   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(RtbiginttrestRRR R R((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 RRRR<RORRRRRRRRRRRR(RRRRt next_inputRt saved_statet start_post start_flagst bytes_fedt chars_decodedR t next_byteR((s/usr/lib64/python2.7/_pyio.pyROsN              cCs5|j|dkr%|j}n|jj|S(N(RRRROR<RP(RRL((s/usr/lib64/python2.7/_pyio.pyRPs  cCs>|jdkrtdn|j|j}d|_|S(Nubuffer is already detached(R<RRRRR(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 RORRR<RNRRRRRRRRRiRRRRRRR( RtcookieRMRRRR R RR R((s/usr/lib64/python2.7/_pyio.pyRNsf                   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(RZRRRRR&RRRR<RiRRRRRR (RRdRtresultR ((s/usr/lib64/python2.7/_pyio.pyRi9s(          !cCs=t|_|j}|s9d|_|j|_tn|S(N(RRRnRRRRp(RRq((s/usr/lib64/python2.7/_pyio.pyRrRs     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 RRRRRRRRaRRRR RRRR(RReRqtstartRLtendpostnlpostcrpos((s/usr/lib64/python2.7/_pyio.pyRn[sp                           cCs|jr|jjSdS(N(RRR(R((s/usr/lib64/python2.7/_pyio.pyRsN('RRRRRRR RR}R.R/R:R<RVRYR[RRRTR]RJR#RRxRRRRRR RRRORPRRNRiRrRnR(((s/usr/lib64/python2.7/_pyio.pyR*sH  9             "  >   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-8R/ustrictR0i( R R!R RRRRR RRxRN(Rt initial_valueR0((s/usr/lib64/python2.7/_pyio.pyR s   cCs)|j|jjj|j|jS(N(RRR<RRRR(R((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.pyR/scCsdS(N(R(R((s/usr/lib64/python2.7/_pyio.pyR.scCs|jddS(Nudetach(RK(R((s/usr/lib64/python2.7/_pyio.pyRs( RRRR RRR}R/R.R(((s/usr/lib64/python2.7/_pyio.pyR!s  (1Rt __future__RRR!RzRRRtthreadRRRt dummy_threadtioRRRRRRR|R R RRRR=R>RBRRGRHtregisterR~t_ioRRRRR)R(RR'RRRR*R!(((s/usr/lib64/python2.7/_pyio.pytsX       "    < TjvaHI?U