U e5dk@sxddlZddlZddlZddlZddlZddlZddlmZej dkrTddl m Z ndZ ddl Z ddl mZmZmZmZdddhZeedreejeejd ZeZeed pejjZd6ddZddZz e jZWnek reZYnXGdddZ GdddZ!z e j"Z"Wn(ek rDGddde#e$Z"YnXGdddej%dZ&e j&'e&Gddde&Z(e j('e(ddl)m*Z*e('e*Gddde&Z+e j+'e+Gd d!d!e+Z,Gd"d#d#e+Z-Gd$d%d%e,Z.Gd&d'd'e,Z/Gd(d)d)e+Z0Gd*d+d+e/e.Z1Gd,d-d-e(Z*Gd.d/d/e&Z2e j2'e2Gd0d1d1ej3Z4Gd2d3d3e2Z5Gd4d5d5e5Z6dS)7N) allocate_lock>win32cygwin)setmode)__all__SEEK_SETSEEK_CURSEEK_END SEEK_HOLEi ZgettotalrefcountrTc Cst|tst|}t|tttfs0td|t|tsFtd|t|ts\td||dk rzt|tsztd||dk rt|tstd|t|}|tdst|t|krt d|d|k} d|k} d |k} d |k} d |k} d |k}d |k}d|krD| s"| s"| s"| r*t dddl }| dt dd} |rX|rXt d| | | | dkrvt d| s| s| s| st d|r|dk rt d|r|dk rt d|r|dk rt d|r|dkrddl }| dt dt|| rdpd| r"dp$d| r2d p4d| rBd pDd| rRd pTd||d}|}z$d}|dks|dkr|rd}d}|dkrt}zt|j}Wnttfk rYnX|dkr|}|dkrt d |dkr|r|WSt d!| r t||}n<| s2| s2| r>t||}n| rPt||}n t d"||}|rl|WSt|||||}|}||_|WS|YnXdS)#Nzinvalid file: %rzinvalid mode: %rzinvalid buffering: %rinvalid encoding: %rinvalid errors: %rzaxrwb+tUxr wa+tbUz4mode U cannot be combined with 'x', 'w', 'a', or '+'rz'U' mode is deprecatedr Tz'can't have text and binary mode at oncer z)can't have read/write/append mode at oncez/must have exactly one of read/write/append modez-binary mode doesn't take an encoding argumentz+binary mode doesn't take an errors argumentz+binary mode doesn't take a newline argumentzaline buffering (buffering=1) isn't supported in binary mode, the default buffer size will be used)openerFrzinvalid buffering sizezcan't have unbuffered text I/Ozunknown mode: %r) isinstanceintosfspathstrbytes TypeErrorsetlen ValueErrorwarningswarnDeprecationWarningRuntimeWarningFileIOisattyDEFAULT_BUFFER_SIZEfstatfileno st_blksizeOSErrorAttributeErrorBufferedRandomBufferedWriterBufferedReader TextIOWrappermodeclose)filer4 bufferingencodingerrorsnewlineclosefdrZmodesZcreatingZreadingZwritingZ appendingZupdatingtextZbinaryr$rawresultline_bufferingZbsbufferrA/usr/lib64/python3.8/_pyio.pyopen)s{                    rCcCs ddl}|dtdt|dS)Nrz(_pyio.open_code() may not be using hooksr rb)r$r%r'rC)pathr$rArArB_open_code_with_warnings rFc@seZdZdddZdS) DocDescriptorNcCs dtjS)Nz\open(file, mode='r', buffering=-1, encoding=None, errors=None, newline=None, closefd=True) )rC__doc__)selfobjtyprArArB__get__szDocDescriptor.__get__)N)__name__ __module__ __qualname__rLrArArArBrGsrGc@seZdZeZddZdS) OpenWrappercOs t||SN)rC)clsargskwargsrArArB__new__,szOpenWrapper.__new__N)rMrNrOrGrHrUrArArArBrP"srPc@s eZdZdS)UnsupportedOperationN)rMrNrOrArArArBrV5srVc@seZdZddZd5ddZddZd6d d Zd d Zd ZddZ ddZ ddZ d7ddZ ddZ d8ddZddZd9ddZeddZd:d d!Zd"d#Zd$d%Zd&d'Zd(d)Zd;d+d,Zd-d.Zd/d0Zdd}|sdS|ddp&t|}dkr:t|}|S)Nr  r)r{findr"min)Z readaheadnrIsizerArB nreadaheads  z#IOBase.readline..nreadaheadcSsdSNr rArArArArBr sr is not an integerrr|) hasattr __index__r/r bytearrayr"readendswithr)rIrr size_indexresrrArrBreadline s&     zIOBase.readlinecCs ||SrQrfrarArArB__iter__5szIOBase.__iter__cCs|}|st|SrQ)r StopIterationrIlinerArArB__next__9szIOBase.__next__cCsP|dks|dkrt|Sd}g}|D]&}|||t|7}||kr$qLq$|SNr)listappendr")rIZhintrlinesrrArArB readlines?s  zIOBase.readlinescCs ||D]}||q dSrQ)rgwrite)rIrrrArArB writelinesQszIOBase.writelines)r)N)N)N)N)N)r)N)rMrNrOrZr[rbrdrhrir5rlrnrqrrrsrtrupropertyrjrgryrzr,r)rrrrrrArArArBrW9s4#         * rW) metaclassc@s.eZdZd ddZddZddZdd Zd S) RawIOBasercCsP|dkr d}|dkr|St|}||}|dkr>dS||d=t|S)Nrr)readallrrreadintor)rIrrrrArArBrls   zRawIOBase.readcCs4t}|t}|sq ||7}q|r,t|S|SdSrQ)rrr*r)rIrdatarArArBr}s  zRawIOBase.readallcCs|ddS)Nrr\rIrrArArBrszRawIOBase.readintocCs|ddSNrr\rrArArBrszRawIOBase.writeN)r)rMrNrOrrrrrArArArBr^s r)r(c@sHeZdZdddZdddZddZdd Zd d Zd d ZddZ dS)BufferedIOBasercCs|ddSNrr\rrArArBrszBufferedIOBase.readcCs|ddS)Nread1r\rrArArBrszBufferedIOBase.read1cCs|j|ddS)NFr _readintorrArArBrs zBufferedIOBase.readintocCs|j|ddS)NTrrrrArArB readinto1s zBufferedIOBase.readinto1cCsVt|tst|}|d}|r0|t|}n|t|}t|}||d|<|SNB)r memoryviewcastrr"r)rIrrrrrArArBrs   zBufferedIOBase._readintocCs|ddSrr\rrArArBrs zBufferedIOBase.writecCs|ddSNdetachr\rarArArBrszBufferedIOBase.detachN)r)r) rMrNrOrrrrrrrrArArArBrs    rc@seZdZddZd#ddZddZd$d d Zd d Zd dZddZ ddZ e ddZ e ddZ e ddZe ddZddZddZdd Zd!d"ZdS)%_BufferedIOMixincCs ||_dSrQ_rawrIr=rArArB__init__sz_BufferedIOMixin.__init__rcCs"|j||}|dkrtd|S)Nrz#seek() returned an invalid position)r=r[r.)rIr^r_Z new_positionrArArBr[sz_BufferedIOMixin.seekcCs|j}|dkrtd|S)Nrz#tell() returned an invalid position)r=rbr.rerArArBrbs z_BufferedIOMixin.tellNcCs$||dkr|}|j|SrQ)rhrbr=rdrerArArBrd$sz_BufferedIOMixin.truncatecCs|jrtd|jdS)Nflush on closed file)rjr#r=rhrarArArBrh2sz_BufferedIOMixin.flushcCs.|jdk r*|js*z |W5|jXdSrQ)r=rjr5rhrarArArBr57s z_BufferedIOMixin.closecCs*|jdkrtd||j}d|_|S)Nzraw stream already detached)r=r#rhrrrArArBr?s  z_BufferedIOMixin.detachcCs |jSrQ)r=rnrarArArBrnIsz_BufferedIOMixin.seekablecCs|jSrQrrarArArBr=Lsz_BufferedIOMixin.rawcCs|jjSrQ)r=rjrarArArBrjPsz_BufferedIOMixin.closedcCs|jjSrQ)r=rYrarArArBrYTsz_BufferedIOMixin.namecCs|jjSrQ)r=r4rarArArBr4Xsz_BufferedIOMixin.modecCstd|jjddSNzcannot pickle z objectr rXrMrarArArB __getstate__\sz_BufferedIOMixin.__getstate__cCsN|jj}|jj}z |j}Wn tk r:d||YSXd|||SdS)Nz<{}.{}>z<{}.{} name={!r}>)rXrNrOrYr/format)rImodnameZclsnamerYrArArB__repr___s z_BufferedIOMixin.__repr__cCs |jSrQ)r=r,rarArArBr,ksz_BufferedIOMixin.filenocCs |jSrQ)r=r)rarArArBr)nsz_BufferedIOMixin.isatty)r)N)rMrNrOrr[rbrdrhr5rrnrr=rjrYr4rrr,r)rArArArBr s(         rcseZdZdZd ddZddZddZdd Zfd d Zd!d dZ d"ddZ ddZ d#ddZ ddZ d$ddZddZddZddZZS)%BytesIONcCs&t}|dk r||7}||_d|_dSr)r_buffer_pos)rIZ initial_bytesbufrArArBrzs zBytesIO.__init__cCs|jrtd|jS)Nz__getstate__ on closed file)rjr#__dict__copyrarArArBrszBytesIO.__getstate__cCs|jrtdt|jS)Nzgetvalue on closed file)rjr#rrrarArArBgetvalueszBytesIO.getvaluecCs|jrtdt|jS)Nzgetbuffer on closed file)rjr#rrrarArArB getbufferszBytesIO.getbuffercs"|jdk r|jtdSrQ)rclearsuperr5rarXrArBr5s  z BytesIO.closercCs|jrtd|dkrd}n4z |j}Wn"tk rHt|dYnX|}|dkrbt|j}t|j|jkrvdStt|j|j|}|j|j|}||_t |S)Nread from closed filerrr) rjr#rr/r r"rrr~r)rIrrZnewposrrArArBrs"  z BytesIO.readcCs ||SrQ)rrrArArBrsz BytesIO.read1c Cs|jrtdt|tr tdt| }|j}W5QRX|dkrFdS|j}|t|j krzd|t|j }|j |7_ ||j |||<|j|7_|S)Nwrite to closed file can't write str to binary streamr) rjr#rrr rnbytesrr"r)rIrZviewrr^ZpaddingrArArBrs  z BytesIO.writercCs|jrtdz |j}Wn"tk r:t|dYnX|}|dkrh|dkr`td|f||_nD|dkrtd|j||_n(|dkrtdt|j||_ntd|jS)Nzseek on closed filerrnegative seek position %rr r zunsupported whence value) rjr#rr/r rmaxr"r)rIr^r_ pos_indexrArArBr[s" z BytesIO.seekcCs|jrtd|jS)Ntell on closed file)rjr#rrarArArBrbsz BytesIO.tellcCsx|jrtd|dkr|j}nJz |j}Wn"tk rJt|dYnX|}|dkrhtd|f|j|d=|S)Nztruncate on closed filerrznegative truncate position %r)rjr#rrr/r r)rIr^rrArArBrds  zBytesIO.truncatecCs|jrtddSNrwTrxrarArArBrrszBytesIO.readablecCs|jrtddSrrxrarArArBrtszBytesIO.writablecCs|jrtddSrrxrarArArBrnszBytesIO.seekable)N)r)r)r)N)rMrNrOrrrrrr5rrrr[rbrdrrrtrn __classcell__rArArrBrrs      rc@steZdZefddZddZddZddd Zdd d Zdd dZ dddZ dddZ ddZ ddZ dddZdS) r2cCsF|stdt|||dkr,td||_|t|_dS)Nz "raw" argument must be readable.rinvalid buffer size) rrr.rrr# buffer_size_reset_read_bufLock _read_lockrIr=rrArArBr s zBufferedReader.__init__cCs |jSrQ)r=rrrarArArBrrszBufferedReader.readablecCsd|_d|_dS)Nrr) _read_buf _read_posrarArArBrszBufferedReader._reset_read_bufNc Cs@|dk r|dkrtd|j||W5QRSQRXdS)Nrzinvalid number of bytes to read)r#r_read_unlockedrrArArBr szBufferedReader.readc Csd}d}|j}|j}|dks$|dkr|t|jdrj|j}|dkrZ||dpXdS||d|S||dg}d}|j}||kr|}q|t|7}||q|d |p|St||} || kr|j|7_||||S||dg}t |j |} | |krH|j| }||kr.|}qH| t|7} ||qt || }d |} | |d|_d|_| r| d|S|S)Nr)rNrrr) rrrrr=rrr"rjoinrrr~) rIrZ nodata_valZ empty_valuesrr^chunkZchunksZ current_sizeavailZwantedoutrArArBr-sL             zBufferedReader._read_unlockedrc Cs(|j||W5QRSQRXdSrQ)r_peek_unlockedrrArArBr{aszBufferedReader.peekcCsrt||j}t|j|j}||ks,|dkrb|j|}|j|}|rb|j|jd||_d|_|j|jdSr)r~rr"rrr=r)rIrZwantZhaveZto_readZcurrentrArArBrks   zBufferedReader._peek_unlockedrc Cs^|dkr|j}|dkrdS|j4|d|t|t|j|jW5QRSQRXdS)Nrrr )rrrrr~r"rrrrArArBrvs zBufferedReader.read1c Cs t|tst|}|jdkr dS|d}d}|j|t|krtt|j|jt|}|r|j|j|j|||||<|j|7_||7}|t|krqt|||j kr|j ||d}|sq||7}n|r|s| dsq|r6|r6qq6W5QRX|S)Nrrr ) rrrrrr"r~rrrr=rr)rIrrwrittenrrrArArBrs6       zBufferedReader._readintocCst|t|j|jSrQ)rrbr"rrrarArArBrbszBufferedReader.tellc Csd|tkrtd|jD|dkr4|t|j|j8}t|||}||W5QRSQRXdS)Ninvalid whence valuer ) valid_seek_flagsr#rr"rrrr[rr]rArArBr[szBufferedReader.seek)N)N)r)r)r)r)rMrNrOr*rrrrrrr{rrrrbr[rArArArBr2s  4 .r2c@s\eZdZefddZddZddZddd Zd d Zd d Z ddZ dddZ ddZ dS)r1cCsF|stdt|||dkr,td||_t|_t|_ dS)Nz "raw" argument must be writable.rr) rtr.rrr#rr _write_bufr _write_lockrrArArBrs zBufferedWriter.__init__cCs |jSrQ)r=rtrarArArBrtszBufferedWriter.writablec Cst|trtd|j|jr(tdt|j|jkr@| t|j}|j |t|j|}t|j|jkrz | Wnlt k r}zNt|j|jkrt|j|j}||8}|jd|j|_t |j |j |W5d}~XYnX|W5QRSQRXdS)Nrr)rrr rrjr#r"rr_flush_unlockedextendBlockingIOErrorerrnostrerror)rIrZbeforereZoveragerArArBrs(    "zBufferedWriter.writeNc CsD|j4||dkr"|j}|j|W5QRSQRXdSrQ)rrr=rbrdrerArArBrds  zBufferedWriter.truncatec Cs|j|W5QRXdSrQ)rrrarArArBrhszBufferedWriter.flushcCs|jrtd|jrz|j|j}Wntk rBtdYnX|dkrZttjdd|t |jksp|dkrxt d|jd|=qdS)NrzHself.raw should implement RawIOBase: it should not raise BlockingIOErrorz)write could not complete without blockingrz*write() returned incorrect number of bytes) rjr#rr=rr RuntimeErrorrZEAGAINr"r.rIrrArArBrs zBufferedWriter._flush_unlockedcCst|t|jSrQ)rrbr"rrarArArBrbszBufferedWriter.tellrc CsD|tkrtd|j$|t|||W5QRSQRXdS)Nr)rr#rrrr[r]rArArBr[s zBufferedWriter.seekcCs`|j$|jdks|jr&W5QRdSW5QRXz |W5|j|jW5QRXXdSrQ)rr=rjr5rhrarArArBr5s zBufferedWriter.close)N)r) rMrNrOr*rrtrrdrhrrbr[r5rArArArBr1s   r1c@seZdZefddZdddZddZdd Zdd d Zd d dZ ddZ ddZ ddZ ddZ ddZddZeddZdS)!BufferedRWPaircCs<|std|s tdt|||_t|||_dS)Nz#"reader" argument must be readable.z#"writer" argument must be writable.)rrr.rtr2readerr1writer)rIrrrrArArBr<s  zBufferedRWPair.__init__rcCs|dkr d}|j|SNr)rrrrArArBrJszBufferedRWPair.readcCs |j|SrQ)rrrrArArBrOszBufferedRWPair.readintocCs |j|SrQ)rrrrArArBrRszBufferedRWPair.writercCs |j|SrQ)rr{rrArArBr{UszBufferedRWPair.peekcCs |j|SrQ)rrrrArArBrXszBufferedRWPair.read1cCs |j|SrQ)rrrrArArBr[szBufferedRWPair.readinto1cCs |jSrQ)rrrrarArArBrr^szBufferedRWPair.readablecCs |jSrQ)rrtrarArArBrtaszBufferedRWPair.writablecCs |jSrQ)rrhrarArArBrhdszBufferedRWPair.flushcCs z|jW5|jXdSrQ)rr5rrarArArBr5gszBufferedRWPair.closecCs|jp|jSrQ)rr)rrarArArBr)mszBufferedRWPair.isattycCs|jjSrQ)rrjrarArArBrjpszBufferedRWPair.closedN)r)r)r)rMrNrOr*rrrrr{rrrrrtrhr5r)rrjrArArArBr,s    rc@sjeZdZefddZdddZddZdd d Zdd d Zd dZ dddZ dddZ ddZ ddZ dS)r0cCs(|t|||t|||dSrQ)rqr2rr1rrArArBr~szBufferedRandom.__init__rc Cs|tkrtd||jrJ|j |j|jt|jdW5QRX|j||}|j| W5QRX|dkrt d|S)Nrr rz seek() returned invalid position) rr#rhrrr=r[rr"rr.r]rArArBr[s$zBufferedRandom.seekcCs|jrt|St|SdSrQ)rr1rbr2rarArArBrbs zBufferedRandom.tellNcCs|dkr|}t||SrQ)rbr1rdrerArArBrdszBufferedRandom.truncatecCs |dkr d}|t||Sr)rhr2rrrArArBrszBufferedRandom.readcCs|t||SrQ)rhr2rrrArArBrszBufferedRandom.readintocCs|t||SrQ)rhr2r{rrArArBr{szBufferedRandom.peekrcCs|t||SrQ)rhr2rrrArArBrszBufferedRandom.read1cCs|t||SrQ)rhr2rrrArArBrszBufferedRandom.readinto1c CsF|jr:|j(|j|jt|jd|W5QRXt||Sr) rrr=r[rr"rr1rrrArArBrs zBufferedRandom.write)r)N)N)r)r)rMrNrOr*rr[rbrdrrr{rrrrArArArBr0us      r0cseZdZdZdZdZdZdZdZdZ d0ddZ dd Z d d Z d d Z ddZd1ddZd2ddZddZddZddZefddZddZd3ddZfd d!Zd"d#Zd$d%Zd&d'Zd(d)Zd*d+Zed,d-Zed.d/Z Z!S)4r(rFNTr c CsB|jdkr*z|jrt|jW5d|_Xt|trsz"FileIO.__init__..r rzKMust have exactly one of create/read/write/append mode and at most one plusrTr rrO_BINARYZ O_NOINHERIT O_CLOEXECz'Cannot use closefd=False with file nameizexpected integer from openerzNegative file descriptorFr-)-_fd_closefdrr5rfloatr rr#rr!sumcount_created _writableO_EXCLO_CREAT _readableO_TRUNC _appendingO_APPENDO_RDWRO_RDONLYO_WRONLYgetattrrCr.set_inheritabler+statS_ISDIRst_modeIsADirectoryErrorrZEISDIRrr/_blksizer*_setmoderrYlseekr ZESPIPE) rIr6r4r;rfdflagsZnoinherit_flagZowned_fdZfdfstatrrArArBrs     $                    zFileIO.__init__cCsB|jdkr>|jr>|js>ddl}|jd|ftd|d|dS)Nrzunclosed file %rr ) stacklevelsource)rrrjr$r%ResourceWarningr5)rIr$rArArBrlAszFileIO.__del__cCstd|jjddSrrrarArArBrHszFileIO.__getstate__cCspd|jj|jjf}|jr"d|Sz |j}Wn*tk rVd||j|j|jfYSXd|||j|jfSdS)Nz%s.%sz <%s [closed]>z<%s fd=%d mode=%r closefd=%r>z<%s name=%r mode=%r closefd=%r>) rXrNrOrjrYr/rr4r)rI class_namerYrArArBrKs  zFileIO.__repr__cCs|jstddS)NzFile not open for reading)rrVrarArArBrsYszFileIO._checkReadablecCs|jstddS)NzFile not open for writing)rrVrorArArBru]szFileIO._checkWritablecCsT|||dks |dkr(|Szt|j|WStk rNYdSXdSr)rgrsrrrrrrrArArBrasz FileIO.readcCs||t}z6t|jdt}t|jj}||krH||d}Wnt k r^YnXt }t ||krt |}|t |t7}|t |}zt |j|}Wntk r|rYqYdSX|sq||7}qft|Sr`)rgrsr*rr rrr+st_sizer.rr"rrrr)rIbufsizer^endr>rrrArArBrqs2   zFileIO.readallcCs4t|d}|t|}t|}||d|<|Sr)rrrr")rIrmrrrArArBrs  zFileIO.readintocCs<||zt|j|WStk r6YdSXdSrQ)rgrurrrrrrArArBrs z FileIO.writecCs*t|trtd|t|j||S)Nzan integer is required)rrr rgrr rr]rArArBr[s z FileIO.seekcCs|t|jdtSr)rgrr rrrarArArBrbsz FileIO.tellcCs2|||dkr |}t|j||SrQ)rgrurbr ftruncaterrrArArBrds zFileIO.truncatecs.|js*z|jrt|jW5tXdSrQ)rjrr5rrrrarrArBr5s z FileIO.closecCsF||jdkr@z |Wntk r8d|_YnXd|_|jS)NFT)rg _seekablerbr.rarArArBrns   zFileIO.seekablecCs||jSrQ)rgrrarArArBrrszFileIO.readablecCs||jSrQ)rgrrarArArBrtszFileIO.writablecCs||jSrQ)rgrrarArArBr,sz FileIO.filenocCs|t|jSrQ)rgrr)rrarArArBr)sz FileIO.isattycCs|jSrQ)rrarArArBr;szFileIO.closefdcCsJ|jr|jrdSdSn0|jr,|jr&dSdSn|jrB|jrd?Z#dRd@dAZ$dBdCZ%dSdDdEZ&dTdFdGZ'dHdIZ(dUdJdKZ)e dLdMZ*dS)Vr3iNFc Cs|||dkrvzt|}Wnttfk r<YnX|dkrvz ddl}Wntk rjd}Yn X|d}t |t st d|t |jsd}t|||dkrd}nt |t st d|||_d|_d|_d|_|j|_|_t|jd |_||||||dS) NrasciiFrzG%r is not a text encoding; use codecs.open() to handle arbitrary codecsrrrr)_check_newlinerdevice_encodingr,r/rVlocale ImportErrorZgetpreferredencodingrrr#r lookup_is_text_encoding LookupErrorr_decoded_chars_decoded_chars_used _snapshotr@rnr_tellingr _has_read1 _configure) rIr@r8r9r:r? write_throughr<rprArArBrs>           zTextIOWrapper.__init__cCs>|dk r$t|ts$tdt|f|dkr:td|fdS)Nzillegal newline type: %r)Nrr*r(r)zillegal newline value: %r)rrr typer#)rIr:rArArBr:szTextIOWrapper._check_newlinecCs||_||_d|_d|_d|_| |_|dk|_||_|dk|_|pHt j |_ ||_ ||_ |jr|r|j}|dkrz|dWntk rYnXdS)Nrr) _encoding_errors_encoder_decoder _b2cratio_readuniversal_readtranslate_readnl_writetranslaterlinesep_writenl_line_buffering_write_throughrrtr@rb _get_encoderr5r@)rIr8r9r:r?rGpositionrArArBrFs&    zTextIOWrapper._configurecCsd|jj|jj}z |j}Wntk r2YnX|d|7}z |j}Wntk r`YnX|d|7}|d|jS)Nz<{}.{}z name={0!r}z mode={0!r}z encoding={0!r}>)rrXrNrOrYr/r4r8)rIr>rYr4rArArBr!s   zTextIOWrapper.__repr__cCs|jSrQ)rJrarArArBr82szTextIOWrapper.encodingcCs|jSrQ)rKrarArArBr96szTextIOWrapper.errorscCs|jSrQ)rUrarArArBr?:szTextIOWrapper.line_bufferingcCs|jSrQ)rVrarArArBrG>szTextIOWrapper.write_throughcCs|jSrQ)rrarArArBr@BszTextIOWrapper.buffer)r8r9r:r?rGcCs|jdk r*|dk s"|dk s"|tk r*td|dkrH|dkrB|j}q^d}nt|ts^td||dkrn|j}nt|tstd||tkr|j}| ||dkr|j }|dkr|j }| | |||||dS)NzPIt is not possible to set the encoding or newline of stream after the first readrrr)rMEllipsisrVrKrrr rJrQr:r?rGrhrF)rIr8r9r:r?rGrArArB reconfigureFs@       zTextIOWrapper.reconfigurecCs|jrtd|jSrv)rjr#rrarArArBrnoszTextIOWrapper.seekablecCs |jSrQ)r@rrrarArArBrrtszTextIOWrapper.readablecCs |jSrQ)r@rtrarArArBrtwszTextIOWrapper.writablecCs|j|j|_dSrQ)r@rhrrDrarArArBrhzs zTextIOWrapper.flushcCs.|jdk r*|js*z |W5|jXdSrQ)r@rjr5rhrarArArBr5~s zTextIOWrapper.closecCs|jjSrQ)r@rjrarArArBrjszTextIOWrapper.closedcCs|jjSrQ)r@rYrarArArBrYszTextIOWrapper.namecCs |jSrQ)r@r,rarArArBr,szTextIOWrapper.filenocCs |jSrQ)r@r)rarArArBr)szTextIOWrapper.isattycCs|jrtdt|ts(td|jjt|}|js<|j oBd|k}|rf|jrf|j dkrf| d|j }|j pr| }||}|j||j r|sd|kr||dd|_|jr|j|S)Nrzcan't write %s to text streamr*r(r)rjr#rrr rXrMr"rRrUrTr/rLrWencoder@rrh_set_decoded_charsrCrMr7)rIrZlengthZhaslfencoderrrArArBrs(     zTextIOWrapper.writecCst|j}||j|_|jSrQ)r getincrementalencoderrJrKrL)rIZ make_encoderrArArBrWs  zTextIOWrapper._get_encodercCs2t|j}||j}|jr(t||j}||_|SrQ)r getincrementaldecoderrJrKrOrrPrM)rIZ make_decoderr#rArArB _get_decoders    zTextIOWrapper._get_decodercCs||_d|_dSr)rArB)rIcharsrArArBr\sz TextIOWrapper._set_decoded_charscCsF|j}|dkr|j|d}n|j|||}|jt|7_|SrQ)rBrAr")rIroffsetrarArArB_get_decoded_charss z TextIOWrapper._get_decoded_charscCs$|j|krtd|j|8_dS)Nz"rewind decoded_chars out of bounds)rBAssertionErrorrrArArB_rewind_decoded_charss z#TextIOWrapper._rewind_decoded_charscCs|jdkrtd|jr&|j\}}|jr<|j|j}n|j|j}| }|j ||}| ||rt |t |j |_ nd|_ |jr|||f|_| S)Nz no decoderrI)rMr#rDr2rEr@r _CHUNK_SIZErr+r\r"rArNrC)rI dec_buffer dec_flags input_chunkeofZ decoded_charsrArArB _read_chunks  zTextIOWrapper._read_chunkrcCs(||d>B|d>B|d>Bt|d>BS)N@)r4)rIrXrh bytes_to_feedneed_eof chars_to_skiprArArB _pack_cookies  zTextIOWrapper._pack_cookiecCsFt|d\}}t|d\}}t|d\}}t|d\}}|||||fS)Nl)divmod)rIZbigintrestrXrhrprqrrrArArB_unpack_cookie s zTextIOWrapper._unpack_cookiec Cs@|jstd|jstd||j}|j}|dksF|jdkrX|j rTt d|S|j\}}|t |8}|j }|dkr| ||S|}zt|j|}d}|dkr"|d|ft ||d|} | |kr|\} } | s| }|| 8}q4|t | 8}d}q||8}|d}qd}|d|f||} |} |dkrZ| | | WSd}d}d}t|t |D]x}|d7}|t ||||d7}|\}}|s||kr| |7} ||8}|dd} }}||krtqqt|t |jddd 7}d}||krtd | | | |||WS||XdS) N!underlying stream is not seekablez(telling position disabled by next() callzpending decoded textrr rr Tr&z'can't reconstruct logical file position)rrVrDr.rhr@rbrMrCrArdr"rBrsr2r5rrNr+range)rIrXr#rhZ next_inputrrZ saved_stateZ skip_bytesZ skip_backrrd start_posZ start_flagsZ bytes_fedrqZ chars_decodedirgrArArBrb s              zTextIOWrapper.tellcCs$||dkr|}|j|SrQ)rhrbr@rdrerArArBrdm szTextIOWrapper.truncatecCs*|jdkrtd||j}d|_|S)Nzbuffer is already detached)r@r#rhr)rIr@rArArBrs s  zTextIOWrapper.detachc sfdd}jrtdjs(td|tkrN|dkr@tdd}}nZ|tkr|dkrftdj d|} dd_ j rj |||S|dkrtd |f|dkrtd |f|\}}}}} j | dd_ |dkr*j r*j n@j s>|s>| rjj pL_ j d |f|d f_ | rj|} j | ||| f_ tj| krtd | _|||S) NcsHzjp}Wntk r&YnX|dkr<|dn|dSr)rLrWr@r5r7)rXr]rarArB_reset_encoder| s z*TextIOWrapper.seek.._reset_encoderrrwrz#can't do nonzero cur-relative seeksz#can't do nonzero end-relative seeksrzunsupported whence (%r)rrz#can't restore logical file position)rjr#rrVrrbr rhr@r[r\rCrMr7rvr`r5rr+r"rAr.rB) rIZcookier_r|rXrzrhrprqrrrirArarBr[{ s`            zTextIOWrapper.seekcCs||dkrd}n4z |j}Wn"tk rBt|dYnX|}|jpV|}|dkr||j|j dd}| dd|_ |Sd}||}t ||kr|s| }|||t |7}q|SdS)NrrrTr&rF)rsrr/r rMr`rcr+r@rr\rCr"rk)rIrrr#r>rjrArArBr s,    zTextIOWrapper.readcCs(d|_|}|s$d|_|j|_t|Srm)rDrrCrrrrArArBr szTextIOWrapper.__next__c Cs |jrtd|dkrd}n4z |j}Wn"tk rHt|dYnX|}|}d}|jsj|d}}|jr| d|}|dkr|d}qnt |}n|j rF| d|}| d|}|dkr|dkrt |}n |d}qnX|dkr|d}qn@||kr|d}qn(||dkr8|d}qn |d}qn(| |j }|dkrn|t |j }q|dkrt ||kr|}q| r|jrqq|jr||7}qr|d d|_|Sqr|dkr||kr|}|t |||d|S) Nrrrrr*r r(r r)rjr#rr/r rcrMr`rPr}r"rOrQrkrAr\rCre) rIrrrstartr^endposZnlposZcrposrArArBr st            zTextIOWrapper.readlinecCs|jr|jjSdSrQ)rMrrarArArBrH szTextIOWrapper.newlines)NNNFF)NNNFF)N)rrrr)N)r)N)N)+rMrNrOrfrrr:rFrrr8r9r?rGr@rYrZrnrrrtrhr5rjrYr,r)rrWr`r\rcrerkrsrvrbrdrr[rrrrrArArArBr3sz ( $      )    * c  K  ]r3csNeZdZdfdd ZddZddZed d Zed d Zd dZ Z S)StringIOrr*csftt|jtdd|d|dkr(d|_|dk rbt|tsNtdt |j | || ddS)Nzutf-8 surrogatepass)r8r9r:Fz*initial_value must be str or None, not {0}r) rrrrrRrrr rrHrMrr[)rIZ initial_valuer:rrArBrT s  zStringIO.__init__c CsP||jp|}|}|z|j|jddWS||XdS)NTr&) rhrMr`r2r7r5r+r@r)rIr#Z old_staterArArBrd szStringIO.getvaluecCs t|SrQ)objectrrarArArBrn szStringIO.__repr__cCsdSrQrArarArArBr9s szStringIO.errorscCsdSrQrArarArArBr8w szStringIO.encodingcCs|ddSrr\rarArArBr{ szStringIO.detach)rr*) rMrNrOrrrrr9r8rrrArArrBrM s   r)r rNNNTN)7rabcr rrsys_threadrrplatformZmsvcrtrr iorrrr rraddr SEEK_DATAr*rrdev_moderkrCrF open_coder/rGrPrVr.r#ABCMetarWregisterr_ior(rrrr2r1rr0rr!rr3rrArArArBs       [    $ =   g hCiIJY@ U$