HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //home/arjun/.local/lib/python3.10/site-packages/anyio/streams/__pycache__/file.cpython-310.pyc
o

���g�@s�ddlmZddlmZmZddlmZmZddlm	Z	ddl
mZddlm
Z
mZmZddlmZmZmZmZmZmZdd	lmZmZGd
d�de�ZGdd
�d
�ZGdd�dee�ZGdd�dee�ZdS)�)�annotations)�Callable�Mapping)�SEEK_SET�UnsupportedOperation)�PathLike)�Path)�Any�BinaryIO�cast�)�BrokenResourceError�ClosedResourceError�EndOfStream�TypedAttributeSet�	to_thread�typed_attribute)�ByteReceiveStream�ByteSendStreamc@s8eZdZUe�Zded<e�Zded<e�Zded<dS)�FileStreamAttributer
�filer�path�int�filenoN)�__name__�
__module__�__qualname__rr�__annotations__rr�rr�E/home/arjun/.local/lib/python3.10/site-packages/anyio/streams/file.pyrs
rc@s.eZdZd
dd�Zddd�Zedd
d��ZdS)�_BaseFileStreamrr
cCs
||_dS�N��_file)�selfrrrr�__init__s
z_BaseFileStream.__init__�return�Nonec�s�t�|jj�IdHdSr!)r�run_syncr#�close�r$rrr�aclose!s�z_BaseFileStream.aclose�Mapping[Any, Callable[[], Any]]csjtj�fdd�i}t�jd�r�fdd�|tj<z�j��Wn
ty)Y|Sw�fdd�|tj<|S)Ncs�jSr!r"rr*rr�<lambda>'sz2_BaseFileStream.extra_attributes.<locals>.<lambda>�namecst�jj�Sr!)rr#r.rr*rrr-+scs
�j��Sr!)r#rrr*rrr-2s
)rr�hasattrr#rrr)r$�
attributesrr*r�extra_attributes$s��z _BaseFileStream.extra_attributesN)rr
)r&r')r&r,)rrrr%r+�propertyr1rrrrr s


r c@sBeZdZdZeddd��Zdddd�Zefddd�Zddd�Z	dS)�FileReadStreamz�
    A byte stream that reads from a file in the file system.

    :param file: a file that has been opened for reading in binary mode

    .. versionadded:: 3.0
    r�str | PathLike[str]r&c�s(�t�t|�jd�IdH}|tt|��S)z{
        Create a file read stream by opening the given file.

        :param path: path of the file to read from

        �rbN�rr(r�openrr
)�clsrrrrr�	from_path@s�zFileReadStream.from_path��	max_bytesr�bytesc
�sZ�z
t�|jj|�IdH}Wntytd�ty&}zt|�d}~ww|r+|St�r!)	rr(r#�read�
ValueErrorr�OSErrorr
r)r$r;�data�excrrr�receiveKs���zFileReadStream.receive�position�whencec�s�t�|jj||�IdHS)au
        Seek the file to the given position.

        .. seealso:: :meth:`io.IOBase.seek`

        .. note:: Not all file descriptors are seekable.

        :param position: position to seek the file to
        :param whence: controls how ``position`` is interpreted
        :return: the new absolute position
        :raises OSError: if the file is not seekable

        N)rr(r#�seek)r$rCrDrrrrEXs�zFileReadStream.seekc�s�t�|jj�IdHS)z�
        Return the current stream position.

        .. note:: Not all file descriptors are seekable.

        :return: the current absolute position
        :raises OSError: if the file is not seekable

        N)rr(r#�tellr*rrrrFhs�
zFileReadStream.tellN)rr4r&r3)r:)r;rr&r<)rCrrDrr&r)r&r)
rrr�__doc__�classmethodr9rBrrErFrrrrr37s

r3c@s,eZdZdZe	dddd	��Zdd
d�ZdS)�FileWriteStreamz�
    A byte stream that writes to a file in the file system.

    :param file: a file that has been opened for writing in binary mode

    .. versionadded:: 3.0
    Frr4�append�boolr&c�s4�|rdnd}t�t|�j|�IdH}|tt|��S)a
        Create a file write stream by opening the given file for writing.

        :param path: path of the file to write to
        :param append: if ``True``, open the file for appending; if ``False``, any
            existing file at the given path will be truncated

        �ab�wbNr6)r8rrJ�moderrrrr9~s�zFileWriteStream.from_path�itemr<r'c
�sP�zt�|jj|�IdHWdStytd�ty'}zt|�d}~wwr!)rr(r#�writer>rr?r
)r$rOrArrr�send�s���zFileWriteStream.sendN)F)rr4rJrKr&rI)rOr<r&r')rrrrGrHr9rQrrrrrIus�rIN)�
__future__r�collections.abcrr�iorr�osr�pathlibr�typingr	r
r�r
rrrrr�abcrrrr r3rIrrrr�<module>s 	>