Ë
    zñ�jwJ  ã                   óR   — d dl mZ d dlmZmZmZmZmZ d dlm	Z	m
Z
  G d„ de	«      Zy)é    )ÚBytesIO)Úlinefeed_byte_valueÚcrlfÚcr_byteÚlinefeed_byteÚcr_byte_value)ÚClosingContextManagerÚuc                   óæ   — e Zd ZdZdZdZdZdZdZdZ	dZ
dZdZd	Zd
Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd%d„Zd%d„Zd%d„Zd&d„Zd„ Zd„ Zd„ Zd„ Z e!d„ «       Z"d„ Z#d „ Z$d!„ Z%d'd"„Z&d#„ Z'd$„ Z(y)(ÚBufferedFilezc
    Reusable base class to implement Python-style file buffering around a
    simpler stream.
    i    r   é   é   é   é   é    é@   é€   c                 óÄ   — d | _         d| _        | j                  | _        t	        «       | _        t        «       | _        d| _        d| _	        dx| _
        | _        d| _        y )Nr   F)ÚnewlinesÚ_flagsÚ_DEFAULT_BUFSIZEÚ_bufsizer   Ú_wbufferÚbytesÚ_rbufferÚ_at_trailing_crÚ_closedÚ_posÚ_realposÚ_size©Úselfs    úN/var/www/api.ozpay.ru/ozpay/venv/lib/python3.12/site-packages/paramiko/file.pyÚ__init__zBufferedFile.__init__3   sU   € ØˆŒØˆŒØ×-Ñ-ˆŒÜ›	ˆŒÜ›ˆŒØ$ˆÔØˆŒð %&Ð%ˆŒ	�D”Màˆ�
ó    c                 ó$   — | j                  «        y ©N)Úcloser!   s    r#   Ú__del__zBufferedFile.__del__B   s   € Ø�
‰
�r%   c                 ó4   — | j                   rt        d«      ‚| S )zý
        Returns an iterator that can be used to iterate over the lines in this
        file.  This iterator happens to return the file itself, since a file is
        its own iterator.

        :raises: ``ValueError`` -- if the file is closed.
        zI/O operation on closed file)r   Ú
ValueErrorr!   s    r#   Ú__iter__zBufferedFile.__iter__E   s   € ð �<Š<ÜÐ;Ó<Ð<Øˆr%   c                 ó2   — | j                  «        d| _        y)zN
        Close the file.  Future read and write operations will fail.
        TN)Úflushr   r!   s    r#   r(   zBufferedFile.closeQ   s   € ð 	�
‰
ŒØˆ�r%   c                 ót   — | j                  | j                  j                  «       «       t        «       | _        y)z{
        Write out any data in the write buffer.  This may do nothing if write
        buffering is not turned on.
        N)Ú
_write_allr   Úgetvaluer   r!   s    r#   r.   zBufferedFile.flushX   s)   € ð
 	�‰˜Ÿ™×.Ñ.Ó0Ô1Ü›	ˆŒØr%   c                 ó6   — | j                  «       }|st        ‚|S )a�  
        Returns the next line from the input, or raises ``StopIteration``
        when EOF is hit.  Unlike python file objects, it's okay to mix
        calls to `.next` and `.readline`.

        :raises: ``StopIteration`` -- when the end of the file is reached.

        :returns:
            a line (`str`, or `bytes` if the file was opened in binary mode)
            read from the file.
        )ÚreadlineÚStopIteration)r"   Úlines     r#   Ú__next__zBufferedFile.__next__a   s   € ð �}‰}‹ˆÙÜÐØˆr%   c                 óN   — | j                   | j                  z  | j                  k(  S )z±
        Check if the file can be read from.

        :returns:
            `True` if the file can be read from. If `False`, `read` will raise
            an exception.
        )r   Ú	FLAG_READr!   s    r#   ÚreadablezBufferedFile.readabler   s    € ð —‘˜dŸn™nÑ,°·±Ñ?Ð?r%   c                 óN   — | j                   | j                  z  | j                  k(  S )z´
        Check if the file can be written to.

        :returns:
            `True` if the file can be written to. If `False`, `write` will
            raise an exception.
        )r   Ú
FLAG_WRITEr!   s    r#   ÚwritablezBufferedFile.writable|   s    € ð —‘˜dŸo™oÑ-°$·/±/ÑAÐAr%   c                  ó   — y)z½
        Check if the file supports random access.

        :returns:
            `True` if the file supports random access. If `False`, `seek` will
            raise an exception.
        F© r!   s    r#   ÚseekablezBufferedFile.seekable†   s   € ð r%   c                 óh   — | j                  t        |«      «      }||dt        |«       t        |«      S )z°
        Read up to ``len(buff)`` bytes into ``bytearray`` *buff* and return the
        number of bytes read.

        :returns:
            The number of bytes read.
        N)ÚreadÚlen)r"   ÚbuffÚdatas      r#   ÚreadintozBufferedFile.readinto�   s0   € ð �y‰yœ˜T›Ó#ˆØ ˆˆ[Œs�4‹yÐÜ�4‹yÐr%   Nc                 ó6  — | j                   rt        d«      ‚| j                  | j                  z  st        d«      ‚|�|dk  rÉt	        | j
                  «      }t        «       | _        | xj                  t        |«      z  c_        	 	 | j                  | j                  «      }|�t        |«      dk(  r	 t        |«      S |j                  |«       | xj                  t        |«      z  c_        | xj                  t        |«      z  c_        Œ†|t        | j
                  «      k  rC| j
                  d| }| j
                  |d | _        | xj                  t        |«      z  c_        |S t        | j
                  «      |k  r¶|t        | j
                  «      z
  }| j                  | j                  z  rt        | j                   |«      }	 | j                  |«      }|�t        |«      dk(  rnL| xj
                  |z  c_        | xj                  t        |«      z  c_        t        | j
                  «      |k  rŒ¶| j
                  d| }| j
                  |d | _        | xj                  t        |«      z  c_        |S # t        $ r d}Y �Œäw xY w# t        $ r d}Y Œ¿w xY w)a™  
        Read at most ``size`` bytes from the file (less if we hit the end of
        the file first).  If the ``size`` argument is negative or omitted,
        read all the remaining data in the file.

        .. note::
            ``'b'`` mode flag is ignored (``self.FLAG_BINARY`` in
            ``self._flags``), because SSH treats all files as binary, since we
            have no idea what encoding the file is in, or even if the file is
            text data.

        :param int size: maximum number of bytes to read
        :returns:
            data read from the file (as bytes), or an empty string if EOF was
            encountered immediately
        úFile is closedzFile is not open for readingNr   )r   ÚIOErrorr   r8   Ú	bytearrayr   r   r   rB   Ú_readr   ÚEOFErrorÚextendr   ÚFLAG_BUFFEREDÚmaxr   )r"   ÚsizeÚresultÚnew_dataÚ	read_sizes        r#   rA   zBufferedFile.readœ   s0  € ð" �<Š<ÜÐ*Ó+Ð+Ø—‘˜dŸn™nÒ,ÜÐ8Ó9Ð9ØˆL˜d Qšhä˜tŸ}™}Ó-ˆFÜ!›GˆDŒMØ�IŠIœ˜V›Ñ$�IØð$Ø#Ÿz™z¨$×*?Ñ*?Ó@�Hð Ð$¬#¨h«-¸1Ò*<Øô ˜“=Ð ð —‘˜hÔ'Ø—’¤ X£Ñ.•Ø—	’	œS ›]Ñ*•	ð ð ”3�t—}‘}Ó%Ò%Ø—]‘] 5 DÐ)ˆFØ ŸM™M¨$¨%Ð0ˆDŒMØ�IŠIœ˜V›Ñ$�IØˆMÜ�$—-‘-Ó  4Ò'Øœs 4§=¡=Ó1Ñ1ˆIØ�{‰{˜T×/Ñ/Ò/Ü §¡¨yÓ9�	ð ØŸ:™: iÓ0�ð Ð ¤c¨(£m°qÒ&8ØØ�MŠM˜XÑ%�MØ�MŠMœS ›]Ñ*�Mô �$—-‘-Ó  4Ó'ð —‘˜u Ð%ˆØŸ™ d eÐ,ˆŒØ�	Š	”S˜“[Ñ �	Øˆøô9  ò $Ø#“Hð$ûô& ò  Ø’ð ús$   ÂI8 ÇJ
 É8JÊJÊ
JÊJc                 ó²  — | j                   rt        d«      ‚| j                  | j                  z  st        d«      ‚| j                  }d}	 | j
                  rj| j                  | j                  z  rQt        |«      dkD  rC|d   t        k(  r|dd }| j                  t        «       n| j                  t        «       d| _        |�4|dk\  r/t        |«      |k\  r||d | _        |d| }d}nß|t        |«      z
  }n| j                  }t        |v s!| j                  | j                  z  r	t        |v rnš	 | j                  |«      }|�t        |«      dk(  rSt!        «       | _        | xj"                  t        |«      z  c_        | j                  | j$                  z  r|S t'        |«      S ||z  }| xj(                  t        |«      z  c_        �Œ||j+                  t        «      }| j                  | j                  z  r&|j+                  t        «      }|dk\  r||k  s|dk  r|}|dk(  rD| xj"                  t        |«      z  c_        | j                  | j$                  z  r|S t'        |«      S |dz   }||   t,        k(  r|t        |«      k  r||   t        k(  r|dz  }|r||d | j                  z   | _        n
||d | _        ||| }	|d| t        z   }t        | j                  «      dk(  r|	t        k(  rd| _        n| j                  |	«       | xj"                  t        |«      z  c_        | j                  | j$                  z  r|S t'        |«      S # t        $ r d}Y �Œw xY w)	aÍ  
        Read one entire line from the file.  A trailing newline character is
        kept in the string (but may be absent when a file ends with an
        incomplete line).  If the size argument is present and non-negative, it
        is a maximum byte count (including the trailing newline) and an
        incomplete line may be returned.  An empty string is returned only when
        EOF is encountered immediately.

        .. note::
            Unlike stdio's ``fgets``, the returned string contains null
            characters (``'\0'``) if they occurred in the input.

        :param int size: maximum length of returned string.
        :returns:
            next line of the file, or an empty string if the end of the
            file has been reached.

            If the file was opened in binary (``'b'``) mode: bytes are returned
            Else: the encoding of the file is assumed to be UTF-8 and character
            strings (`str`) are returned
        rG   zFile not open for readingFTr   r   Néÿÿÿÿ)r   rH   r   r8   r   r   ÚFLAG_UNIVERSAL_NEWLINErB   r   Ú_record_newliner   r   r   r   rJ   rK   r   r   ÚFLAG_BINARYr
   r   Úfindr   )
r"   rO   r5   Ú	truncatedÚnrQ   ÚposÚrposÚxposÚlfs
             r#   r3   zBufferedFile.readline×   s  € ð. �<Š<ÜÐ*Ó+Ð+Ø—‘˜dŸn™nÒ,ÜÐ5Ó6Ð6Ø�}‰}ˆØˆ	Øà×$Ò$Ø—K‘K $×"=Ñ"=Ò=Ü˜“I ’Mð ˜‘7Ô1Ò1Ø  ˜8�DØ×(Ñ(¬Õ.à×(Ñ(¬Ô1Ø',�Ô$ð Ð  t¨q¢yÜ�t“9 Ò$à$(¨¨ K�D”MØ  ˜;�DØ $�IØØœ3˜t›9Ñ$‘à—M‘M�Ü Ñ$Ø—‘˜d×9Ñ9Ò9¼gÈ¹oàð ØŸ:™: a›=�ð Ð ¤c¨(£m°qÒ&8Ü %£�”Ø—	’	œS ›YÑ&•	Ø#Ÿ{™{¨T×-=Ñ-=Ò=�tÐJÄ1ÀTÃ7ÐJØ�HÑˆDØ�MŠMœS ›]Ñ*�MñO ðR �i‰iœÓ&ˆØ�;‰;˜×4Ñ4Ò4Ø—9‘9œWÓ%ˆDØ˜’	  s¢
¨c°AªgØ�Ø�"Š9à�IŠIœ˜T›Ñ"�IØŸ;™;¨×)9Ñ)9Ò9�4ÐF¼qÀ»wÐFØ�Q‰wˆà�‰IœÒ&Ø”s˜4“yÒ Ø�T‘
Ô1Ò1à�A‰IˆDñ Ø   ˜K¨$¯-©-Ñ7ˆD�Mà   ˜KˆDŒMà�#�dˆ^ˆØ�D�SˆzœMÑ)ˆÜ�—‘Ó !Ò#¨"´ª-ð $(ˆDÕ à× Ñ  Ô$Ø�	Š	”S˜“YÑ�	Ø—{‘{ T×%5Ñ%5Ò5ˆtÐB¼1¸T»7ÐBøôU ò  Ø“ð ús   Ä.M ÍMÍMc                 ó¢   — g }d}	 | j                  «       }t        |«      dk(  r	 |S |j                  |«       |t        |«      z  }|�||k\  r	 |S ŒK)a®  
        Read all remaining lines using `readline` and return them as a list.
        If the optional ``sizehint`` argument is present, instead of reading up
        to EOF, whole lines totalling approximately sizehint bytes (possibly
        after rounding up to an internal buffer size) are read.

        :param int sizehint: desired maximum number of bytes to read.
        :returns: list of lines read from the file.
        r   )r3   rB   Úappend)r"   ÚsizehintÚlinesÚ
byte_countr5   s        r#   Ú	readlineszBufferedFile.readlines@  sg   € ð ˆØˆ
ØØ—=‘=“?ˆDÜ�4‹y˜AŠ~Øð
 ˆð	 �L‰L˜ÔØœ#˜d›)Ñ#ˆJØÐ$¨:¸Ò+AØØˆð r%   c                 ó   — t        d«      ‚)a¬  
        Set the file's current position, like stdio's ``fseek``.  Not all file
        objects support seeking.

        .. note::
            If a file is opened in append mode (``'a'`` or ``'a+'``), any seek
            operations will be undone at the next write (as the file position
            will move back to the end of the file).

        :param int offset:
            position to move to within the file, relative to ``whence``.
        :param int whence:
            type of movement: 0 = absolute; 1 = relative to the current
            position; 2 = relative to the end of the file.

        :raises: ``IOError`` -- if the file doesn't support random access.
        zFile does not support seeking.©rH   )r"   ÚoffsetÚwhences      r#   ÚseekzBufferedFile.seekV  s   € ô$ Ð6Ó7Ð7r%   c                 ó   — | j                   S )zù
        Return the file's current position.  This may not be accurate or
        useful if the underlying file doesn't support random access, or was
        opened in append mode.

        :returns: file position (`number <int>` of bytes).
        )r   r!   s    r#   ÚtellzBufferedFile.tellj  s   € ð �y‰yÐr%   c                 ó  — t        |t        «      r|j                  d«      }| j                  rt	        d«      ‚| j
                  | j                  z  st	        d«      ‚| j
                  | j                  z  s| j                  |«       y| j                  j                  |«       | j
                  | j                  z  r–|j                  t        «      }|dk\  r{| j                  j                  «       }|t        |«      t        |«      z
  z  }| j                  |d|dz    «       t!        «       | _	        | j                  j                  ||dz   d «       y| j                  j#                  «       | j$                  k\  r| j'                  «        y)a8  
        Write data to the file.  If write buffering is on (``bufsize`` was
        specified and non-zero), some or all of the data may not actually be
        written yet.  (Use `flush` or `close` to force buffered data to be
        written out.)

        :param data: ``str``/``bytes`` data to write
        zutf-8rG   zFile not open for writingNr   r   )Ú
isinstanceÚstrÚencoder   rH   r   r;   rM   r0   r   ÚwriteÚFLAG_LINE_BUFFEREDÚrfindr   r1   rB   r   rk   r   r.   )r"   rD   Úlast_newline_posÚwbufs       r#   rp   zBufferedFile.writet  s>  € ô �dœCÔ à—;‘;˜wÓ'ˆDØ�<Š<ÜÐ*Ó+Ð+Ø—‘˜dŸo™oÒ-ÜÐ5Ó6Ð6Ø—‘˜d×0Ñ0Ò0Ø�O‰O˜DÔ!ØØ�‰×Ñ˜DÔ!Ø�;‰;˜×0Ñ0Ò0à#Ÿz™z¬-Ó8ÐØ 1Ò$Ø—}‘}×-Ñ-Ó/�Ø ¤C¨£I´°D³	Ñ$9Ñ9Ð Ø—‘ Ð%;Ð'7¸!Ñ';Ð <Ô=Ü '£	�”Ø—‘×#Ñ# DÐ)9¸AÑ)=Ð)?Ð$@ÔAØð �=‰=×ÑÓ 4§=¡=Ò0Ø�J‰JŒLØr%   c                 ó4   — |D ]  }| j                  |«       Œ y)a?  
        Write a sequence of strings to the file.  The sequence can be any
        iterable object producing strings, typically a list of strings.  (The
        name is intended to match `readlines`; `writelines` does not add line
        separators.)

        :param sequence: an iterable sequence of strings.
        N)rp   )r"   Úsequencer5   s      r#   Ú
writelineszBufferedFile.writelines˜  s"   € ð ò 	ˆDØ�J‰J�tÕð	àr%   c                 ó   — | S )z
        Identical to ``iter(f)``.  This is a deprecated file interface that
        predates Python iterator support.
        r>   r!   s    r#   Ú
xreadlineszBufferedFile.xreadlines¥  s	   € ð
 ˆr%   c                 ó   — | j                   S r'   )r   r!   s    r#   ÚclosedzBufferedFile.closed¬  s   € à�|‰|Ðr%   c                 ó   — t        «       ‚)zˆ
        (subclass override)
        Read data from the stream.  Return ``None`` or raise ``EOFError`` to
        indicate EOF.
        )rK   )r"   rO   s     r#   rJ   zBufferedFile._read²  s   € ô ‹jÐr%   c                 ó   — t        d«      ‚)zI
        (subclass override)
        Write data into the stream.
        zwrite not implementedrf   )r"   rD   s     r#   Ú_writezBufferedFile._writeº  s   € ô
 Ð-Ó.Ð.r%   c                  ó   — y)ai  
        (subclass override)
        Return the size of the file.  This is called from within `_set_mode`
        if the file is opened in append mode, so the file position can be
        tracked and `seek` and `tell` will work correctly.  If the file is
        a stream that can't be randomly accessed, you don't need to override
        this method,
        r   r>   r!   s    r#   Ú	_get_sizezBufferedFile._get_sizeÁ  s   € ð r%   c                 ó†  — | j                   | _        |dk  rd}|dk(  r-| xj                  | j                  | j                  z  z  c_        n~|dkD  rG|| _        | xj                  | j                  z  c_        | xj                  | j                   z  c_        n2|dk(  r-| xj                  | j                  | j                  z   z  c_        d|v sd|v r| xj                  | j
                  z  c_        d|v sd|v r| xj                  | j                  z  c_        d|v rY| xj                  | j                  | j                  z  z  c_        | j                  «       | _	        | j                  x| _
        | _        d|v r| xj                  | j                  z  c_        d|v r'| xj                  | j                  z  c_        d	| _        y	y	)
zM
        Subclasses call this method to initialize the BufferedFile.
        r   r   Úrú+ÚwÚaÚbÚUN)r   r   r   rM   rq   r8   r;   ÚFLAG_APPENDr€   r    r   r   rW   rU   r   )r"   ÚmodeÚbufsizes      r#   Ú	_set_modezBufferedFile._set_modeÎ  so  € ð
 ×-Ñ-ˆŒØ�QŠ;ð ˆGØ�aŠ<ð �KŠK˜4×-Ñ-°×0GÑ0GÑGÑGŽKØ�qŠ[Ø#ˆDŒMØ�KŠK˜4×-Ñ-Ñ-�KØ�KŠK˜D×3Ñ3Ð3Ñ3ŽKØ˜Š\à�KŠK˜T×/Ñ/°$×2IÑ2IÑIÐJÑJ�Kà�4‰K˜S D™[Ø�KŠK˜4Ÿ>™>Ñ)�KØ�4‰K˜S D™[Ø�KŠK˜4Ÿ?™?Ñ*�KØ�$‰;Ø�KŠK˜4Ÿ?™?¨T×-=Ñ-=Ñ=Ñ=�KØŸ™Ó)ˆDŒJØ(,¯
©
Ð2ˆDŒI˜œØ�$‰;Ø�KŠK˜4×+Ñ+Ñ+�KØ�$‰;Ø�KŠK˜4×6Ñ6Ñ6�Kð !ˆD�Mð r%   c                 ób  — t        |«      }t        |«      dkD  r–| j                  |«      }||d  }| j                  | j                  z  r.| xj
                  |z  c_        | j
                  x| _        | _        n*| xj                  |z  c_        | xj                  |z  c_        t        |«      dkD  rŒ–y )Nr   )Ú
memoryviewrB   r~   r   rˆ   r    r   r   )r"   Úraw_datarD   Úcounts       r#   r0   zBufferedFile._write_allö  s’   € ô ˜(Ó#ˆÜ�$‹i˜!ŠmØ—K‘K Ó%ˆEØ˜˜�<ˆDØ�{‰{˜T×-Ñ-Ò-Ø—
’
˜eÑ#•
Ø,0¯J©JÐ6�”	˜D�Mà—	’	˜UÑ"•	Ø—’ Ñ&•ô �$‹i˜!‹mð r%   c                 ó$  — | j                   | j                  z  sy | j                  €|| _        y | j                  |k7  r.t        | j                  t        «      r| j                  |f| _        y || j                  vr| xj                  |fz  c_        y y r'   )r   rU   r   rm   r   )r"   Únewlines     r#   rV   zBufferedFile._record_newline  st   € ð —‘˜d×9Ñ9Ò9ØØ�=‰=Ð Ø#ˆD�MØ�]‰]˜gÒ%¬*°T·]±]ÄEÔ*JØ!Ÿ]™]¨GÐ4ˆD�MØ˜DŸM™MÑ)Ø�MŠM˜g˜ZÑ'ŽMð *r%   r'   )r   )r‚   rT   ))Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   ÚSEEK_SETÚSEEK_CURÚSEEK_ENDr8   r;   rˆ   rW   rM   rq   rU   r$   r)   r,   r(   r.   r6   r9   r<   r?   rE   rA   r3   rd   ri   rk   rp   rw   ry   Úpropertyr{   rJ   r~   r€   r‹   r0   rV   r>   r%   r#   r   r      s×   „ ñð
 Ðà€HØ€HØ€Hà€IØ€JØ€KØ€KØ€MØÐØ!Ðòòò
òòòò"@òBòò
ó9óvgCóRó,8ò(ò"òHòð ñó ðò
ò/ò	ó&!òPó(r%   r   N)Úior   Úparamiko.commonr   r   r   r   r   Úparamiko.utilr	   r
   r   r>   r%   r#   ú<module>r�      s(   ðõ$ ÷õ ÷ 3ôq(Ð(õ q(r%   