Your IP : 3.143.7.112


Current Path : /opt/alt/python310/lib64/python3.10/__pycache__/
Upload File :
Current File : //opt/alt/python310/lib64/python3.10/__pycache__/_pyio.cpython-310.opt-2.pyc

o

6��fq�@sr	ddlZddlZddlZddlZddlZddlZddlmZej	dvr+ddl
mZndZddl
Z
ddl
mZmZmZmZhd�Zeed�rRe�ej�e�ej�dZeZeed	�p^ejjZeZd6dd�Ze		d7dd��Zdd�Z ze
j!Z!Wne"y�e Z!Ynwdd�Z#ze
j$Z$Wne"y�Gdd�de%e&�Z$YnwGdd�dej'd�Z(e
j(�)e(�Gdd�de(�Z*e
j*�)e*�ddl+m,Z,e*�)e,�Gdd�de(�Z-e
j-�)e-�Gd d!�d!e-�Z.Gd"d#�d#e-�Z/Gd$d%�d%e.�Z0Gd&d'�d'e.�Z1Gd(d)�d)e-�Z2Gd*d+�d+e1e0�Z3Gd,d-�d-e*�Z,Gd.d/�d/e(�Z4e
j4�)e4�Gd0d1�d1ej5�Z6Gd2d3�d3e4�Z7Gd4d5�d5e7�Z8dS)8�N)�
allocate_lock>Zwin32�cygwin)�setmode)�__all__�SEEK_SET�SEEK_CUR�SEEK_END>r���	SEEK_HOLEi Zgettotalrefcountr
cCs4	|durd}tjjrddl}|�dt|d�|S)N�localerz"'encoding' argument not specified.r	)�sys�flags�warn_default_encoding�warnings�warn�EncodingWarning)�encoding�
stacklevelr�r�,/opt/alt/python310/lib64/python3.10/_pyio.py�
text_encoding+s
�r�r���Tc	Csr	t|t�st�|�}t|tttf�std|��t|t�s$td|��t|t�s/td|��|dur>t|t�s>td|��|durMt|t�sMtd|��t|�}|td�s_t|�t|�kret	d|��d|v}	d|v}
d	|v}d
|v}d|v}
d|v}d
|v}d|vr�|	s�|s�|s�|
r�t	d��ddl
}|�dtd�d}
|r�|r�t	d��|	|
||dkr�t	d��|	s�|
s�|s�|s�t	d��|r�|dur�t	d��|r�|dur�t	d��|r�|dur�t	d��|r�|dkr�ddl
}|�dt
d�t||	r�dp�d|
r�dp�d|�rd	�pd|�r
d
�pd|
�rd�pd||d�}|}z�d}|dk�s-|dk�r1|���r1d}d}|dk�rVt}z
t�|���j}Wnttf�yNYnw|dk�rV|}|dk�r_t	d ��|dk�rn|�rj|WSt	d!��|
�rwt||�}n|	�s�|�s�|�r�t||�}n|
�r�t||�}nt	d"|��|}|�r�|WSt|�}t|||||�}|}||_|WS|���)#Nzinvalid file: %rzinvalid mode: %rzinvalid buffering: %r�invalid encoding: %r�invalid errors: %rzaxrwb+tU�xr�w�a�+�t�b�Uz4mode U cannot be combined with 'x', 'w', 'a', or '+'rz'U' mode is deprecatedr
Tz'can't have text and binary mode at oncer	z)can't have read/write/append mode at oncez/must have exactly one of read/write/append modez-binary mode doesn't take an encoding argumentz+binary mode doesn't take an errors argumentz+binary mode doesn't take a newline 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)�
isinstance�int�os�fspath�str�bytes�	TypeError�set�len�
ValueErrorrr�DeprecationWarning�RuntimeWarning�FileIO�isatty�DEFAULT_BUFFER_SIZE�fstat�fileno�
st_blksize�OSError�AttributeError�BufferedRandom�BufferedWriter�BufferedReaderr�
TextIOWrapper�mode�close)�filer=�	bufferingr�errors�newline�closefdr$ZmodesZcreatingZreadingZwritingZ	appendingZupdating�textZbinaryr�raw�result�line_bufferingZbs�bufferrrr�openHs�
x


��

�����
�


rIcCs"	ddl}|�dtd�t|d�S)Nrz(_pyio.open_code() may not be using hooksr
�rb)rrr0rI)�pathrrrr�_open_code_with_warning$s
�
rLcCs0|dkrddl}|jdtdd�tatSt|��)N�OpenWrapperrz+OpenWrapper is deprecated, use open insteadr
)r)rrr/rIrMr8)�namerrrr�__getattr__:s�rOc@seZdZdS)�UnsupportedOperationN)�__name__�
__module__�__qualname__rrrrrPOsrPc@s�eZdZ	dd�Zd5dd�Zdd�Zd6d	d
�Zdd�Zd
Zdd�Z	dd�Z
dd�Zd6dd�Zdd�Z
d6dd�Zdd�Zd6dd�Zedd��Zd6d d!�Zd"d#�Zd$d%�Zd&d'�Zd(d)�Zd7d+d,�Zd-d.�Zd/d0�Zd6d1d2�Zd3d4�ZdS)8�IOBasecCs	td|jj|f��)Nz%s.%s() not supported)rP�	__class__rQ)�selfrNrrr�_unsupportedus
�zIOBase._unsupportedrcC�	|�d�dS)N�seek�rW�rV�pos�whencerrrrY|s
zIOBase.seekcCs	|�dd�S�Nrr	)rY�rVrrr�tell��zIOBase.tellNcCrX�N�truncaterZ�rVr\rrrrc��zIOBase.truncatecC�	|��dS�N��_checkClosedr_rrr�flush�szIOBase.flushFcCs*	|jsz
|��Wd|_dSd|_wdS)NT)�_IOBase__closedrjr_rrrr>�s
�zIOBase.closecCsV	z|j}Wn
tyYdSw|rdStr|��dSz|��WdSYdSrg)�closedr8�_IOBASE_EMITS_UNRAISABLEr>)rVrlrrr�__del__�s
�zIOBase.__del__cC�	dS�NFrr_rrr�seekable�szIOBase.seekablecC�$	|��st|dur
d��|��dS)NzFile or stream is not seekable.)rqrP�rV�msgrrr�_checkSeekable�����zIOBase._checkSeekablecCrorprr_rrr�readable��zIOBase.readablecCrr)NzFile or stream is not readable.)rwrPrsrrr�_checkReadable�rvzIOBase._checkReadablecCrorprr_rrr�writable�rxzIOBase.writablecCrr)NzFile or stream is not writable.)rzrPrsrrr�_checkWritable�rvzIOBase._checkWritablecC�	|jSrg)rkr_rrrrl�sz
IOBase.closedcCs"	|jrt|durd��|��dS�N�I/O operation on closed file.�rlr.rsrrrri�s���zIOBase._checkClosedcCs	|��|Srgrhr_rrr�	__enter__szIOBase.__enter__cGrfrg)r>)rV�argsrrr�__exit__razIOBase.__exit__cCrX)Nr5rZr_rrrr5�z
IOBase.filenocCs	|��dSrprhr_rrrr2sz
IOBase.isattyrcs�	t�d�r��fdd�}ndd�}�durd�nz�j}Wnty,t��d���w|��t�}�dks=t|��krb��|��}|sJ	t|�S||7}|�d�rX	t|�S�dks=t|��ks=t|�S)	N�peekcs>��d�}|s	dS|�d�dpt|�}�dkrt|��}|S)Nr	�
r)r��findr-�min)Z	readahead�n�rV�sizerr�
nreadahead0s

z#IOBase.readline.<locals>.nreadaheadcSsdS�Nr	rrrrrr�9sr� is not an integerrr�)	�hasattr�	__index__r8r+�	bytearrayr-�read�endswithr*)rVr�r��
size_index�resr!rr�r�readline$s0

	
��
�zIOBase.readlinecCs|��|Srgrhr_rrr�__iter__NszIOBase.__iter__cCs|��}|st�|Srg)r��
StopIteration�rV�linerrr�__next__RszIOBase.__next__cCsT	|dus	|dkr
t|�Sd}g}|D]}|�|�|t|�7}||kr'|Sq|S�Nr)�list�appendr-)rVZhintr��linesr�rrr�	readlinesXs
�zIOBase.readlinescCs"	|��|D]}|�|�qdSrg)ri�write)rVr�r�rrr�
writelinesjs
�zIOBase.writelines�rrg�r)rQrRrSrWrYr`rcrjrkr>rnrqrurwryrzr{�propertyrlrir�r�r5r2r�r�r�r�r�rrrrrTSs8 







	

*
rT)�	metaclassc@s0eZdZ	ddd�Zdd�Zdd�Zdd	�Zd
S)�	RawIOBasercCsR	|durd}|dkr|��St|���}|�|�}|dur dS||d�=t|�S)Nrr)�readallr�r��readintor*)rVr�r!r�rrrr��s

zRawIOBase.readcCs4	t�}	|�t�}|s
n||7}q|rt|�S|Srg)r�r�r3r*)rVr��datarrrr��s
�zRawIOBase.readallcCrX)Nr�rZ�rVr!rrrr��rezRawIOBase.readintocCrX�Nr�rZr�rrrr��rezRawIOBase.writeNr�)rQrRrSr�r�r�r�rrrrr�ws
r�)r1c@sJeZdZ	ddd�Zddd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	dS)�BufferedIOBasercCrX�Nr�rZr�rrrr��szBufferedIOBase.readcCrX)N�read1rZr�rrrr��szBufferedIOBase.read1cC�	|j|dd�S)NF�r���	_readintor�rrrr��szBufferedIOBase.readintocCr�)NTr�r�r�rrr�	readinto1��zBufferedIOBase.readinto1cCsVt|t�s	t|�}|�d�}|r|�t|��}n|�t|��}t|�}||d|�<|S�N�B)r%�
memoryview�castr�r-r�)rVr!r�r�r�rrrr��s

zBufferedIOBase._readintocCrXr�rZr�rrrr�r�zBufferedIOBase.writecCrX�N�detachrZr_rrrr��zBufferedIOBase.detachNr�)
rQrRrSr�r�r�r�r�r�r�rrrrr��s

r�c@s�eZdZ	dd�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
||_dSrg��_raw�rVrErrr�__init__,�
z_BufferedIOMixin.__init__rcCs"|j�||�}|dkrtd��|S)Nrz#seek() returned an invalid position)rErYr7)rVr\r]Znew_positionrrrrY1sz_BufferedIOMixin.seekcCs|j��}|dkr
td��|S)Nrz#tell() returned an invalid position)rEr`r7rdrrrr`7s
z_BufferedIOMixin.tellNcCs4|��|��|��|dur|��}|j�|�Srg)rir{rjr`rErcrdrrrrc=sz_BufferedIOMixin.truncatecCs|jrtd��|j��dS)N�flush on closed file)rlr.rErjr_rrrrjNsz_BufferedIOMixin.flushcC�>|jdur|jsz|��W|j��dS|j��wdSdSrg)rErlrjr>r_rrrr>Ss

�z_BufferedIOMixin.closecC�*|jdur	td��|��|j}d|_|S)Nzraw stream already detached)rEr.rjr�r�rrrr�[�
z_BufferedIOMixin.detachcC�
|j��Srg)rErqr_rrrrqer�z_BufferedIOMixin.seekablecC�|jSrgr�r_rrrrEh�z_BufferedIOMixin.rawcC�|jjSrg)rErlr_rrrrll�z_BufferedIOMixin.closedcCr�rg)rErNr_rrrrNpr�z_BufferedIOMixin.namecCr�rg)rEr=r_rrrr=tr�z_BufferedIOMixin.modecC�td|jj�d����Nzcannot pickle z object�r+rUrQr_rrr�__getstate__x�z_BufferedIOMixin.__getstate__cCsH|jj}|jj}z|j}Wntyd�||�YSwd�|||�S)Nz<{}.{}>z<{}.{} name={!r}>)rUrRrSrNr8�format)rV�modnameZclsnamerNrrr�__repr__{s
�z_BufferedIOMixin.__repr__cCr�rg)rEr5r_rrrr5�r�z_BufferedIOMixin.filenocCr�rg)rEr2r_rrrr2�r�z_BufferedIOMixin.isattyr�rg)rQrRrSr�rYr`rcrjr>r�rqr�rErlrNr=r�r�r5r2rrrrr�#s,






r�cs�eZdZ	dZd 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�}|dur||7}||_d|_dSr�)r��_buffer�_pos)rVZ
initial_bytes�bufrrrr��s

zBytesIO.__init__cCs|jrtd��|j��S)Nz__getstate__ on closed file)rlr.�__dict__�copyr_rrrr��s
zBytesIO.__getstate__cC�	|jrtd��t|j�S)Nzgetvalue on closed file)rlr.r*r�r_rrr�getvalue��
zBytesIO.getvaluecCr�)Nzgetbuffer on closed file)rlr.r�r�r_rrr�	getbuffer�r�zBytesIO.getbuffercs"|jdur
|j��t���dSrg)r��clear�superr>r_�rUrrr>�s

z
BytesIO.closercCs�|jrtd��|durd}nz|j}Wnty!t|�d���w|�}|dkr.t|j�}t|j�|jkr8dStt|j�|j|�}|j|j|�}||_t	|�S)N�read from closed filerr�r�)
rlr.r�r8r+r-r�r�r�r*)rVr�r�Znewposr!rrrr��s$
�
zBytesIO.readcCs	|�|�Srg)r�r�rrrr��s
z
BytesIO.read1cCs�|jrtd��t|t�rtd��t|��}|j}Wd�n1s"wY|dkr-dS|j}|t|j	�krGd|t|j	�}|j	|7_	||j	|||�<|j|7_|S)N�write to closed file� can't write str to binary streamr�)
rlr.r%r)r+r��nbytesr�r-r�)rVr!Zviewr�r\Zpaddingrrrr��s 

�z
BytesIO.writercCs�|jrtd��z|j}Wntyt|�d���w|�}|dkr3|dkr-td|f��||_|jS|dkrCtd|j|�|_|jS|dkrUtdt|j�|�|_|jStd��)Nzseek on closed filer�r�negative seek position %rr	r
zunsupported whence value)	rlr.r�r8r+r��maxr-r�)rVr\r]�	pos_indexrrrrY�s(
����zBytesIO.seekcC�|jrtd��|jS)N�tell on closed file)rlr.r�r_rrrr`��zBytesIO.tellcCsr|jrtd��|dur|j}n"z|j}Wnty"t|�d���w|�}|dkr1td|f��|j|d�=|S)Nztruncate on closed filer�rznegative truncate position %r)rlr.r�r�r8r+r�)rVr\r�rrrrc�s
�zBytesIO.truncatecC�|jrtd��dS�Nr~Trr_rrrrw
�zBytesIO.readablecCr�r�rr_rrrrzr�zBytesIO.writablecCr�r�rr_rrrrqr�zBytesIO.seekablergr�r�)rQrRrSr�r�r�r�r�r>r�r�r�rYr`rcrwrzrq�
__classcell__rrr�rr��s"




r�c@sveZdZ	efdd�Zdd�Zdd�Zddd	�Zdd
d�Zdd
d�Z	ddd�Z
ddd�Zdd�Zdd�Z
ddd�ZdS)r;cCsH	|��s	td��t�||�|dkrtd��||_|��t�|_dS)Nz "raw" argument must be readable.r�invalid buffer size)	rwr7r�r�r.�buffer_size�_reset_read_buf�Lock�
_read_lock�rVrEr�rrrr�(szBufferedReader.__init__cCr�rg)rErwr_rrrrw5r�zBufferedReader.readablecCsd|_d|_dS)Nr�r)�	_read_buf�	_read_posr_rrrr�8s
zBufferedReader._reset_read_bufNcCsN	|dur
|dkr
td��|j�
|�|�Wd�S1s wYdS)Nrzinvalid number of bytes to read)r.r��_read_unlockedr�rrrr�<s$�zBufferedReader.readcCs�d}d}|j}|j}|dus|dkr^|��t|jd�r5|j��}|dur-||d�p,dS||d�|S||d�g}d}	|j��}||vrK|}n|t|�7}|�|�q?d�	|�p]|St|�|}	||	krw|j|7_||||�S||d�g}t
|j|�}
|	|kr�|j�|
�}||vr�|}n|	t|�7}	|�|�|	|ks�t||	�}d�	|�}||d�|_d|_|r�|d|�S|S)Nr�)r�Nrr�r)
r�r�r�r�rEr�r�r-r��joinr�r�r�)rVr�Z
nodata_valZempty_valuesr�r\�chunkZchunksZcurrent_size�availZwanted�outrrrr�IsR


�
�
	
zBufferedReader._read_unlockedrcCs6	|j�
|�|�Wd�S1swYdSrg)r��_peek_unlockedr�rrrr�}s$�zBufferedReader.peekcCsrt||j�}t|j�|j}||ks|dkr1|j|}|j�|�}|r1|j|jd�||_d|_|j|jd�Sr�)r�r�r-r�r�rEr�)rVr�ZwantZhaveZto_readZcurrentrrrr��s
zBufferedReader._peek_unlockedrcCsl	|dkr|j}|dkrdS|j�|�d�|�t|t|j�|j��Wd�S1s/wYdS)Nrr�r	)r�r�r�r�r�r-r�r�r�rrrr��s
�$�zBufferedReader.read1cCs|	t|t�s
t|�}|jdkrdS|�d�}d}|j��|t|�kr�tt|j�|jt|��}|rT|j|j|j|�||||�<|j|7_||7}|t|�krTn@t|�||j	kro|j
�||d��}|sjn2||7}n
|rs|sy|�d�syn+|r~|r~n.|t|�ks"Wd�|SWd�|SWd�|SWd�|SWd�|SWd�|S1s�wY|S)Nrr�r	)
r%r�r�r�r�r-r�r�r�r�rEr�r�)rVr�r��writtenr�r�rrrr��s^


�

�
��
��
��
��
��
��zBufferedReader._readintocCst�|�t|j�|jSrg)r�r`r-r�r�r_rrrr`�szBufferedReader.tellcCsp|tvrtd��|j�#|dkr|t|j�|j8}t�|||�}|��|Wd�S1s1wYdS)N�invalid whence valuer	)	�valid_seek_flagsr.r�r-r�r�r�rYr�r[rrrrY�s$�zBufferedReader.seekrgr�r�)rQrRrSr3r�rwr�r�r�r�r�r�r�r`rYrrrrr;s	



4


.r;c@s^eZdZ	efdd�Zdd�Zdd�Zddd	�Zd
d�Zdd
�Z	dd�Z
ddd�Zdd�ZdS)r:cCsF|��std��t�||�|dkrtd��||_t�|_t�|_	dS)Nz "raw" argument must be writable.rr�)
rzr7r�r�r.r�r��
_write_bufr��_write_lockr�rrrr��szBufferedWriter.__init__cCr�rg)rErzr_rrrrz�r�zBufferedWriter.writablecCst|t�r	td��|j�u|jrtd��t|j�|jkr |�	�t|j�}|j�
|�t|j�|}t|j�|jkrxz|�	�Wn7tyw}z+t|j�|jkrmt|j�|j}||8}|jd|j�|_t|j|j
|��WYd}~nd}~ww|Wd�S1s�wYdS)Nr�r�)r%r)r+rrlr.r-rr��_flush_unlocked�extend�BlockingIOError�errno�strerror)rVr!Zbeforer��eZoveragerrrr��s0

���$�zBufferedWriter.writeNcCsP|j�|��|dur|j��}|j�|�Wd�S1s!wYdSrg)rrrEr`rcrdrrrrcs

$�zBufferedWriter.truncatecCs4|j�
|��Wd�dS1swYdSrg)rrr_rrrrjs
"�zBufferedWriter.flushcCs�|jrtd��|jrDz	|j�|j�}Wntytd��w|dur*ttjdd��|t	|j�ks5|dkr9t
d��|jd|�=|js
dSdS)Nr�zHself.raw should implement RawIOBase: it should not raise BlockingIOErrorz)write could not complete without blockingrz*write() returned incorrect number of bytes)rlr.rrEr�r�RuntimeErrorrZEAGAINr-r7�rVr�rrrrs"���zBufferedWriter._flush_unlockedcCst�|�t|j�Srg)r�r`r-rr_rrrr`.r�zBufferedWriter.tellrcCsP|tvrtd��|j�|��t�|||�Wd�S1s!wYdS)Nr�)rr.rrr�rYr[rrrrY1s$�zBufferedWriter.seekcCs�|j�|jdus|jr	Wd�dSWd�n1swYz |��W|j�|j��Wd�dS1s>wYdS|j�
|j��Wd�w1sXwYwrg)rrErlrjr>r_rrrr>8s��
*��zBufferedWriter.closergr�)
rQrRrSr3r�rzr�rcrjrr`rYr>rrrrr:�s

r:c@s�eZdZ	efdd�Zddd�Zdd�Zdd	�Zddd�Zdd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zedd��ZdS) �BufferedRWPaircCs>	|��s	td��|��std��t||�|_t||�|_dS)Nz#"reader" argument must be readable.z#"writer" argument must be writable.)rwr7rzr;�readerr:�writer)rVrr
r�rrrr�XszBufferedRWPair.__init__rcCs|durd}|j�|�S�Nr)rr�r�rrrr�fszBufferedRWPair.readcC�|j�|�Srg)rr�r�rrrr�k�zBufferedRWPair.readintocCrrg)r
r�r�rrrr�nrzBufferedRWPair.writercCrrg)rr�r�rrrr�qrzBufferedRWPair.peekcCrrg)rr�r�rrrr�trzBufferedRWPair.read1cCrrg)rr�r�rrrr�wrzBufferedRWPair.readinto1cCr�rg)rrwr_rrrrwzr�zBufferedRWPair.readablecCr�rg)r
rzr_rrrrz}r�zBufferedRWPair.writablecCr�rg)r
rjr_rrrrj�r�zBufferedRWPair.flushcCs(z
|j��W|j��dS|j��wrg)r
r>rr_rrrr>�szBufferedRWPair.closecCs|j��p	|j��Srg)rr2r
r_rrrr2�r�zBufferedRWPair.isattycCr�rg)r
rlr_rrrrl�r�zBufferedRWPair.closedNr�r�)rQrRrSr3r�r�r�r�r�r�r�rwrzrjr>r2r�rlrrrrrHs 


rc@sleZdZ	efdd�Zddd�Zdd�Zdd	d
�Zddd�Zd
d�Z	ddd�Z
ddd�Zdd�Zdd�Z
dS)r9cCs(|��t�|||�t�|||�dSrg)rur;r�r:r�rrrr��szBufferedRandom.__init__rcCs�|tvrtd��|��|jr/|j�|j�|jt|j�d�Wd�n1s*wY|j�||�}|j�|�	�Wd�n1sHwY|dkrUt
d��|S)Nr�r	rz seek() returned invalid position)rr.rjr�r�rErYr�r-r�r7r[rrrrY�s�
�zBufferedRandom.seekcCs|jrt�|�St�|�Srg)rr:r`r;r_rrrr`�s

zBufferedRandom.tellNcCs|dur|��}t�||�Srg)r`r:rcrdrrrrc�szBufferedRandom.truncatecCs |durd}|��t�||�Sr)rjr;r�r�rrrr��szBufferedRandom.readcC�|��t�||�Srg)rjr;r�r�rrrr���zBufferedRandom.readintocCrrg)rjr;r�r�rrrr��rzBufferedRandom.peekrcCrrg)rjr;r�r�rrrr��rzBufferedRandom.read1cCrrg)rjr;r�r�rrrr��rzBufferedRandom.readinto1cCsZ|jr'|j�|j�|jt|j�d�|��Wd�n1s"wYt�||�Sr�)	r�r�rErYr�r-r�r:r�r�rrrr��s
�zBufferedRandom.writer�rgr�)rQrRrSr3r�rYr`rcr�r�r�r�r�r�rrrrr9�s




r9cs�eZdZdZdZdZdZdZdZdZ	d0dd�Z
dd	�Zd
d�Zdd
�Z
dd�Zd1dd�Zd1dd�Zdd�Zdd�Zdd�Zefdd�Zdd�Zd1dd�Z�fd d!�Zd"d#�Zd$d%�Zd&d'�Zd(d)�Zd*d+�Zed,d-��Zed.d/��Z �Z!S)2r1rFNTrc
Cs0	|jdkrz|jrt�|j�Wd|_nd|_wt|t�r"td��t|t�r2|}|dkr1td��nd}t|t	�s@td|f��t
|�t
d�ksOtd|f��tdd�|D��d	ksa|�d
�d	kretd��d|vrvd
|_
d
|_tjtjB}n(d|vr�d
|_d}nd|vr�d
|_tjtjB}nd|vr�d
|_d
|_tjtjB}d
|vr�d
|_d
|_|jr�|jr�|tjO}n|jr�|tjO}n|tjO}|ttdd�O}ttdd�p�ttdd�}||O}d}z�|dk�r|s�td��|dur�t�||d�}n|||�}t|t��std��|dk�rtd��|}|�st�|d�||_t�|�}	zt�|	j��r2t t!j"t�#t!j"�|��Wn
t$�y=Ynwt|	dd�|_%|j%d	k�rNt&|_%t'�rWt'|tj(�||_)|j�r�z	t�*|dt+�Wnt�y�}
z|
j!t!j,k�rx�WYd}
~
nd}
~
wwWn|du�r�t�|��||_dS)Nrrz$integer argument expected, got floatznegative file descriptorzinvalid mode: %szxrwab+css�|]}|dvVqdS)ZrwaxNr)�.0�crrr�	<genexpr>s�z"FileIO.__init__.<locals>.<genexpr>r	rzKMust have exactly one of create/read/write/append mode and at most one plusrTrrr�O_BINARYZO_NOINHERIT�	O_CLOEXECz'Cannot use closefd=False with file namei�zexpected integer from openerzNegative file descriptorFr6)-�_fd�_closefdr'r>r%�floatr+r&r.r)r,�sum�count�_created�	_writable�O_EXCL�O_CREAT�	_readable�O_TRUNC�
_appending�O_APPEND�O_RDWR�O_RDONLY�O_WRONLY�getattrrIr7�set_inheritabler4�stat�S_ISDIR�st_mode�IsADirectoryErrorrZEISDIRrr8�_blksizer3�_setmoderrN�lseekrZESPIPE)rVr?r=rCr$�fdrZnoinherit_flagZowned_fdZfdfstatrrrrr��s�
�

�
$

�



�������


zFileIO.__init__cCsN|jdkr!|jr#|js%ddl}|jd|ftd|d�|��dSdSdSdS)Nrzunclosed file %rr
)r�source)rrrlrr�ResourceWarningr>)rVrrrrrn]s��zFileIO.__del__cCr�r�r�r_rrrr�dr�zFileIO.__getstate__cCsjd|jj|jjf}|jrd|Sz|j}Wnty*d||j|j|jfYSwd|||j|jfS)Nz%s.%sz
<%s [closed]>z<%s fd=%d mode=%r closefd=%r>z<%s name=%r mode=%r closefd=%r>)	rUrRrSrlrNr8rr=r)rV�
class_namerNrrrr�gs�
���zFileIO.__repr__cC�|jstd��dS)NzFile not open for reading)r!rPr_rrrryu��zFileIO._checkReadablecCr5)NzFile not open for writing)rrPrsrrrr{yr6zFileIO._checkWritablecCsP	|��|��|dus|dkr|��Szt�|j|�WSty'YdSwr�)riryr�r'r�rrr�rrrr�}s�zFileIO.readcCs�	|��|��t}zt�|jdt�}t�|j�j}||kr%||d}Wn	t	y/Ynwt
�}	t|�|krEt|�}|t|t�7}|t|�}z	t�
|j|�}Wntye|rbYt|�SYdSw|sm	t|�S||7}q4r^)riryr3r'r0rrr4�st_sizer7r�r-r�r�rr*)rV�bufsizer\�endrFr�r�rrrr��s@������zFileIO.readallcCs6	t|��d�}|�t|��}t|�}||d|�<|Sr�)r�r�r�r-)rVr!�mr�r�rrrr��szFileIO.readintocCs8	|��|��zt�|j|�WStyYdSwrg)rir{r'r�rrr�rrrr��s�zFileIO.writecCs,	t|t�r
td��|��t�|j||�S)Nzan integer is required)r%rr+rir'r0rr[rrrrY�s


zFileIO.seekcCs	|��t�|jdt�Sr�)rir'r0rrr_rrrr`�szFileIO.tellcCs4	|��|��|dur|��}t�|j|�|Srg)rir{r`r'�	ftruncaterr�rrrrc�szFileIO.truncatecsL	|js$z|jrt�|j�Wt���dSWt���dSt���wdSrg)rlrr'r>rr�r_r�rrr>�s��zFileIO.closecCsJ	|��|jdur"z|��Wntyd|_Y|jSwd|_|jS)NFT)ri�	_seekabler`r7r_rrrrq�s
�zFileIO.seekablecC�	|��|jSrg)rir!r_rrrrw�zFileIO.readablecCr=rg)rirr_rrrrzr>zFileIO.writablecCr=rg)rirr_rrrr5
r>z
FileIO.filenocCs	|��t�|j�Srg)rir'r2rr_rrrr2sz
FileIO.isattycCr|rg)rr_rrrrCszFileIO.closefdcCsB	|jr|jr	dSdS|jr|jrdSdS|jr|jrdSdSdS)Nzxb+Zxbzab+Zabzrb+rJ�wb)rr!r#rr_rrrr=szFileIO.mode)rTNrg)"rQrRrSrrr!rr#r<rr�rnr�r�ryr{r�r�r�r�rrYr`rcr>rqrwrzr5r2r�rCr=r�rrr�rr1�s>
y

#



r1c@s^eZdZ	ddd�Zdd�Zddd�Zd	d
�Zdd�Zed
d��Z	edd��Z
edd��ZdS)�
TextIOBasercCrXr�rZr�rrrr�:szTextIOBase.readcCrXr�rZ)rV�srrrr�D�zTextIOBase.writeNcCrXrbrZrdrrrrcHrBzTextIOBase.truncatecCrX)Nr�rZr_rrrr�Lr�zTextIOBase.readlinecCrXr�rZr_rrrr�Sr�zTextIOBase.detachcC�	dSrgrr_rrrr\szTextIOBase.encodingcCrCrgrr_rrr�newlinesaszTextIOBase.newlinescCrCrgrr_rrrrAkszTextIOBase.errorsr�rg)rQrRrSr�r�rcr�r�r�rrDrArrrrr@2s


	

	r@c@sReZdZ	ddd�Zddd�Zdd�Zd	d
�Zdd�Zd
ZdZ	dZ
edd��ZdS)�IncrementalNewlineDecoder�strictcCs,tjj||d�||_||_d|_d|_dS)N)rArF)�codecs�IncrementalDecoderr��	translate�decoder�seennl�	pendingcr)rVrJrIrArrrr�|s

z"IncrementalNewlineDecoder.__init__FcCs�|jdur|}n|jj||d�}|jr|s|rd|}d|_|�d�r.|s.|dd�}d|_|�d�}|�d�|}|�d�|}|j|oH|j|oL|jB|oQ|jBO_|j	rh|r`|�
dd�}|rh|�
dd�}|S)N��final�
FrT�
�
)rJ�decoderLr�rrK�_LF�_CR�_CRLFrI�replace)rV�inputrN�outputZcrlfZcrZlfrrrrR�s*

�z IncrementalNewlineDecoder.decodecCs@|jdur
d}d}n|j��\}}|dK}|jr|dO}||fS)Nr�rr	)rJ�getstaterL)rVr��flagrrrrY�s
z"IncrementalNewlineDecoder.getstatecCs<|\}}t|d@�|_|jdur|j�||d?f�dSdSr�)�boolrLrJ�setstate)rV�stater�rZrrrr\�s

�z"IncrementalNewlineDecoder.setstatecCs(d|_d|_|jdur|j��dSdS)NrF)rKrLrJ�resetr_rrrr^�s

�zIncrementalNewlineDecoder.resetr	r
�cCs
d|jS)N)NrQrO)rOrQrP)rQrP)rOrP)rOrQrP)rKr_rrrrD�s�z"IncrementalNewlineDecoder.newlinesN)rF)F)
rQrRrSr�rRrYr\r^rSrTrUr�rDrrrrrEus

rEc@s�eZdZ	dZdZ		dNdd�Zdd�Z		dNdd	�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�ZdOd3d4�Zd5d6�Zd7d8�Z 	9	9dPd:d;�Z!d<d=�Z"d>d?�Z#dOd@dA�Z$dBdC�Z%dQdDdE�Z&dOdFdG�Z'dHdI�Z(dOdJdK�Z)e	dLdM��Z*dS)Rr<iNFc		Cs0|�|�t|�}|dkr$zt�|���pd}Wnttfy#Ynw|dkr?zddl}Wnty9d}Ynw|�	d�}t
|t�sJtd|��t
�|�jsXd}t||��|dur_d}nt
|t�sjtd|��trqt
�|�||_d	|_d|_d|_|j��|_|_t|jd
�|_|�|||||�dS)Nrr�utf-8FrzG%r is not a text encoding; use codecs.open() to handle arbitrary codecsrFrr#r�)�_check_newlinerr'�device_encodingr5r8rPr�ImportErrorZgetpreferredencodingr%r)r.rG�lookup�_is_text_encoding�LookupError�
_CHECK_ERRORS�lookup_errorr��_decoded_chars�_decoded_chars_used�	_snapshotrHrqr<�_tellingr��
_has_read1�
_configure)	rVrHrrArBrG�
write_throughrrtrrrr��sF
��




�zTextIOWrapper.__init__cCs>|durt|t�stdt|�f��|dvrtd|f��dS)Nzillegal newline type: %r)Nr#rQrOrPzillegal newline value: %r)r%r)r+�typer.)rVrBrrrras
�zTextIOWrapper._check_newlinecCs�||_||_d|_d|_d|_||_|du|_||_|dk|_|p$t	j
|_||_||_
|jrQ|��rS|j��}|dkrUz
|���d�WdStyPYdSwdSdSdS)N�r#r)�	_encoding�_errors�_encoder�_decoder�	_b2cratio�_readuniversal�_readtranslate�_readnl�_writetranslater'�linesep�_writenl�_line_buffering�_write_throughr<rzrHr`�_get_encoderr\rf)rVrrArBrGro�positionrrrrns,


��zTextIOWrapper._configurecCs|d�|jj|jj�}z|j}Wn	tyYnw|d�|�7}z|j}Wn	ty.Ynw|d�|�7}|d�|j�S)Nz<{}.{}z name={0!r}z mode={0!r}z encoding={0!r}>)r�rUrRrSrNr8r=r)rVrFrNr=rrrr�Bs 
�
�
�zTextIOWrapper.__repr__cCr�rg)rrr_rrrrSr�zTextIOWrapper.encodingcCr�rg)rsr_rrrrAWr�zTextIOWrapper.errorscCr�rg)r}r_rrrrG[r�zTextIOWrapper.line_bufferingcCr�rg)r~r_rrrro_r�zTextIOWrapper.write_throughcCr�rg)r�r_rrrrHcr�zTextIOWrapper.buffer)rrArBrGrocCs�	|jdur|dus|dus|turtd��|dur%|dur"|j}nd}nt|t�s0td|��|dur8|j}nt|t�sCtd|��|turJ|j}|�	|�|durV|j
}|dur]|j}|��|�
|||||�dS)NzPIt is not possible to set the encoding or newline of stream after the first readrFrr)ru�EllipsisrPrsr%r)r+rrryrarGrorjrn)rVrrArBrGrorrr�reconfiguregs8
�



�zTextIOWrapper.reconfigurecCr�r})rlr.r<r_rrrrq�r�zTextIOWrapper.seekablecCr�rg)rHrwr_rrrrw�r�zTextIOWrapper.readablecCr�rg)rHrzr_rrrrz�r�zTextIOWrapper.writablecCs|j��|j|_dSrg)rHrjr<rlr_rrrrj�s
zTextIOWrapper.flushcCr�rg)rHrlrjr>r_rrrr>�s

�zTextIOWrapper.closecCr�rg)rHrlr_rrrrl�r�zTextIOWrapper.closedcCr�rg)rHrNr_rrrrN�r�zTextIOWrapper.namecCr�rg)rHr5r_rrrr5�r�zTextIOWrapper.filenocCr�rg)rHr2r_rrrr2�r�zTextIOWrapper.isattycCs�	|jrtd��t|t�std|jj��t|�}|js|j	o"d|v}|r4|jr4|j
dkr4|�d|j
�}|jp:|�
�}|�|�}|j�|�|j	rS|sOd|vrS|��|�d�d|_|jrc|j��|S)Nr�zcan't write %s to text streamrQrOr#)rlr.r%r)r+rUrQr-rzr}r|rVrtr�encoderHr�rj�_set_decoded_charsrkrur^)rVrAZlengthZhaslf�encoderr!rrrr��s*
�


zTextIOWrapper.writecCst�|j�}||j�|_|jSrg)rG�getincrementalencoderrrrsrt)rVZmake_encoderrrrr�szTextIOWrapper._get_encodercCs2t�|j�}||j�}|jrt||j�}||_|Srg)rG�getincrementaldecoderrrrsrwrErxru)rVZmake_decoderrJrrr�_get_decoder�s
zTextIOWrapper._get_decodercCs	||_d|_dSr�)rirj)rV�charsrrrr��s
z TextIOWrapper._set_decoded_charscCsH	|j}|dur|j|d�}n	|j|||�}|jt|�7_|Srg)rjrir-)rVr��offsetr�rrr�_get_decoded_chars�sz TextIOWrapper._get_decoded_charscCs&	|j|kr
td��|j|8_dS)Nz"rewind decoded_chars out of bounds)rj�AssertionErrorr
rrr�_rewind_decoded_chars�s
z#TextIOWrapper._rewind_decoded_charscCs�	|jdur
td��|jr|j��\}}|jr|j�|j�}n|j�|j�}|}|j�	||�}|�
|�|rBt|�t|j�|_
nd|_
|jrO|||f|_|S)Nz
no decoderrq)rur.rlrYrmrHr��_CHUNK_SIZEr�rRr�r-rirvrk)rV�
dec_buffer�	dec_flags�input_chunk�eofZ
decoded_charsrrr�_read_chunk�s"


zTextIOWrapper._read_chunkrcCs(||d>B|d>B|d>Bt|�d>BS)N�@���)r[)rVr�r��
bytes_to_feed�need_eof�
chars_to_skiprrr�_pack_cookie	s
�
�zTextIOWrapper._pack_cookiecCsJt|d�\}}t|d�\}}t|d�\}}t|d�\}}|||t|�|fS)Nl)�divmodr[)rVZbigint�restr�r�r�r�r�rrr�_unpack_cookie$	s
zTextIOWrapper._unpack_cookiec	Cs>|jstd��|jstd��|��|j��}|j}|dus#|jdur,|j	r*t
d��|S|j\}}|t|�8}|j}|dkrD|�
||�S|��}z�t|j|�}d}|dkr�|�d|f�t|�|d|���}	|	|kr�|��\}
}|
s{|}||	8}n|t|
�8}d}n||8}|d}|dksVd}|�d|f�||}|}
|dkr�|�
||
�W|�|�Sd}d}d}t|t|��D]7}|d7}|t|�|||d���7}|��\}}|s�||kr�||7}||8}|dd}
}}||kr�nq�|t|jdd	d
��7}d	}||k�r
td��|�
||
|||�W|�|�S|�|�w)N�!underlying stream is not seekablez(telling position disabled by next() callzpending decoded textrr	r�r
FTrMz'can't reconstruct logical file position)r<rPrlr7rjrHr`rurkrir�r-rjr�rYr&rvr\rR�range)rVr�rJr�Z
next_inputr�Zsaved_stateZ
skip_bytesZ	skip_backr�r!�d�	start_posZstart_flagsZ	bytes_fedr�Z
chars_decoded�ir�rrrr`+	s~

� ��

�zTextIOWrapper.tellcCs$|��|dur|��}|j�|�Srg)rjr`rHrcrdrrrrc�	szTextIOWrapper.truncatecCr�)Nzbuffer is already detached)rHr.rjr�)rVrHrrrr��	r�zTextIOWrapper.detachcs��fdd�}�jr
td���jstd��|tkr'|dkr td��d}���}n-|tkrT|dkr3td������j�	d|�}��
d�d�_�jrN�j�
�||�|S|dkr_td	|f��|dkrjtd
|f�������|�\}}}}}	�j�	|���
d�d�_|dkr��jr��j�
�n�js�|s�|	r��jp�����_�j�d|f�|df�_|	rԈj�|�}
��
�j�|
|��||
f�_t�j�|	kr�td��|	�_||�|S)
NcsL	z	�jp���}Wn
tyYdSw|dkr |�d�dS|��dSr�)rtrrfr\r^)r�r�r_rr�_reset_encoder�	s�z*TextIOWrapper.seek.<locals>._reset_encoderr�r�rz#can't do nonzero cur-relative seeksz#can't do nonzero end-relative seeksr#zunsupported whence (%r)r�r�z#can't restore logical file position)rlr.r<rPrr`rrjrHrYr�rkrur^r�r�r\r�rRr-rir7rj)rVZcookier]r�r�r�r�r�r�r�r�rr_rrY�	s`



�

�
zTextIOWrapper.seekcCs�|��|durd}nz|j}Wntyt|�d���w|�}|jp(|��}|dkrE|��|j|j�	�dd�}|�
d�d|_|Sd}|�|�}t|�|krl|sl|�
�}||�|t|��7}t|�|krl|rT|S)Nrr�rTrMr#F)ryr�r8r+rur�r�rRrHr�r�rkr-r�)rVr�r�rJrFr�rrrr��	s0
��


�zTextIOWrapper.readcCs(d|_|��}|sd|_|j|_t�|Srp)rlr�rkr<r�r�rrrr�
szTextIOWrapper.__next__c	Cs�|jrtd��|durd}nz|j}Wnty!t|�d���w|�}|��}d}|js2|��d}}	|jrN|�	d|�}|dkrI|d}n�t
|�}nU|jr�|�	d|�}|�	d|�}|dkro|dkrjt
|�}n9|d}nb|dkrx|d}nY||kr�|d}nP||dkr�|d	}nE|d}n@|�	|j�}|dkr�|t
|j�}n.|dkr�t
|�|kr�|}n!|�
�r�|jr�n|�
�s�|jr�||��7}n
|�d
�d|_|Sq7|dkr�||kr�|}|�t
|�|�|d|�S)Nr�rr�rTrQr	rOr
r#)rlr.r�r8r+r�rur�rxr�r-rwryr�rir�rkr�)	rVr�r�r��startr\�endposZnlposZcrposrrrr�
s|
�

�
�@zTextIOWrapper.readlinecCs|jr|jjSdSrg)rurDr_rrrrDi
szTextIOWrapper.newlines)NNNFFrg)rrFrr�)+rQrRrSr�r�r�rarnr�r�rrArGrorHr�r�rqrwrzrjr>rlrNr5r2r�rr�r�r�r�r�r�r�r`rcr�rYr�r�r�rDrrrrr<�sp
�-
�$




�)



*
�

c

K
	]r<csPeZdZ	d�fdd�	Zdd�Zdd�Zed	d
��Zedd��Zd
d�Z	�Z
S)�StringIOr#rQcsjtt|�jt�dd|d�|durd|_|dur3t|t�s'td�t	|�j
���|�|�|�d�dSdS)Nr`�
surrogatepass)rrArBFz*initial_value must be str or None, not {0}r)
r�r�r�r�rzr%r)r+r�rprQr�rY)rVZ
initial_valuerBr�rrr�u
s�
�
�zStringIO.__init__c	CsT|��|jp
|��}|��}|��z|j|j��dd�W|�|�S|�|�w)NTrM)	rjrur�rYr^rRrHr�r\)rVrJZ	old_staterrrr��
szStringIO.getvaluecCs
t�|�Srg)�objectr�r_rrrr��
s
zStringIO.__repr__cC�dSrgrr_rrrrA�
�zStringIO.errorscCr�rgrr_rrrr�
r�zStringIO.encodingcCs|�d�dSr�rZr_rrrr��
szStringIO.detach)r#rQ)rQrRrSr�r�r�r�rArr�r�rrr�rr�n
s


r�)r
)rrNNNTN)9r'�abcrGrr*r
�_threadrr��platformZmsvcrtrr/�iorrrrrr��addr�	SEEK_DATAr3rr�dev_modermrgr�staticmethodrIrL�	open_coder8rOrPr7r.�ABCMetarT�registerr��_ior1r�r�r�r;r:rr9r@rHrEr<r�rrrr�<module>s�


�\
�
�#=
gkCiIJY@U)

?>