Файловый менеджер - Редактировать - /opt/imh-python/lib/python3.9/site-packages/pyasn1/codec/__pycache__/streaming.cpython-39.pyc
Ðазад
a d�h� � @ sb d dl Z d dlZd dlmZ d dlmZ G dd� de j�Zdd� Zdd � Z ddd�Z dd d�ZdS )� N)�error)�univc @ sd e Zd ZdZdd� Zdd� Zdd� Zdejfd d �Z ddd�Z ed d� �Zej dd� �Zdd� ZdS )�CachingStreamWrappera Wrapper 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. c C s || _ t�� | _d| _d S �Nr )�_raw�io�BytesIO�_cache�_markedPosition)�self�raw� r ��/root/rpmbuild/BUILDROOT/imh-python39-modules-3.9.7-92.el8.x86_64/opt/imh-python/lib/python3.9/site-packages/pyasn1/codec/streaming.py�__init__ s zCachingStreamWrapper.__init__c C s$ | � |�}| j�t|� tj� |S �N)�readr �seek�len�os�SEEK_CUR)r �n�resultr r r �peek s zCachingStreamWrapper.peekc C s dS )NTr �r r r r �seekable! s zCachingStreamWrapper.seekable���c C s | j �||�S r )r r )r r �whencer r r r $ s zCachingStreamWrapper.seekc C sH | j �|�}|dkr(|t|�8 }|s(|S | j�|�}| j �|� || S )Nr )r r r r �write)r r Zread_from_cacheZ read_from_rawr r r r ( s zCachingStreamWrapper.readc C s | j S )a Position 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 r r r r �markedPosition5 s z#CachingStreamWrapper.markedPositionc C s2 || _ | j�� tjkr.t�| j�� �| _d| _ d S r )r r �tellr �DEFAULT_BUFFER_SIZEr r )r �valuer r r r ? s c C s | j �� S r )r r r r r r r M s zCachingStreamWrapper.tellN)r )�__name__� __module__�__qualname__�__doc__r r r r �SEEK_SETr r �propertyr �setterr r r r r r s r c C s� t | tj�r| S t | t�r$t�| �S t | tj�r>t�| �� �S z| �� rN| W S t| �W S W n( t y� t �d| jj d ��Y n0 dS )ai Convert 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)� isinstancer r �bytesr ZOctetStringZasOctetsr r �AttributeErrorr ZUnsupportedSubstrateError� __class__r"