HEX
Server: LiteSpeed
System: Linux server.nevid-deploma.com 4.18.0-553.111.1.lve.el8.x86_64 #1 SMP Fri Mar 13 13:42:17 UTC 2026 x86_64
User: smilepac (1037)
PHP: 8.1.34
Disabled: NONE
Upload Files
File: //opt/cppython/lib/python3.8/site-packages/pyasn1/codec/__pycache__/streaming.cpython-38.pyc
U

ID�g��@sbddlZddlZddlmZddlmZGdd�dej�Zdd�Zdd	�Z	ddd�Z
dd
d�ZdS)�N)�error)�univc@sdeZdZdZdd�Zdd�Zdd�Zdejfd	d
�Z	ddd�Z
ed
d��Zej
dd��Zdd�ZdS)�CachingStreamWrapperaWrapper around non-seekable streams.

    Note that the implementation is tied to the decoder,
    not checking for dangerous arguments for the sake
    of performance.

    The read bytes are kept in an internal cache until
    setting _markedPosition which may reset the cache.
    cCs||_t��|_d|_dS�Nr)�_raw�io�BytesIO�_cache�_markedPosition)�self�raw�r
�C/opt/cppython/lib/python3.8/site-packages/pyasn1/codec/streaming.py�__init__s
zCachingStreamWrapper.__init__cCs$|�|�}|j�t|�tj�|S�N)�readr	�seek�len�os�SEEK_CUR)r�n�resultr
r
r�peeks
zCachingStreamWrapper.peekcCsdS)NTr
�rr
r
r�seekable!szCachingStreamWrapper.seekable���cCs|j�||�Sr)r	r)rr�whencer
r
rr$szCachingStreamWrapper.seekcCsH|j�|�}|dkr(|t|�8}|s(|S|j�|�}|j�|�||S)Nr)r	rrr�write)rrZread_from_cacheZ
read_from_rawr
r
rr(szCachingStreamWrapper.readcCs|jS)aPosition where the currently processed element starts.

        This is used for back-tracking in SingleItemDecoder.__call__
        and (indefLen)ValueDecoder and should not be used for other purposes.
        The client is not supposed to ever seek before this position.
        )r
rr
r
r�markedPosition5sz#CachingStreamWrapper.markedPositioncCs2||_|j��tjkr.t�|j���|_d|_dSr)r
r	�tellr�DEFAULT_BUFFER_SIZErr)r�valuer
r
rr?scCs
|j��Sr)r	rrr
r
rrMszCachingStreamWrapper.tellN)r)�__name__�
__module__�__qualname__�__doc__rrrr�SEEK_SETrr�propertyr�setterrr
r
r
rr
s	


	

rcCs�t|tj�r|St|t�r$t�|�St|tj�r>t�|���Sz|��rN|WSt|�WSWn*t	k
r�t
�d|jj
d��YnXdS)aiConvert object to seekable byte-stream.

    Parameters
    ----------
    substrate: :py:class:`bytes` or :py:class:`io.IOBase` or :py:class:`univ.OctetString`

    Returns
    -------
    : :py:class:`io.IOBase`

    Raises
    ------
    : :py:class:`~pyasn1.error.PyAsn1Error`
        If the supplied substrate cannot be converted to a seekable stream.
    zCannot convert z to a seekable bit stream.N)�
isinstancerr�bytesrZOctetStringZasOctetsrr�AttributeErrorrZUnsupportedSubstrateError�	__class__r")�	substrater
r
r�asSeekableStreamQs 


��r.ccszt|tj�rD|��}|�dtj�|��|k}|�|tj�|Vn2|�d�}|dkr\dV|rn|�dtj	�|VdS)aCheck whether we have reached the end of a stream.

    Although it is more effective to read and catch exceptions, this
    function

    Parameters
    ----------
    substrate: :py:class:`IOBase`
        Stream to check

    Returns
    -------
    : :py:class:`bool`
    r�Nr)
r)rrrrr�SEEK_ENDr&rr)r-�cpr�receivedr
r
r�
isEndOfStreamvs
r3rc	csrt|d�r>|�|�}|dkr"dVt|�|kr6dVq"|Vn0|��}zt||�D]
}|VqRW5|�|�XdS)a?Peek into stream.

    Parameters
    ----------
    substrate: :py:class:`IOBase`
        Stream to read from.

    size: :py:class:`int`
        How many bytes to peek (-1 = all available)

    Returns
    -------
    : :py:class:`bytes` or :py:class:`str`
        The return type depends on Python major version
    rN)�hasattrrrrr�readFromStream)r-�sizer2�current_position�chunkr
r
r�peekIntoStream�s

r9ccsz|�|�}|dkr"tj|d�Vq|s<|dkr<tj|d��qt|�|krp|�t|�tj�tj|d�Vqqpq|VdS)aRead from the stream.

    Parameters
    ----------
    substrate: :py:class:`IOBase`
        Stream to read from.

    Keyword parameters
    ------------------
    size: :py:class:`int`
        How many bytes to read (-1 = all available)

    context: :py:class:`dict`
        Opaque caller context will be attached to exception objects created
        by this function.

    Yields
    ------
    : :py:class:`bytes` or :py:class:`str` or :py:class:`SubstrateUnderrunError`
        Read data or :py:class:`~pyasn1.error.SubstrateUnderrunError`
        object if no `size` bytes is readily available in the stream. The
        data type depends on Python major version

    Raises
    ------
    : :py:class:`~pyasn1.error.EndOfStreamError`
        Input stream is exhausted
    N)�contextr)rrZSubstrateUnderrunErrorZEndOfStreamErrorrrrr)r-r6r:r2r
r
rr5�s
r5)r)rN)rrZpyasn1rZpyasn1.typer�IOBaserr.r3r9r5r
r
r
r�<module>sD%!
$