%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/paramiko/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/paramiko/__pycache__/buffered_pipe.cpython-312.pyc

�

�ec,��\�dZddlZddlZddlZddlmZmZGd�de�ZGd�de	�Z
y)z�
Attempt to generalize the "feeder" part of a `.Channel`: an object which can be
read from and closed, but is reading from a buffer fed by another thread.  The
read operations are blocking and can have a timeout set.
�N)�PY2�bc��eZdZdZy)�PipeTimeoutzP
    Indicates that a timeout was reached on a read from a `.BufferedPipe`.
    N)�__name__�
__module__�__qualname__�__doc__���8/usr/lib/python3/dist-packages/paramiko/buffered_pipe.pyrrs���	rrc�d�eZdZdZd�Zerd�Zdd�Znd�Zdd�Zd�Zd	�Z	d
�Z
dd�Zd�Zd
�Z
d�Zy)�BufferedPipez�
    A buffer that obeys normal read (with timeout) & close semantics for a
    file or socket, but is fed data from another thread.  This is used by
    `.Channel`.
    c���tj�|_tj|j�|_d|_t
jd�|_d|_y)N�BF)	�	threading�Lock�_lock�	Condition�_cv�_event�array�_buffer�_closed��selfs r
�__init__zBufferedPipe.__init__.sD���^�^�%��
��&�&�t�z�z�2�������{�{�3�'�����rc�:�|jj|�y�N)r�
fromstring�r�datas  r
�_buffer_frombyteszBufferedPipe._buffer_frombytes7s���L�L�#�#�D�)rNc�<�|jd|j�Sr)r�tostring�r�limits  r
�_buffer_tobyteszBufferedPipe._buffer_tobytes:s���<�<���'�0�0�2�2rc�:�|jj|�yr)r�	frombytesr!s  r
r#zBufferedPipe._buffer_frombytes?s���L�L�"�"�4�(rc�<�|jd|j�Sr)r�tobytesr&s  r
r(zBufferedPipe._buffer_tobytesBs���<�<���'�/�/�1�1rc�D�|jj�	||_|jst	|j
�dkDr|j
�n|j�|jj�y#|jj�wxYw)a
        Set an event on this buffer.  When data is ready to be read (or the
        buffer has been closed), the event will be set.  When no data is
        ready, the event will be cleared.

        :param threading.Event event: the event to set/clear
        rN)	r�acquirerr�lenr�set�clear�release)r�events  r
�	set_eventzBufferedPipe.set_eventEsl��	
�
�
����	!��D�K��|�|�s�4�<�<�0�1�4��	�	�����
��J�J��� ��D�J�J��� �s�AB�Bc�`�|jj�	|j�|jj�|j	t|��|jj�|jj�y#|jj�wxYw)z�
        Feed new data into this pipe.  This method is assumed to be called
        from a separate thread, so synchronization is done.

        :param data: the data to add, as a ``str`` or ``bytes``
        N)	rr.rr0r#rr�
notify_allr2r!s  r
�feedzBufferedPipe.feed\st��	
�
�
����	!��{�{�&������!��"�"�1�T�7�+��H�H���!��J�J��� ��D�J�J��� �s�AB�B-c��|jj�	t|j�dk(r	|jj	�y	|jj	�y#|jj	�wxYw)ad
        Returns true if data is buffered and ready to be read from this
        feeder.  A ``False`` result does not mean that the feeder has closed;
        it means you may need to wait before more data arrives.

        :return:
            ``True`` if a `read` call would immediately return at least one
            byte; ``False`` otherwise.
        rFT�rr.r/rr2rs r
�
read_readyzBufferedPipe.read_readylse��	
�
�
����	!��4�<�<� �A�%��
�J�J��� ���J�J��� ��D�J�J��� �s�A,�,Bc��t�}|jj�	t|j�dk(r�|j
r||jj
�S|dk(r
t��t|j�dk(r�|j
stj�}|jj|�|�)|tj�|z
z}|dkr
t��t|j�dk(r
|j
s�t|j�|krR|j�}|jdd�=|j�G|j
s;|jj�n |j|�}|jd|�=|jj
�|S#|jj
�wxYw)a|
        Read data from the pipe.  The return value is a string representing
        the data received.  The maximum amount of data to be received at once
        is specified by ``nbytes``.  If a string of length zero is returned,
        the pipe has been closed.

        The optional ``timeout`` argument can be a nonnegative float expressing
        seconds, or ``None`` for no timeout.  If a float is given, a
        `.PipeTimeout` will be raised if the timeout period value has elapsed
        before any data arrives.

        :param int nbytes: maximum number of bytes to read
        :param float timeout:
            maximum seconds to wait (or ``None``, the default, to wait forever)
        :return: the read data, as a ``str`` or ``bytes``

        :raises:
            `.PipeTimeout` -- if a timeout was specified and no data was ready
            before that timeout
        rgN)�bytesrr.r/rrr2r�timer�waitr(rr1)r�nbytes�timeout�out�thens     r
�readzBufferedPipe.read~sj��*�g���
�
����	!��4�<�<� �A�%��<�<��0
�J�J��� �-�c�>�%�-�'��4�<�<�(�A�-�t�|�|��9�9�;�D��H�H�M�M�'�*��*��4�9�9�;��#5�5��"�c�>�"-�-�/�
�4�<�<�(�A�-�t�|�|��4�<�<� �F�*��*�*�,���L�L��O��K�K�+�T�\�\��K�K�%�%�'��*�*�6�2���L�L��&��)��J�J��� ��
��
�J�J��� �s�%F>�&B1F>�B
F>�>Gc�P�|jj�	|j�}|jdd�=|j�&|j
s|jj
�||jj�S#|jj�wxYw)z�
        Clear out the buffer and return all data that was in it.

        :return:
            any data that was in the buffer prior to clearing it out, as a
            `str`
        N)rr.r(rrrr1r2)rrAs  r
�emptyzBufferedPipe.empty�sv��	
�
�
����	!��&�&�(�C����Q�����'�������!�!�#���J�J��� ��D�J�J��� �s�AB	�	B%c�:�|jj�	d|_|jj	�|j
�|j
j
�|jj�y#|jj�wxYw)z�
        Close this pipe object.  Future calls to `read` after the buffer
        has been emptied will return immediately with an empty string.
        TN)rr.rrr6rr0r2rs r
�closezBufferedPipe.close�si��
	
�
�
����	!��D�L��H�H���!��{�{�&������!��J�J��� ��D�J�J��� �s�AA>�>Bc���|jj�	t|j�|jj	�S#|jj	�wxYw)zi
        Return the number of bytes buffered.

        :return: number (`int`) of bytes buffered
        r9rs r
�__len__zBufferedPipe.__len__�sF��	
�
�
����	!��t�|�|�$��J�J��� ��D�J�J��� �s�A�A'r)rrr	r
rrr#r(r4r7r:rCrErGrIrrr
rr'sI�����	*�	3�
	)�	2�!�.!� !�$4�l!�$!�
!rr)r
rrr=�paramiko.py3compatrr�IOErrorr�objectrrrr
�<module>rMs2��&�
���%�	�'�	�w!�6�w!r

Zerion Mini Shell 1.0