
    > /iv                        d dl mZ dZd dlmZmZ d dlmZmZ d dl	m
Z
 d dlmZ d dlmZmZmZ dd	lmZmZmZmZmZmZ dd
lmZmZ  G d de      Z G d d      Z G d dee      Z G d dee      Zy)    )annotations)FileReadStreamFileStreamAttributeFileWriteStream)CallableMapping)SEEK_SETUnsupportedOperation)PathLike)Path)AnyBinaryIOcast   )BrokenResourceErrorClosedResourceErrorEndOfStreamTypedAttributeSet	to_threadtyped_attribute)ByteReceiveStreamByteSendStreamc                  V    e Zd ZU  e       Zded<    e       Zded<    e       Zded<   y)r   r   filer   pathintfilenoN)__name__
__module____qualname__r   r   __annotations__r   r        H/srv/sistema/bot/venv/lib/python3.12/site-packages/anyio/streams/file.pyr   r      s)    $&D(& "D$"!#FC#r#   r   c                  .    e Zd ZddZddZedd       Zy)_BaseFileStreamc                    || _         y N_file)selfr   s     r$   __init__z_BaseFileStream.__init__$   s	    
r#   c                r   K   t        j                  | j                  j                         d {    y 7 wr(   )r   run_syncr*   closer+   s    r$   aclosez_BaseFileStream.aclose'   s$       !1!1222s   -757c                    t         j                   fdi}t         j                  d      r fd|t         j                  <   	  j                  j                           fd|t         j
                  <   |S # t        $ r Y |S w xY w)Nc                      j                   S r(   r)   r0   s   r$   <lambda>z2_BaseFileStream.extra_attributes.<locals>.<lambda>-   s    djj r#   namec                 B    t         j                  j                        S r(   )r   r*   r5   r0   s   r$   r4   z2_BaseFileStream.extra_attributes.<locals>.<lambda>1   s    4

;P r#   c                 8     j                   j                         S r(   )r*   r   r0   s   r$   r4   z2_BaseFileStream.extra_attributes.<locals>.<lambda>8   s    TZZ=N=N=P r#   )r   r   hasattrr*   r   r   r
   )r+   
attributess   ` r$   extra_attributesz _BaseFileStream.extra_attributes*   s      $$&84

 4::v&3PJ*//0	QJJ 6QJ*112 $ 	 	s   A6 6	BBN)r   r   )returnNone)r;   zMapping[Any, Callable[[], Any]])r   r   r    r,   r1   propertyr:   r"   r#   r$   r&   r&   #   s     3  r#   r&   c                  @    e Zd ZdZedd       Zdd	dZefd
dZddZ	y)r   z
    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
    c                   K   t        j                  t        |      j                  d       d{   } | t	        t
        |            S 7 w)z{
        Create a file read stream by opening the given file.

        :param path: path of the file to read from

        rbNr   r.   r   openr   r   )clsr   r   s      r$   	from_pathzFileReadStream.from_pathF   s<      ''T
>>4$'(( ?s   -AA
Ac                   K   	 t        j                  | j                  j                  |       d {   }|r|S t        7 # t        $ r t
        d t        $ r}t        |d }~ww xY wwr(   )	r   r.   r*   read
ValueErrorr   OSErrorr   r   )r+   	max_bytesdataexcs       r$   receivezFileReadStream.receiveQ   se     	/"++DJJOOYGGD K H 	0%4/ 	/%3.	/s7   A)-A A A 
A) A A&A!!A&&A)c                t   K   t        j                  | j                  j                  ||       d{   S 7 w)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)r   r.   r*   seek)r+   positionwhences      r$   rN   zFileReadStream.seek^   s+      ''

6JJJJs   /868c                p   K   t        j                  | j                  j                         d{   S 7 w)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)r   r.   r*   tellr0   s    r$   rR   zFileReadStream.telln   s'      ''

8888s   -646N)r   str | PathLike[str]r;   r   )i   )rI   r   r;   bytes)rO   r   rP   r   r;   r   )r;   r   )
r   r   r    __doc__classmethodrD   rL   r	   rN   rR   r"   r#   r$   r   r   =   s0     ) ) 7? K 
9r#   r   c                  8    e Zd ZdZe	 d	 	 	 	 	 dd       ZddZy)r   z
    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
    c                   K   |rdnd}t        j                  t        |      j                  |       d{   } | t	        t
        |            S 7 w)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wbNrA   )rC   r   appendmoder   s        r$   rD   zFileWriteStream.from_path   sE      t4''T
>>4$'(( ?s   3AAAc                   K   	 t        j                  | j                  j                  |       d {    y 7 # t        $ r t
        d t        $ r}t        |d }~ww xY wwr(   )r   r.   r*   writerG   r   rH   r   )r+   itemrK   s      r$   sendzFileWriteStream.send   sR     	/$$TZZ%5%5t<<< 	0%4/ 	/%3.	/s1   A -9 79 A 9 AAAA N)F)r   rS   r[   boolr;   r   )r_   rT   r;   r<   )r   r   r    rU   rV   rD   r`   r"   r#   r$   r   r   {   s;     7<)&)04)	) )/r#   r   N)
__future__r   __all__collections.abcr   r   ior	   r
   osr   pathlibr   typingr   r   r    r   r   r   r   r   r   abcr   r   r   r&   r   r   r"   r#   r$   <module>rk      sg    " . -   & &  4$+ $ 4;9_&7 ;9|/o~ /r#   