Format: application/x-python-code
⬇ Download File (5.4 KB)
   1  o
   2  
   3  ;'h�@s�ddlmZddlmZmZddlmZmZddlm	Z	ddl
   4  mZddlm
   5  Z
   6  mZmZddlmZmZmZmZmZmZdd	lmZmZGd
   7  d�de�ZGdd
   8  �d
   9  �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
  10  �filer�path�int�filenoN)�__name__�
  11  __module__�__qualname__rr�__annotations__rr�rr�HC:\Users\shubh\Videos\agent\nova\Lib\site-packages\anyio/streams/file.pyrs
  12  rc@s.eZdZd
  13  dd�Zddd�Zedd
  14  d��ZdS)�_BaseFileStreamrr
  15  cCs
  16  ||_dS�N��_file)�selfrrrr�__init__s
  17  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
  18  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
  19  �j��Sr!)r#rrr*rrr-2s
  20  )rr�hasattrr#rrr)r$�
  21  attributesrr*r�extra_attributes$s��z _BaseFileStream.extra_attributesN)rr
  22  )r&r')r&r,)rrrr%r+�propertyr1rrrrr s
  23  
  24  
  25  r c@sBeZdZdZeddd��Zdddd�Zefddd�Zddd�Z	dS)�FileReadStreamz�
  26      A byte stream that reads from a file in the file system.
  27  
  28      :param file: a file that has been opened for reading in binary mode
  29  
  30      .. versionadded:: 3.0
  31      r�str | PathLike[str]r&c�s(�t�t|�jd�IdH}|tt|��S)z{
  32          Create a file read stream by opening the given file.
  33  
  34          :param path: path of the file to read from
  35  
  36          �rbN�rr(r�openrr
  37  )�clsrrrrr�	from_path@s�zFileReadStream.from_path��	max_bytesr�bytesc
  38  �sZ�z
  39  t�|jj|�IdH}Wntytd�ty&}zt|�d}~ww|r+|St�r!)	rr(r#�read�
  40  ValueErrorr�OSErrorr
  41  r)r$r;�data�excrrr�receiveKs���zFileReadStream.receive�position�whencec�s�t�|jj||�IdHS)au
  42          Seek the file to the given position.
  43  
  44          .. seealso:: :meth:`io.IOBase.seek`
  45  
  46          .. note:: Not all file descriptors are seekable.
  47  
  48          :param position: position to seek the file to
  49          :param whence: controls how ``position`` is interpreted
  50          :return: the new absolute position
  51          :raises OSError: if the file is not seekable
  52  
  53          N)rr(r#�seek)r$rCrDrrrrEXs�zFileReadStream.seekc�s�t�|jj�IdHS)z�
  54          Return the current stream position.
  55  
  56          .. note:: Not all file descriptors are seekable.
  57  
  58          :return: the current absolute position
  59          :raises OSError: if the file is not seekable
  60  
  61          N)rr(r#�tellr*rrrrFhs�
  62  zFileReadStream.tellN)rr4r&r3)r:)r;rr&r<)rCrrDrr&r)r&r)
  63  rrr�__doc__�classmethodr9rBrrErFrrrrr37s
  64  
  65  r3c@s,eZdZdZe	dddd	��Zdd
  66  d�ZdS)�FileWriteStreamz�
  67      A byte stream that writes to a file in the file system.
  68  
  69      :param file: a file that has been opened for writing in binary mode
  70  
  71      .. versionadded:: 3.0
  72      Frr4�append�boolr&c�s4�|rdnd}t�t|�j|�IdH}|tt|��S)a
  73          Create a file write stream by opening the given file for writing.
  74  
  75          :param path: path of the file to write to
  76          :param append: if ``True``, open the file for appending; if ``False``, any
  77              existing file at the given path will be truncated
  78  
  79          �ab�wbNr6)r8rrJ�moderrrrr9~s�zFileWriteStream.from_path�itemr<r'c
  80  �sP�zt�|jj|�IdHWdStytd�ty'}zt|�d}~wwr!)rr(r#�writer>rr?r
  81  )r$rOrArrr�send�s���zFileWriteStream.sendN)F)rr4rJrKr&rI)rOr<r&r')rrrrGrHr9rQrrrrrIus�rIN)�
  82  __future__r�collections.abcrr�iorr�osr�pathlibr�typingr	r
  83  r�r
  84  rrrrr�abcrrrr r3rIrrrr�<module>s 	>