Server : LiteSpeed
System : Linux server51.dnsbootclub.com 4.18.0-553.62.1.lve.el8.x86_64 #1 SMP Mon Jul 21 17:50:35 UTC 2025 x86_64
User : nandedex ( 1060)
PHP Version : 8.1.33
Disable Function : NONE
Directory :  /opt/cppython/lib/python3.8/site-packages/paramiko/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]


Current File : //opt/cppython/lib/python3.8/site-packages/paramiko/__pycache__/file.cpython-38.pyc
U

P��gwJ�@sLddlmZddlmZmZmZmZmZddlm	Z	m
Z
Gdd�de	�ZdS)�)�BytesIO)�linefeed_byte_value�crlf�cr_byte�
linefeed_byte�
cr_byte_value)�ClosingContextManager�uc@seZdZdZdZdZdZdZdZdZ	dZ
dZdZd	Z
d
Zdd�Zd
d�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zd@d d!�ZdAd"d#�ZdBd$d%�ZdCd&d'�Zd(d)�Zd*d+�Zd,d-�Zd.d/�Z e!d0d1��Z"d2d3�Z#d4d5�Z$d6d7�Z%dDd:d;�Z&d<d=�Z'd>d?�Z(dS)E�BufferedFilezc
    Reusable base class to implement Python-style file buffering around a
    simpler stream.
    i r����� �@�cCsFd|_d|_|j|_t�|_t�|_d|_d|_	d|_
|_d|_dS)NrF)
�newlines�_flags�_DEFAULT_BUFSIZE�_bufsizer�_wbuffer�bytes�_rbuffer�_at_trailing_cr�_closed�_pos�_realpos�_size��self�r �:/opt/cppython/lib/python3.8/site-packages/paramiko/file.py�__init__3szBufferedFile.__init__cCs|��dS�N)�closerr r r!�__del__BszBufferedFile.__del__cCs|jrtd��|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.
        zI/O operation on closed file)r�
ValueErrorrr r r!�__iter__EszBufferedFile.__iter__cCs|��d|_dS)zN
        Close the file.  Future read and write operations will fail.
        TN)�flushrrr r r!r$QszBufferedFile.closecCs|�|j���t�|_dS)z{
        Write out any data in the write buffer.  This may do nothing if write
        buffering is not turned on.
        N)�
_write_allr�getvaluerrr r r!r(XszBufferedFile.flushcCs|��}|st�|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�liner r r!�__next__aszBufferedFile.__next__cCs|j|j@|jkS)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_READrr r r!�readablerszBufferedFile.readablecCs|j|j@|jkS)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_WRITErr r r!�writable|szBufferedFile.writablecCsdS)z�
        Check if the file supports random access.

        :returns:
            `True` if the file supports random access. If `False`, `seek` will
            raise an exception.
        Fr rr r r!�seekable�szBufferedFile.seekablecCs&|�t|��}||dt|��<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)rZbuff�datar r r!�readinto�szBufferedFile.readintoNcCs�|jrtd��|j|j@s"td��|dks2|dkr�t|j�}t�|_|jt|�7_z|�	|j
�}Wntk
r~d}YnX|dks�t|�dkr�q�|�|�|j
t|�7_
|jt|�7_qVt|�S|t|j�k�r|jd|�}|j|d�|_|jt|�7_|St|j�|k�r�|t|j�}|j|j@�rJt|j|�}z|�	|�}Wntk
�rrd}YnX|dk�s�t|�dk�r��q�|j|7_|j
t|�7_
�q|jd|�}|j|d�|_|jt|�7_|S)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 closedzFile is not open for readingNr)r�IOErrorrr/�	bytearrayrrrr5�_readr�EOFError�extendr�
FLAG_BUFFERED�maxr)r�size�result�new_data�	read_sizer r r!r4�sN



zBufferedFile.readc
Cs�|jrtd��|j|j@s"td��|j}d}|jr~|j|j@r~t|�dkr~|dtkrn|dd�}|�	t
�n
|�	t�d|_|dk	r�|dkr�t|�|kr�||d�|_|d|�}d}�q�|t|�}n|j}t
|ks�|j|j@r�t|kr�q�z|�|�}Wntk
�rd}YnX|dk�s2t|�dk�rft�|_|jt|�7_|j|j@�r^|St|�S||7}|jt|�7_q,|�t
�}|j|j@�r�|�t�}|dk�r�||k�s�|dk�r�|}|dk�r�|jt|�7_|j|j@�r�|St|�S|d}||tk�r6|t|�k�r6||tk�r6|d7}|�rR||d�|j|_n||d�|_|||�}	|d|�t
}t|j�dk�r�|	tk�r�d|_n
|�	|	�|jt|�7_|j|j@�r�|St|�S)	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
        r8zFile not open for readingFrrNT���)rr9rr/rr�FLAG_UNIVERSAL_NEWLINEr5r�_record_newlinerrrrr;r<rr�FLAG_BINARYr	r�findr)
rr@r-�	truncated�nrB�pos�rposZxpos�lfr r r!r+�s��
�
�

��




�
�
�
zBufferedFile.readlinecCsLg}d}|��}t|�dkrqH|�|�|t|�7}|dk	r||krqHq|S)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.
        rN)r+r5�append)r�sizehint�linesZ
byte_countr-r r r!�	readlines@s

zBufferedFile.readlinescCstd��dS)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.
        zFile does not support seeking.N�r9)r�offset�whencer r r!�seekVszBufferedFile.seekcCs|jS)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).
        )rrr r r!�telljszBufferedFile.tellcCs�t|t�r|�d�}|jr"td��|j|j@s6td��|j|j@sP|�|�dS|j	�
|�|j|j@r�|�t
�}|dkr�|j	��}|t|�t|�7}|�|d|d��t�|_	|j	�
||dd��dS|j	��|jkr�|��dS)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
        zutf-8r8zFile not open for writingNrr)�
isinstance�str�encoderr9rr1r>r)r�write�FLAG_LINE_BUFFERED�rfindrr*r5rrVrr()rr6Zlast_newline_posZwbufr r r!rZts,	




zBufferedFile.writecCs|D]}|�|�qdS)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)rZ)r�sequencer-r r r!�
writelines�s	zBufferedFile.writelinescCs|S)z
        Identical to ``iter(f)``.  This is a deprecated file interface that
        predates Python iterator support.
        r rr r r!�
xreadlines�szBufferedFile.xreadlinescCs|jSr#)rrr r r!�closed�szBufferedFile.closedcCs
t��dS)z�
        (subclass override)
        Read data from the stream.  Return ``None`` or raise ``EOFError`` to
        indicate EOF.
        N)r<)rr@r r r!r;�szBufferedFile._readcCstd��dS)zI
        (subclass override)
        Write data into the stream.
        zwrite not implementedNrR)rr6r r r!�_write�szBufferedFile._writecCsdS)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,
        rr rr r r!�	_get_size�s	zBufferedFile._get_size�rrDcCs:|j|_|dkrd}|dkr4|j|j|jBO_nR|dkrf||_|j|jO_|j|jM_n |dkr�|j|j|jBM_d|ks�d|kr�|j|jO_d|ks�d|kr�|j|jO_d|kr�|j|j|jBO_|��|_	|j	|_
|_d|k�r|j|jO_d|k�r6|j|j
O_d	|_d	S)
zM
        Subclasses call this method to initialize the BufferedFile.
        rrrc�+�w�a�b�UN)rrrr>r[r/r1�FLAG_APPENDrbrrrrGrEr)r�mode�bufsizer r r!�	_set_mode�s0


zBufferedFile._set_modecCsvt|�}t|�dkrr|�|�}||d�}|j|j@rT|j|7_|j|_|_q|j|7_|j|7_qdS)Nr)�
memoryviewr5rarrirrr)r�raw_datar6�countr r r!r)�s
zBufferedFile._write_allcCsd|j|j@sdS|jdkr"||_n>|j|krFt|jt�rF|j|f|_n||jkr`|j|f7_dSr#)rrErrWr)r�newliner r r!rFs

zBufferedFile._record_newline)N)N)N)r)rcrD))�__name__�
__module__�__qualname__�__doc__r�SEEK_SET�SEEK_CUR�SEEK_ENDr/r1rirGr>r[rEr"r%r'r$r(r.r0r2r3r7r4r+rQrUrVrZr^r_�propertyr`r;rarbrlr)rFr r r r!r
sL	



;
i


$


(r
N)�iorZparamiko.commonrrrrrZ
paramiko.utilrr	r
r r r r!�<module>s

F1le Man4ger