O+ t G d de Z G d de Z G d de Z G d d ZdS ) c e Zd ZdS )LineBufferOverflowN__name__
__module____qualname__ Q/opt/imunify360/venv/lib/python3.11/site-packages/defence360agent/utils/buffer.pyr r Dr r c 4 e Zd ZdZdZd Zd Zd Zd Zd Z dS )
LineBufferz
Allows to accumulate data, and than iterate over it getting tokens
split by line breaks '
'. If at the end there is no line break,
the data will sit in the line buffer until more data with line
break comes in.
c d| _ d S N bufselfs r
__init__zLineBuffer.__init__
r c t | j t | z | j k r.d| _ t d | j | xj |z
c_ d S )Nr z,LineBuffer exceeded maximum size of {} bytes)lenr MAX_SIZEr formatr datas r
appendzLineBuffer.append si tx==3t99$t}44DH$>EEM
Dr c | S Nr r s r
__iter__zLineBuffer.__iter__ r c | j d }|dk r(| j d| }| j |dz d | _ |S t )N
)r find
StopIteration)r posresults r
__next__zLineBuffer.__next__ sN hmmD!!"99Xae_Fxa *DHMr c d| _ d S r r r s r
cleanzLineBuffer.clean' r r N)
r r r __doc__r r r r! r, r. r r r
r
r
sp H r r
c e Zd ZdS )SizeBufferOverflowNr r r r
r1 r1 + r r r1 c , e Zd ZdZddZd Zd Zd ZdS )
SizeBufferr c " d| _ || _ d S )Nr )_buf _size_len)r size_lens r
r zSizeBuffer.__init__2 s !r c t | j t | z | j k r.d| _ t d | j | xj |z
c_ d S )Nr z,SizeBuffer exceeded maximum size of {} bytes)r r6 r r1 r r s r
r zSizeBuffer.append6 si ty>>CII%
55DI$>EEM
T r c | S r r r s r
r! zSizeBuffer.__iter__@ r" r c D | j st t | j d | j d }t | j | j d |k r:| j | j | j |z }| j | j |z d | _ |S t )Nbig)r6 r) int
from_bytesr7 r )r sizer s r
r, zSizeBuffer.__next__C s y ~~di(8$.(895AAty))*++t339T^dnt.CCDD $.4"7"9"9:DIKr N)r4 )r r r r r r r! r, r r r
r3 r3 / sZ H" " " " r r3 N) Exceptionr objectr
r1 r3 r r r