AlkantarClanX12

Your IP : 18.117.71.213


Current Path : /opt/alt/python37/lib64/python3.7/__pycache__/
Upload File :
Current File : //opt/alt/python37/lib64/python3.7/__pycache__/_pyio.cpython-37.opt-2.pyc

B

YI~d�e�@s8ddlZddlZddlZddlZddlZddlZddlmZej	dkrTddl
mZndZddl
Z
ddl
mZmZmZmZdddhZeed�r�e�ej�e�ej�d	ZeZd3d
d�ZGdd�d�ZGdd�d�Zy
e
jZWn(ek
�rGdd�dee�ZYnXGdd�dej d�Z!e
j!�"e!�Gdd�de!�Z#e
j#�"e#�ddl$m%Z%e#�"e%�Gdd�de!�Z&e
j&�"e&�Gdd�de&�Z'Gdd �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!�Z-e
j-�"e-�Gd-d.�d.ej.�Z/Gd/d0�d0e-�Z0Gd1d2�d2e0�Z1dS)4�N)�
allocate_lock>�win32�cygwin)�setmode)�__all__�SEEK_SET�SEEK_CUR�SEEK_END���	SEEK_HOLEi �r���Tc	Cszt|t�st�|�}t|tttf�s0td|��t|t�sFtd|��t|t�s\td|��|dk	rzt|t�sztd|��|dk	r�t|t�s�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�rD|	�s"|�s"|�s"|
�r*t	d��ddl
}|�dtd�d}
|�rX|�rXt	d��|	|
||dk�rvt	d��|	�s�|
�s�|�s�|�s�t	d��|�r�|dk	�r�t	d��|�r�|dk	�r�t	d��|�r�|dk	�r�t	d��t
||	�r�d�p�d|
�r�d�p�d|�rd	�pd|�rd
�pd|
�r,d�p.d||d�}|}�yd}|dk�sd|dk�rl|���rld}d}|dk�r�t}yt�|���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!|��|}|�rB|St|||||�}|}||_|S|���YnXdS)"Nzinvalid file: %rzinvalid mode: %rzinvalid buffering: %rzinvalid encoding: %rzinvalid errors: %rzaxrwb+tU�xr
�w�a�+�t�b�Uz4mode U cannot be combined with 'x', 'w', 'a', or '+'rz'U' mode is deprecatedrTz'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�)�openerFrzinvalid 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)�filer1�	buffering�encoding�errors�newline�closefdrZmodesZcreatingZreadingZwritingZ	appendingZupdating�textZbinaryr"�raw�result�line_buffering�bs�buffer�r?�*/opt/alt/python37/lib64/python3.7/_pyio.py�open%s�{




>




rAc@seZdZdd�ZdS)�
DocDescriptorcCs
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__rGr?r?r?r@rB�srBc@seZdZe�Zdd�ZdS)�OpenWrappercOs
t||�S)N)rA)�cls�args�kwargsr?r?r@�__new__szOpenWrapper.__new__N)rHrIrJrBrCrOr?r?r?r@rKsrKc@seZdZdS)�UnsupportedOperationN)rHrIrJr?r?r?r@rPsrPc@s�eZdZdd�Zd5dd�Zdd�Zd6d	d
�Zdd�Zd
Zdd�Z	dd�Z
dd�Zd7dd�Zdd�Z
d8dd�Zdd�Zd9dd�Zedd��Zd:d d!�Zd"d#�Zd$d%�Zd&d'�Zd(d)�Zd;d+d,�Zd-d.�Zd/d0�Zd<d1d2�Zd3d4�ZdS)=�IOBasecCstd|jj|f��dS)Nz%s.%s() not supported)rP�	__class__rH)rD�namer?r?r@�_unsupported<szIOBase._unsupportedrcCs|�d�dS)N�seek)rT)rD�pos�whencer?r?r@rUCszIOBase.seekcCs|�dd�S)Nrr
)rU)rDr?r?r@�tellSszIOBase.tellNcCs|�d�dS)N�truncate)rT)rDrVr?r?r@rYWszIOBase.truncatecCs|��dS)N)�_checkClosed)rDr?r?r@�flushaszIOBase.flushFcCs |jsz|��Wdd|_XdS)NT)�_IOBase__closedr[)rDr?r?r@r2kszIOBase.closecCsy|��WnYnXdS)N)r2)rDr?r?r@�__del__vszIOBase.__del__cCsdS)NFr?)rDr?r?r@�seekable�szIOBase.seekablecCs |��st|dkrdn|��dS)NzFile or stream is not seekable.)r^rP)rD�msgr?r?r@�_checkSeekable�szIOBase._checkSeekablecCsdS)NFr?)rDr?r?r@�readable�szIOBase.readablecCs |��st|dkrdn|��dS)NzFile or stream is not readable.)rarP)rDr_r?r?r@�_checkReadable�szIOBase._checkReadablecCsdS)NFr?)rDr?r?r@�writable�szIOBase.writablecCs |��st|dkrdn|��dS)NzFile or stream is not writable.)rcrP)rDr_r?r?r@�_checkWritable�szIOBase._checkWritablecCs|jS)N)r\)rDr?r?r@�closed�sz
IOBase.closedcCs|jrt|dkrdn|��dS)NzI/O operation on closed file.)rer!)rDr_r?r?r@rZ�szIOBase._checkClosedcCs|��|S)N)rZ)rDr?r?r@�	__enter__�szIOBase.__enter__cGs|��dS)N)r2)rDrMr?r?r@�__exit__�szIOBase.__exit__cCs|�d�dS)Nr))rT)rDr?r?r@r)�sz
IOBase.filenocCs|��dS)NF)rZ)rDr?r?r@r&�sz
IOBase.isattyrcs�t�d�r��fdd�}ndd�}�dkr0d�n4y
�j}Wn"tk
r\t��d���YnX|��t�}x>�dks�t|��kr���|��}|s�P||7}|�d�rlPqlWt|�S)	N�peekcs>��d�}|sdS|�d�dp&t|�}�dkr:t|��}|S)Nr
�
r)rh�findr �min)Z	readahead�n)rD�sizer?r@�
nreadahead�s

z#IOBase.readline.<locals>.nreadaheadcSsdS)Nr
r?r?r?r?r@rn�srz is not an integerrri)	�hasattr�	__index__r,r�	bytearrayr �read�endswithr)rDrmrn�
size_index�resrr?)rDrmr@�readline�s&
	

zIOBase.readlinecCs|��|S)N)rZ)rDr?r?r@�__iter__szIOBase.__iter__cCs|��}|st�|S)N)rv�
StopIteration)rD�liner?r?r@�__next__szIOBase.__next__cCsR|dks|dkrt|�Sd}g}x,|D]$}|�|�|t|�7}||kr&Pq&W|S)Nr)�list�appendr )rDZhintrl�linesryr?r?r@�	readliness

zIOBase.readlinescCs$|��x|D]}|�|�qWdS)N)rZ�write)rDr}ryr?r?r@�
writelines$s
zIOBase.writelines)r)N)N)N)N)N)r)N)rHrIrJrTrUrXrYr[r\r2r]r^r`rarbrcrd�propertyrerZrfrgr)r&rvrwrzr~r�r?r?r?r@rQs2#






	

*
rQ)�	metaclassc@s.eZdZddd�Zdd�Zdd�Zdd	�Zd
S)�	RawIOBasercCsP|dkrd}|dkr|��St|���}|�|�}|dkr>dS||d�=t|�S)Nrr)�readallrqrp�readintor)rDrmrrlr?r?r@rr?s

zRawIOBase.readcCs8t�}x|�t�}|sP||7}qW|r0t|�S|SdS)N)rqrrr'r)rDru�datar?r?r@r�Ps
zRawIOBase.readallcCs|�d�dS)Nr�)rT)rDrr?r?r@r�^szRawIOBase.readintocCs|�d�dS)Nr)rT)rDrr?r?r@rfszRawIOBase.writeN)r)rHrIrJrrr�r�rr?r?r?r@r�1s
r�)r%c@sHeZdZddd�Zddd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	dS)�BufferedIOBasercCs|�d�dS)Nrr)rT)rDrmr?r?r@rr�szBufferedIOBase.readcCs|�d�dS)N�read1)rT)rDrmr?r?r@r��szBufferedIOBase.read1cCs|j|dd�S)NF)r�)�	_readinto)rDrr?r?r@r��szBufferedIOBase.readintocCs|j|dd�S)NT)r�)r�)rDrr?r?r@�	readinto1�s	zBufferedIOBase.readinto1cCsVt|t�st|�}|�d�}|r0|�t|��}n|�t|��}t|�}||d|�<|S)N�B)r�
memoryview�castr�r rr)rDrr�r�rlr?r?r@r��s

zBufferedIOBase._readintocCs|�d�dS)Nr)rT)rDrr?r?r@r�s	zBufferedIOBase.writecCs|�d�dS)N�detach)rT)rDr?r?r@r��szBufferedIOBase.detachN)r)r)
rHrIrJrrr�r�r�r�rr�r?r?r?r@r�ss

r�c@s�eZdZdd�Zd#dd�Zdd�Zd$d	d
�Zdd�Zd
d�Zdd�Z	dd�Z
edd��Zedd��Z
edd��Zedd��Zdd�Zdd�Zdd �Zd!d"�ZdS)%�_BufferedIOMixincCs
||_dS)N)�_raw)rDr:r?r?r@�__init__�sz_BufferedIOMixin.__init__rcCs"|j�||�}|dkrtd��|S)Nrz#seek() returned an invalid position)r:rUr+)rDrVrWZnew_positionr?r?r@rU�sz_BufferedIOMixin.seekcCs|j��}|dkrtd��|S)Nrz#tell() returned an invalid position)r:rXr+)rDrVr?r?r@rX�s
z_BufferedIOMixin.tellNcCs$|��|dkr|��}|j�|�S)N)r[rXr:rY)rDrVr?r?r@rY�sz_BufferedIOMixin.truncatecCs|jrtd��|j��dS)Nzflush on closed file)rer!r:r[)rDr?r?r@r[sz_BufferedIOMixin.flushcCs.|jdk	r*|js*z|��Wd|j��XdS)N)r:rer[r2)rDr?r?r@r2
sz_BufferedIOMixin.closecCs*|jdkrtd��|��|j}d|_|S)Nzraw stream already detached)r:r!r[r�)rDr:r?r?r@r�s
z_BufferedIOMixin.detachcCs
|j��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@re#sz_BufferedIOMixin.closedcCs|jjS)N)r:rS)rDr?r?r@rS'sz_BufferedIOMixin.namecCs|jjS)N)r:r1)rDr?r?r@r1+sz_BufferedIOMixin.modecCstd�|jj���dS)Nz can not serialize a '{0}' object)r�formatrRrH)rDr?r?r@�__getstate__/sz_BufferedIOMixin.__getstate__cCsJ|jj}|jj}y
|j}Wntk
r6d�||�SXd�|||�SdS)Nz<{}.{}>z<{}.{} name={!r}>)rRrIrJrS�	Exceptionr�)rD�modnameZclsnamerSr?r?r@�__repr__3s
z_BufferedIOMixin.__repr__cCs
|j��S)N)r:r))rDr?r?r@r)?sz_BufferedIOMixin.filenocCs
|j��S)N)r:r&)rDr?r?r@r&Bsz_BufferedIOMixin.isatty)r)N)rHrIrJr�rUrXrYr[r2r�r^r�r:rerSr1r�r�r)r&r?r?r?r@r��s 	


r�cs�eZdZdZd dd�Zdd�Zdd�Zdd	�Z�fd
d�Zd!d
d�Z	d"dd�Z
dd�Zd#dd�Zdd�Z
d$dd�Zdd�Zdd�Zdd�Z�ZS)%�BytesIONcCs&t�}|dk	r||7}||_d|_dS)Nr)rq�_buffer�_pos)rDZ
initial_bytes�bufr?r?r@r�Ns
zBytesIO.__init__cCs|jrtd��|j��S)Nz__getstate__ on closed file)rer!�__dict__�copy)rDr?r?r@r�UszBytesIO.__getstate__cCs|jrtd��t|j�S)Nzgetvalue on closed file)rer!rr�)rDr?r?r@�getvalueZszBytesIO.getvaluecCs|jrtd��t|j�S)Nzgetbuffer on closed file)rer!r�r�)rDr?r?r@�	getbufferaszBytesIO.getbuffercs"|jdk	r|j��t���dS)N)r��clear�superr2)rD)rRr?r@r2hs

z
BytesIO.closercCs�|jrtd��|dkrd}n4y
|j}Wn"tk
rHt|�d���YnX|�}|dkrbt|j�}t|j�|jkrvdStt|j�|j|�}|j|j|�}||_t	|�S)Nzread from closed filerz is not an integerr�)
rer!rpr,rr r�r�rkr)rDrmrtZnewposrr?r?r@rrms"

zBytesIO.readcCs
|�|�S)N)rr)rDrmr?r?r@r��sz
BytesIO.read1c	Cs�|jrtd��t|t�r td��t|��}|j}WdQRX|dkrFdS|j}|t|j	�krzd|t|j	�}|j	|7_	||j	|||�<|j|7_|S)Nzwrite to closed filez can't write str to binary streamr�)
rer!rrrr��nbytesr�r r�)rDrZviewrlrVZpaddingr?r?r@r�s

z
BytesIO.writercCs�|jrtd��y
|j}Wn"tk
r:t|�d���YnX|�}|dkrh|dkr`td|f��||_nD|dkr�td|j|�|_n(|dkr�tdt|j�|�|_ntd��|jS)Nzseek on closed filez is not an integerrznegative seek position %rr
rzunsupported whence value)	rer!rpr,rr��maxr r�)rDrVrW�	pos_indexr?r?r@rU�s"
zBytesIO.seekcCs|jrtd��|jS)Nztell on closed file)rer!r�)rDr?r?r@rX�szBytesIO.tellcCsx|jrtd��|dkr|j}nJy
|j}Wn"tk
rJt|�d���YnX|�}|dkrhtd|f��|j|d�=|S)Nztruncate on closed filez is not an integerrznegative truncate position %r)rer!r�rpr,rr�)rDrVr�r?r?r@rY�s
zBytesIO.truncatecCs|jrtd��dS)NzI/O operation on closed file.T)rer!)rDr?r?r@ra�szBytesIO.readablecCs|jrtd��dS)NzI/O operation on closed file.T)rer!)rDr?r?r@rc�szBytesIO.writablecCs|jrtd��dS)NzI/O operation on closed file.T)rer!)rDr?r?r@r^�szBytesIO.seekable)N)r)r)r)N)rHrIrJr�r�r�r�r�r2rrr�rrUrXrYrarcr^�
__classcell__r?r?)rRr@r�Fs




r�c@steZdZefdd�Zdd�Zdd�Zddd	�Zdd
d�Zdd
d�Z	ddd�Z
ddd�Zdd�Zdd�Z
ddd�ZdS) r/cCsF|��std��t�||�|dkr,td��||_|��t�|_dS)Nz "raw" argument must be readable.rzinvalid buffer size)	rar+r�r�r!�buffer_size�_reset_read_buf�Lock�
_read_lock)rDr:r�r?r?r@r��szBufferedReader.__init__cCs
|j��S)N)r:ra)rDr?r?r@ra�szBufferedReader.readablecCsd|_d|_dS)Nr�r)�	_read_buf�	_read_pos)rDr?r?r@r��szBufferedReader._reset_read_bufNc	Cs4|dk	r|dkrtd��|j�|�|�SQRXdS)Nrzinvalid number of bytes to read)r!r��_read_unlocked)rDrmr?r?r@rr�szBufferedReader.readcCs�d}d}|j}|j}|dks$|dkr�|��t|jd�rj|j��}|dkrZ||d�pXdS||d�|S||d�g}d}x2|j��}||kr�|}P|t|�7}|�|�q~Wd�	|�p�|St|�|}	||	kr�|j|7_||||�S||d�g}t
|j|�}
xB|	|k�rL|j�|
�}||k�r2|}P|	t|�7}	|�|��qWt||	�}d�	|�}||d�|_d|_|�r�|d|�S|S)Nr�)r�Nrr�r)
r�r�r�ror:r�rrr r|�joinr�r�rk)rDrlZ
nodata_valZempty_valuesr�rV�chunkZchunksZcurrent_size�availZwanted�outr?r?r@r�sN




zBufferedReader._read_unlockedrc	Cs|j�|�|�SQRXdS)N)r��_peek_unlocked)rDrmr?r?r@rh5szBufferedReader.peekcCsrt||j�}t|j�|j}||ks,|dkrb|j|}|j�|�}|rb|j|jd�||_d|_|j|jd�S)Nr)rkr�r r�r�r:rr)rDrlZwantZhaveZto_readZcurrentr?r?r@r�?s
zBufferedReader._peek_unlockedrc	CsR|dkr|j}|dkrdS|j�(|�d�|�t|t|j�|j��SQRXdS)Nrr�r
)r�r�r�r�rkr r�r�)rDrmr?r?r@r�Js
zBufferedReader.read1c	Cst|t�st|�}|jdkr dS|�d�}d}|j��x�|t|�kr�tt|j�|jt|��}|r�|j|j|j|�||||�<|j|7_||7}|t|�kr�Pt|�||j	kr�|j
�||d��}|s�P||7}n|r�|s�|�d�s�P|r8|r8Pq8WWdQRX|S)Nrr�r
)
rr�r�r�r�r rkr�r�r�r:r�r�)rDr�r��writtenr�rlr?r?r@r�\s4


"

zBufferedReader._readintocCst�|�t|j�|jS)N)r�rXr r�r�)rDr?r?r@rX�szBufferedReader.tellc	CsX|tkrtd��|j�8|dkr4|t|j�|j8}t�|||�}|��|SQRXdS)Nzinvalid whence valuer
)	�valid_seek_flagsr!r�r r�r�r�rUr�)rDrVrWr?r?r@rU�szBufferedReader.seek)N)N)r)r)r)r)rHrIrJr'r�rar�rrr�rhr�r�r�rXrUr?r?r?r@r/�s


4



.r/c@s\eZdZefdd�Zdd�Zdd�Zddd	�Zd
d�Zdd
�Z	dd�Z
ddd�Zdd�ZdS)r.cCsF|��std��t�||�|dkr,td��||_t�|_t�|_	dS)Nz "raw" argument must be writable.rzinvalid buffer size)
rcr+r�r�r!r�rq�
_write_bufr��_write_lock)rDr:r�r?r?r@r��szBufferedWriter.__init__cCs
|j��S)N)r:rc)rDr?r?r@rc�szBufferedWriter.writablecCs�t|t�rtd��|j��|jr(td��t|j�|jkr@|�	�t|j�}|j�
|�t|j�|}t|j�|jkr�y|�	�Wnltk
r�}zNt|j�|jkr�t|j�|j}||8}|jd|j�|_t|j|j
|��Wdd}~XYnX|SQRXdS)Nz can't write str to binary streamzwrite to closed file)rrrr�rer!r r�r��_flush_unlocked�extend�BlockingIOError�errno�strerror)rDrZbeforer��eZoverager?r?r@r�s(

"zBufferedWriter.writeNc	Cs8|j�(|��|dkr"|j��}|j�|�SQRXdS)N)r�r�r:rXrY)rDrVr?r?r@rY�s

zBufferedWriter.truncatec	Cs|j�|��WdQRXdS)N)r�r�)rDr?r?r@r[�szBufferedWriter.flushcCs�|jrtd��xz|jr�y|j�|j�}Wntk
rDtd��YnX|dkr\ttjdd��|t	|j�ksr|dkrzt
d��|jd|�=qWdS)Nzflush on closed filezHself.raw should implement RawIOBase: it should not raise BlockingIOErrorz)write could not complete without blockingrz*write() returned incorrect number of bytes)rer!r�r:rr��RuntimeErrorr�ZEAGAINr r+)rDrlr?r?r@r��szBufferedWriter._flush_unlockedcCst�|�t|j�S)N)r�rXr r�)rDr?r?r@rX�szBufferedWriter.tellrc	Cs8|tkrtd��|j�|��t�|||�SQRXdS)Nzinvalid whence value)r�r!r�r�r�rU)rDrVrWr?r?r@rU�s
zBufferedWriter.seekcCsV|j�|jdks|jrdSWdQRXz|��Wd|j�|j��WdQRXXdS)N)r�r:rer[r2)rDr?r?r@r2�szBufferedWriter.close)N)r)
rHrIrJr'r�rcrrYr[r�rXrUr2r?r?r?r@r.�s	

r.c@s�eZdZefdd�Zddd�Zdd�Zdd	�Zddd�Zd d
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zedd��ZdS)!�BufferedRWPaircCs<|��std��|��s td��t||�|_t||�|_dS)Nz#"reader" argument must be readable.z#"writer" argument must be writable.)rar+rcr/�readerr.�writer)rDr�r�r�r?r?r@r�szBufferedRWPair.__init__rcCs|dkrd}|j�|�S)Nr)r�rr)rDrmr?r?r@rrszBufferedRWPair.readcCs|j�|�S)N)r�r�)rDrr?r?r@r�#szBufferedRWPair.readintocCs|j�|�S)N)r�r)rDrr?r?r@r&szBufferedRWPair.writercCs|j�|�S)N)r�rh)rDrmr?r?r@rh)szBufferedRWPair.peekcCs|j�|�S)N)r�r�)rDrmr?r?r@r�,szBufferedRWPair.read1cCs|j�|�S)N)r�r�)rDrr?r?r@r�/szBufferedRWPair.readinto1cCs
|j��S)N)r�ra)rDr?r?r@ra2szBufferedRWPair.readablecCs
|j��S)N)r�rc)rDr?r?r@rc5szBufferedRWPair.writablecCs
|j��S)N)r�r[)rDr?r?r@r[8szBufferedRWPair.flushcCs z|j��Wd|j��XdS)N)r�r2r�)rDr?r?r@r2;szBufferedRWPair.closecCs|j��p|j��S)N)r�r&r�)rDr?r?r@r&AszBufferedRWPair.isattycCs|jjS)N)r�re)rDr?r?r@reDszBufferedRWPair.closedN)r)r)r)rHrIrJr'r�rrr�rrhr�r�rarcr[r2r&r�rer?r?r?r@r�s


r�c@sjeZdZefdd�Zddd�Zdd�Zdd	d
�Zddd�Zd
d�Z	ddd�Z
ddd�Zdd�Zdd�Z
dS)r-cCs(|��t�|||�t�|||�dS)N)r`r/r�r.)rDr:r�r?r?r@r�RszBufferedRandom.__init__rc	Cs�|tkrtd��|��|jrJ|j� |j�|jt|j�d�WdQRX|j�||�}|j�|�	�WdQRX|dkr�t
d��|S)Nzinvalid whence valuer
rz seek() returned invalid position)r�r!r[r�r�r:rUr�r r�r+)rDrVrWr?r?r@rUWs$zBufferedRandom.seekcCs|jrt�|�St�|�SdS)N)r�r.rXr/)rDr?r?r@rXhs
zBufferedRandom.tellNcCs|dkr|��}t�||�S)N)rXr.rY)rDrVr?r?r@rYnszBufferedRandom.truncatecCs |dkrd}|��t�||�S)Nr)r[r/rr)rDrmr?r?r@rrtszBufferedRandom.readcCs|��t�||�S)N)r[r/r�)rDrr?r?r@r�zszBufferedRandom.readintocCs|��t�||�S)N)r[r/rh)rDrmr?r?r@rh~szBufferedRandom.peekrcCs|��t�||�S)N)r[r/r�)rDrmr?r?r@r��szBufferedRandom.read1cCs|��t�||�S)N)r[r/r�)rDrr?r?r@r��szBufferedRandom.readinto1c	CsF|jr:|j�(|j�|jt|j�d�|��WdQRXt�||�S)Nr
)	r�r�r:rUr�r r�r.r)rDrr?r?r@r�s
zBufferedRandom.write)r)N)N)r)r)rHrIrJr'r�rUrXrYrrr�rhr�r�rr?r?r?r@r-Is	




r-cs�eZdZdZdZdZdZdZdZdZ	d0dd�Z
dd	�Zd
d�Zdd
�Z
dd�Zd1dd�Zd2dd�Zdd�Zdd�Zdd�Zefdd�Zdd�Zd3dd�Z�fd 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�|j�Wdd|_Xt|t�r<td��t|t�r\|}|dkr`td��nd}t|t	�sxtd|f��t
|�t
d�ks�td|f��tdd�|D��d	ks�|�d
�d	kr�td��d|kr�d
|_
d
|_tjtjB}nTd|kr�d
|_d}n@d|k�rd
|_tjtjB}n"d|k�r8d
|_d
|_tjtjB}d
|k�rNd
|_d
|_|j�rj|j�rj|tjO}n|j�r~|tjO}n
|tjO}|ttdd�O}ttdd��p�ttdd�}||O}d}�yT|dk�r:|�s�td��|dk�r�t�||d�}n0|||�}t|t��std��|dk�r$td��|}|�s:t�|d�||_t�|�}	y(t�|	j��rpt t!j"t�#t!j"�|��Wnt$k
�r�YnXt|	dd�|_%|j%d	k�r�t&|_%t'�r�t'|tj(�||_)|j�ryt�*|dt+�Wn4tk
�r}
z|
j!t!j,k�r�Wdd}
~
XYnXWn"|dk	�r0t�|��YnX||_dS)Nrrz$integer argument expected, got floatznegative file descriptorzinvalid mode: %szxrwab+css|]}|dkVqdS)ZrwaxNr?)�.0�cr?r?r@�	<genexpr>�sz"FileIO.__init__.<locals>.<genexpr>r
rzKMust have exactly one of create/read/write/append mode and at most one plusrTr
rr�O_BINARYZO_NOINHERIT�	O_CLOEXECz'Cannot use closefd=False with file namei�zexpected integer from openerzNegative file descriptorFr*)-�_fd�_closefdrr2r�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	ZESPIPE)rDr3r1r8r�fd�flagsZnoinherit_flagZowned_fdZfdfstatr�r?r?r@r��s�




$










zFileIO.__init__cCsB|jdkr>|jr>|js>ddl}|jd|ftd|d�|��dS)Nrzunclosed file %rr)�
stacklevel�source)r�r�rer"r#�ResourceWarningr2)rDr"r?r?r@r]s

zFileIO.__del__cCstd|jj��dS)Nzcannot serialize '%s' object)rrRrH)rDr?r?r@r�szFileIO.__getstate__cCsld|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�r1r�)rD�
class_namerSr?r?r@r�s
zFileIO.__repr__cCs|jstd��dS)NzFile not open for reading)r�rP)rDr?r?r@rb-szFileIO._checkReadablecCs|jstd��dS)NzFile not open for writing)r�rP)rDr_r?r?r@rd1szFileIO._checkWritablecCsP|��|��|dks |dkr(|��Syt�|j|�Stk
rJdSXdS)Nr)rZrbr�rrrr�r�)rDrmr?r?r@rr5szFileIO.readcCs�|��|��t}y6t�|jdt�}t�|j�j}||krH||d}Wnt	k
r^YnXt
�}xnt|�|kr�t|�}|t|t�7}|t|�}yt�
|j|�}Wntk
r�|r�PdSX|s�P||7}qhWt|�S)Nrr
)rZrbr'rr�r�rr(�st_sizer+rqr r�rrr�r)rD�bufsizerV�endr;rlr�r?r?r@r�Es4zFileIO.readallcCs4t|��d�}|�t|��}t|�}||d|�<|S)Nr�)r�r�rrr )rDr�mr�rlr?r?r@r�hs
zFileIO.readintocCs8|��|��yt�|j|�Stk
r2dSXdS)N)rZrdrrr�r�)rDrr?r?r@rpszFileIO.writecCs*t|t�rtd��|��t�|j||�S)Nzan integer is required)rr�rrZrr�r�)rDrVrWr?r?r@rU~s
zFileIO.seekcCs|��t�|jdt�S)Nr)rZrr�r�r)rDr?r?r@rX�szFileIO.tellcCs2|��|��|dkr |��}t�|j|�|S)N)rZrdrXr�	ftruncater�)rDrmr?r?r@rY�szFileIO.truncatecs.|js*z|jrt�|j�Wdt���XdS)N)rer�rr2r�r�)rD)rRr?r@r2�s
zFileIO.closecCsF|��|jdkr@y|��Wntk
r8d|_YnXd|_|jS)NFT)rZ�	_seekablerXr+)rDr?r?r@r^�s
zFileIO.seekablecCs|��|jS)N)rZr�)rDr?r?r@ra�szFileIO.readablecCs|��|jS)N)rZr�)rDr?r?r@rc�szFileIO.writablecCs|��|jS)N)rZr�)rDr?r?r@r)�sz
FileIO.filenocCs|��t�|j�S)N)rZrr&r�)rDr?r?r@r&�sz
FileIO.isattycCs|jS)N)r�)rDr?r?r@r8�szFileIO.closefdcCsJ|jr|jrdSdSn0|jr,|jr&dSdSn|jrB|jr<dSdSndSdS)Nzxb+Zxbzab+Zabzrb+�rb�wb)r�r�r�r�)rDr?r?r@r1�szFileIO.mode)r
TN)N)N)N)"rHrIrJr�r�r�r�r�r�r�r�r]r�r�rbrdrrr�r�rrrUrXrYr2r^rarcr)r&r�r8r1r�r?r?)rRr@r%�s8
y

#


r%c@s\eZdZddd�Zdd�Zddd�Zd	d
�Zdd�Zed
d��Z	edd��Z
edd��ZdS)�
TextIOBasercCs|�d�dS)Nrr)rT)rDrmr?r?r@rr�szTextIOBase.readcCs|�d�dS)Nr)rT)rD�sr?r?r@r�szTextIOBase.writeNcCs|�d�dS)NrY)rT)rDrVr?r?r@rYszTextIOBase.truncatecCs|�d�dS)Nrv)rT)rDr?r?r@rvszTextIOBase.readlinecCs|�d�dS)Nr�)rT)rDr?r?r@r�szTextIOBase.detachcCsdS)Nr?)rDr?r?r@r5szTextIOBase.encodingcCsdS)Nr?)rDr?r?r@�newlinesszTextIOBase.newlinescCsdS)Nr?)rDr?r?r@r6#szTextIOBase.errors)r)N)rHrIrJrrrrYrvr�r�r5r�r6r?r?r?r@r��s


	
r�c@sPeZdZddd�Zddd�Zdd�Zd	d
�Zdd�Zd
ZdZ	dZ
edd��ZdS)�IncrementalNewlineDecoder�strictcCs,tjj||d�||_||_d|_d|_dS)N)r6rF)�codecs�IncrementalDecoderr��	translate�decoder�seennl�	pendingcr)rDr�r�r6r?r?r@r�4s
z"IncrementalNewlineDecoder.__init__FcCs�|jdkr|}n|jj||d�}|jr<|s.|r<d|}d|_|�d�r\|s\|dd�}d|_|�d�}|�d�|}|�d�|}|j|o�|j|o�|jB|o�|jBO_|j	r�|r�|�
dd�}|r�|�
dd�}|S)N)�final�
FrTz
�
)r��decoder�rsr�r��_LF�_CR�_CRLFr��replace)rD�inputr��outputZcrlfZcrZlfr?r?r@r�;s(

"z IncrementalNewlineDecoder.decodecCs@|jdkrd}d}n|j��\}}|dK}|jr8|dO}||fS)Nr�rr
)r��getstater�)rDr��flagr?r?r@rZs
z"IncrementalNewlineDecoder.getstatecCs8|\}}t|d@�|_|jdk	r4|j�||d?f�dS)Nr
)�boolr�r��setstate)rD�stater�rr?r?r@res
z"IncrementalNewlineDecoder.setstatecCs$d|_d|_|jdk	r |j��dS)NrF)r�r�r��reset)rDr?r?r@rks
zIncrementalNewlineDecoder.resetr
r�cCs
d|jS)N)Nr�r�)r�r�z
)r�z
)r�z
)r�r�z
)r�)rDr?r?r@r�usz"IncrementalNewlineDecoder.newlinesN)r�)F)
rHrIrJr�r�rrrr�r�r�r�r�r?r?r?r@r�-s

r�c@sreZdZdZdZdNdd�Zdd�ZdOdd	�Zd
d�Ze	dd
��Z
e	dd��Ze	dd��Ze	dd��Z
e	dd��Zddeddd�dd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Ze	d#d$��Ze	d%d&��Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Zd1d2�ZdPd3d4�Zd5d6�Zd7d8�Z dQd:d;�Z!d<d=�Z"d>d?�Z#dRd@dA�Z$dBdC�Z%dSdDdE�Z&dTdFdG�Z'dHdI�Z(dUdJdK�Z)e	dLdM��Z*dS)Vr0iNFc		Cs|�|�|dkrvyt�|���}Wnttfk
r<YnX|dkrvyddl}Wntk
rjd}YnX|�d�}t	|t
�s�td|��t�
|�js�d}t||��|dkr�d}nt	|t
�s�td|��||_d|_d|_d|_|j��|_|_t|jd	�|_|�|||||�dS)
Nr�asciiFzinvalid encoding: %rzG%r is not a text encoding; use codecs.open() to handle arbitrary codecsr�zinvalid errors: %rrr�)�_check_newliner�device_encodingr)r,rP�locale�ImportError�getpreferredencodingrrr!r��lookup�_is_text_encoding�LookupErrorr��_decoded_chars�_decoded_chars_used�	_snapshotr>r^r��_tellingro�
_has_read1�
_configure)	rDr>r5r6r7r<�
write_throughrr_r?r?r@r��s:





zTextIOWrapper.__init__cCs>|dk	r$t|t�s$tdt|�f��|dkr:td|f��dS)Nzillegal newline type: %r)Nrr�r�z
zillegal newline value: %r)rrr�typer!)rDr7r?r?r@r
�szTextIOWrapper._check_newlinecCs�||_||_d|_d|_d|_||_|dk|_||_|dk|_|pHt	j
|_||_||_
|jr�|��r�|j��}|dkr�y|���d�Wntk
r�YnXdS)Ngrr)�	_encoding�_errors�_encoder�_decoder�	_b2cratio�_readuniversal�_readtranslate�_readnl�_writetranslater�linesep�_writenl�_line_buffering�_write_throughr�rcr>rX�_get_encoderrr)rDr5r6r7r<r�positionr?r?r@r�s&


zTextIOWrapper._configurecCs�d�|jj|jj�}y
|j}Wntk
r2YnX|d�|�7}y
|j}Wntk
r`YnX|d�|�7}|d�|j�S)Nz<{}.{}z name={0!r}z mode={0!r}z encoding={0!r}>)r�rRrIrJrSr�r1r5)rDr;rSr1r?r?r@r��s



zTextIOWrapper.__repr__cCs|jS)N)r)rDr?r?r@r5szTextIOWrapper.encodingcCs|jS)N)r)rDr?r?r@r6
szTextIOWrapper.errorscCs|jS)N)r%)rDr?r?r@r<szTextIOWrapper.line_bufferingcCs|jS)N)r&)rDr?r?r@rszTextIOWrapper.write_throughcCs|jS)N)r�)rDr?r?r@r>szTextIOWrapper.buffer)r5r6r7r<rcCs�|jdk	r*|dk	s"|dk	s"|tk	r*td��|dkrH|dkrB|j}q^d}nt|t�s^td|��|dkrn|j}nt|t�s�td|��|tkr�|j}|�	|�|dkr�|j
}|dkr�|j}|��|�
|||||�dS)NzPIt is not possible to set the encoding or newline of stream after the first readr�zinvalid errors: %rzinvalid encoding: %r)r�EllipsisrPrrrrrr!r
r<rr[r)rDr5r6r7r<rr?r?r@�reconfigures2




zTextIOWrapper.reconfigurecCs|jrtd��|jS)NzI/O operation on closed file.)rer!r�)rDr?r?r@r^CszTextIOWrapper.seekablecCs
|j��S)N)r>ra)rDr?r?r@raHszTextIOWrapper.readablecCs
|j��S)N)r>rc)rDr?r?r@rcKszTextIOWrapper.writablecCs|j��|j|_dS)N)r>r[r�r)rDr?r?r@r[Ns
zTextIOWrapper.flushcCs.|jdk	r*|js*z|��Wd|j��XdS)N)r>rer[r2)rDr?r?r@r2RszTextIOWrapper.closecCs|jjS)N)r>re)rDr?r?r@reYszTextIOWrapper.closedcCs|jjS)N)r>rS)rDr?r?r@rS]szTextIOWrapper.namecCs
|j��S)N)r>r))rDr?r?r@r)aszTextIOWrapper.filenocCs
|j��S)N)r>r&)rDr?r?r@r&dszTextIOWrapper.isattycCs�|jrtd��t|t�s(td|jj��t|�}|js<|j	oBd|k}|rf|jrf|j
dkrf|�d|j
�}|jpr|�
�}|�|�}|j�|�|j	r�|s�d|kr�|��|�d�d|_|jr�|j��|S)Nzwrite to closed filezcan't write %s to text streamr�r�r)rer!rrrrRrHr r"r%r$r�rr'�encoder>rr[�_set_decoded_charsrrr)rDr��lengthZhaslf�encoderrr?r?r@rgs&



zTextIOWrapper.writecCst�|j�}||j�|_|jS)N)r��getincrementalencoderrrr)rDZmake_encoderr?r?r@r'~szTextIOWrapper._get_encodercCs2t�|j�}||j�}|jr(t||j�}||_|S)N)r��getincrementaldecoderrrrr�r r)rDZmake_decoderr�r?r?r@�_get_decoder�s
zTextIOWrapper._get_decodercCs||_d|_dS)Nr)rr)rD�charsr?r?r@r,�sz TextIOWrapper._set_decoded_charscCsF|j}|dkr|j|d�}n|j|||�}|jt|�7_|S)N)rrr )rDrl�offsetr2r?r?r@�_get_decoded_chars�sz TextIOWrapper._get_decoded_charscCs$|j|krtd��|j|8_dS)Nz"rewind decoded_chars out of bounds)r�AssertionError)rDrlr?r?r@�_rewind_decoded_chars�s
z#TextIOWrapper._rewind_decoded_charscCs�|jdkrtd��|jr&|j��\}}|jr<|j�|j�}n|j�|j�}|}|j�	||�}|�
|�|r�t|�t|j�|_
nd|_
|jr�|||f|_|S)Nz
no decoderg)rr!rrrr>r��_CHUNK_SIZErrr�r,r rrr)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(r9�
bytes_to_feed�need_eof�
chars_to_skipr?r?r@�_pack_cookie�szTextIOWrapper._pack_cookiecCsFt|d�\}}t|d�\}}t|d�\}}t|d�\}}|||||fS)Nl)�divmod)rDZbigint�restr(r9rArBrCr?r?r@�_unpack_cookie�s
zTextIOWrapper._unpack_cookiec	Cs:|jstd��|jstd��|��|j��}|j}|dksF|jdkrX|j	rTt
d��|S|j\}}|t|�8}|j}|dkr�|�
||�S|��}�z�t|j|�}d}x�|dk�r"|�d|f�t|�|d|���}	|	|k�r|��\}
}|
s�|}||	8}P|t|
�8}d}q�||8}|d}q�Wd}|�d|f�||}|}
|dk�rX|�
||
�Sd}d}d}x�t|t|��D]t}|d7}|t|�|||d���7}|��\}}|�s�||k�r�||7}||8}|dd}
}}||k�rtP�qtW|t|jddd	��7}d}||k�rtd
��|�
||
|||�S|�|�XdS)Nz!underlying stream is not seekablez(telling position disabled by next() callzpending decoded textrr
r�rT)r�z'can't reconstruct logical file position)r�rPrr+r[r>rXrrrr5r rrDrrrrr��range)rDr(r�r9Z
next_inputrCZsaved_stateZ
skip_bytesZ	skip_backrlr�d�	start_posZstart_flagsZ	bytes_fedrBZ
chars_decoded�ir8r?r?r@rX�sv





zTextIOWrapper.tellcCs$|��|dkr|��}|j�|�S)N)r[rXr>rY)rDrVr?r?r@rYA	szTextIOWrapper.truncatecCs*|jdkrtd��|��|j}d|_|S)Nzbuffer is already detached)r>r!r[r�)rDr>r?r?r@r�G	s
zTextIOWrapper.detachcs��fdd�}�jrtd���js(td��|dkrL|dkr@td��d}���}|dkr�|dkrdtd	������j�dd�}��d
�d�_	�j
r��j
��||�|S|dkr�td|f��|dkr�td|f�������|�\}}}}}	�j�|���d
�d�_	|dk�r(�j
�r(�j
��n@�j
�s<|�s<|	�rh�j
�pJ��
��_
�j
�d
|f�|d
f�_	|	�r��j�|�}
���j
�|
|��||
f�_	t�j�|	k�r�td��|	�_||�|S)NcsHy�jp���}Wntk
r&YnX|dkr<|�d�n|��dS)Nr)rr'rrr)r(r.)rDr?r@�_reset_encoderP	sz*TextIOWrapper.seek.<locals>._reset_encoderztell on closed filez!underlying stream is not seekabler
rz#can't do nonzero cur-relative seeksrz#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,rrrrGr1rrrr�r rr+r)rDZcookierWrLr(rJr9rArBrCr:r?)rDr@rUO	s\





zTextIOWrapper.seekcCs�|��|dkrd}n4y
|j}Wn"tk
rBt|�d���YnX|�}|jpV|��}|dkr�|��|j|j�	�dd�}|�
d�d|_|Sd}|�|�}x4t|�|kr�|s�|�
�}||�|t|��7}q�W|SdS)Nrz is not an integerrT)r�rF)rbrpr,rrr1r4r�r>rrr,rr r<)rDrmrtr�r;r;r?r?r@rr�	s*



zTextIOWrapper.readcCs(d|_|��}|s$d|_|j|_t�|S)NF)rrvrr�rx)rDryr?r?r@rz�	szTextIOWrapper.__next__c	Cs|jrtd��|dkrd}n4y
|j}Wn"tk
rHt|�d���YnX|�}|��}d}|jsj|��d}}�xV|jr�|�	d|�}|dkr�|d}Pnt
|�}n�|j�r>|�	d|�}|�	d|�}|dkr�|dkr�t
|�}n
|d}PnP|dk�r|d}Pn:||k�r|d}Pn$||dk�r2|d}Pn
|d}Pn&|�	|j�}|dk�rd|t
|j�}P|dk�r�t
|�|k�r�|}Px|�
��r�|j�r�P�q�W|j�r�||��7}qv|�d	�d|_|SqvW|dk�r�||k�r�|}|�t
|�|�|d|�S)
Nzread from closed filerz is not an integerrr�r
r�rr)rer!rpr,rr4rr1r rjr rr!r<rr,rr6)	rDrmrtry�startrV�endposZnlposZcrposr?r?r@rv�	sv






zTextIOWrapper.readlinecCs|jr|jjSdS)N)rr�)rDr?r?r@r�
szTextIOWrapper.newlines)NNNFF)NNNFF)N)rrrr)N)r)N)N)+rHrIrJr7r�r�r
rr�r�r5r6r<rr>r)r*r^rarcr[r2rerSr)r&rr'r1r,r4r6r<rDrGrXrYr�rUrrrzrvr�r?r?r?r@r0�sT
'
#'

*
	c

K
	
]r0csNeZdZd�fdd�	Zdd�Zdd�Zed	d
��Zedd��Zd
d�Z	�Z
S)�StringIOrr�csftt|�jt�dd|d�|dkr(d|_|dk	rbt|t�sNtd�t	|�j
���|�|�|�d�dS)Nzutf-8�
surrogatepass)r5r6r7Fz*initial_value must be str or None, not {0}r)
r�rOr�r�r"rrrr�rrHrrU)rDZ
initial_valuer7)rRr?r@r�(
s

zStringIO.__init__c	CsL|��|jp|��}|��}|��z|j|j��dd�S|�|�XdS)NT)r�)	r[rr1rrr�r>r�r)rDr�Z	old_stater?r?r@r�8
szStringIO.getvaluecCs
t�|�S)N)�objectr�)rDr?r?r@r�B
szStringIO.__repr__cCsdS)Nr?)rDr?r?r@r6G
szStringIO.errorscCsdS)Nr?)rDr?r?r@r5K
szStringIO.encodingcCs|�d�dS)Nr�)rT)rDr?r?r@r�O
szStringIO.detach)rr�)rHrIrJr�r�r�r�r6r5r�r�r?r?)rRr@rO!
s
rO)r
rNNNTN)2r�abcr�r�r��sys�_threadrr��platformZmsvcrtrr��iorrrr	r�ro�addr�	SEEK_DATAr'r�rArBrKrPr,r+r!�ABCMetarQ�registerr��_ior%r�r�r�r/r.r�r-r�r�r�r0rOr?r?r?r@�<module>sr



T	
=
giCiIJY@U$