ȺhpddlZddlZddlmZddlmZGddejZdZdZ d d Z d d Z dS) N)error)univc~eZdZdZdZdZdZdejfdZ d dZ e dZ e j d Z d Zd S) 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. cR||_tj|_d|_dSNr)_rawioBytesIO_cache_markedPosition)selfraws v/builddir/build/BUILD/imunify360-venv-2.5.2/opt/imunify360/venv/lib/python3.11/site-packages/pyasn1/codec/streaming.py__init__zCachingStreamWrapper.__init__s$ jll  c||}|jt| tj|SN)readr seeklenosSEEK_CUR)rnresults rpeekzCachingStreamWrapper.peeks81 #f++r{333 rcdS)NTrs rseekablezCachingStreamWrapper.seekable!strc8|j||Sr)r r)rrwhences rrzCachingStreamWrapper.seek$s{6***rc|j|}|dkr|t|z}|s|S|j|}|j|||zS)Nr!)r rrr write)rrread_from_cache read_from_raws rrzCachingStreamWrapper.read(st+**1-- 77 _%% %A '&& q))  -(((..rc|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 rs rmarkedPositionz#CachingStreamWrapper.markedPosition5s ##rc||_|jtjkr9tj|j|_d|_dSdSr)r r tellr DEFAULT_BUFFER_SIZEr r)rvalues rr)z#CachingStreamWrapper.markedPosition?s_ % ;     6 6 6*T[%5%5%7%788DK#$D  7 6rc4|jSr)r r+rs rr+zCachingStreamWrapper.tellMs{!!!rNr!)__name__ __module__ __qualname____doc__rrr rSEEK_SETrrpropertyr)setterr+rrrrr s!!!   ++++ / / / /$$X$ % % %"""""rrct|tjr|St|trtj|St|tjr&tj|S |r|St|S#t$r%tj d|j j zdzwxYw)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.) isinstancer r bytesr OctetStringasOctetsr rAttributeErrorrUnsupportedSubstrateError __class__r0) substrates rasSeekableStreamr@Qs )RZ((0 Iu % %0z)$$$ It/ 0 00z),,../// *      3 ' 22 2 ***-  3 < < ( )** **sB,B,,/Cc#Kt|tjrr|}|dt j||k}||t j|VdS|d}|dV|r |dt j | 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` rNr!) r8r r r+rrSEEK_ENDr4rr)r?cprreceiveds r isEndOfStreamrFvs)RZ(( ^^  q"+&&&!!R'r2;''' >>!$$   EEE  , NN2r{ + + +lrr!c#xKt|drK||}|dVt||krdVt||k|VdS|} t ||D]}|V ||dS#||wxYw)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)hasattrrrr+readFromStreamr)r?sizerEcurrent_positionchunks rpeekIntoStreamrMs y&!!->>$''   EEE(mmd"" EEE(mmd""%>>++ -' 488     NN+ , , , , ,INN+ , , , ,s 3B""B9c#bK ||}|tj|Vnw|s|dkrtj|t ||krF|t | t jtj|Vnn|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 TN)contextr)rrSubstrateUnderrunErrorEndOfStreamErrorrrrr)r?rJrOrEs rrIrIs:>>$''  .w??? ? ? ? ? daii(999 9 ]]T ! ! NNCMM>2; 7 7 7.w??? ? ? ? ? !$ NNNNNrr/)r!N) r rpyasn1r pyasn1.typerIOBaserr@rFrMrIrrrrUs A"A"A"A"A"29A"A"A"H"*"*"*JB!-!-!-!-H//////r