o
    ‚.Úd  ã                   @   s<   d Z ddlmZ ddlmZ ddlmZ G dd„ deƒZdS )zTemplate output streams.é    )ÚStringIO)ÚOptional)ÚOutputStreamLimitErrorc                	       sV   e Zd ZdZ		ddedee dee ddf‡ fdd„Zd	edef‡ fd
d„Z‡  Z	S )ÚLimitedStringIOzHA StringIO subclass that limits the number of bytes that can be written.NÚlimitÚinitial_valueÚnewlineÚreturnc                    s   t ƒ  ||¡ || _d| _d S )Nr   )ÚsuperÚ__init__r   Úsize)Úselfr   r   r   ©Ú	__class__© úE/var/www/Matress/matenv/lib/python3.10/site-packages/liquid/output.pyr      s   
zLimitedStringIO.__init__Ú_LimitedStringIO__sc                    s<   |r|  j t| d¡ƒ7  _ | j | jkrtdƒ‚tƒ  |¡S )Nzutf-8zoutput stream limit reached)r   ÚlenÚencoder   r   r
   Úwrite)r   r   r   r   r   r      s
   zLimitedStringIO.write)NN)
Ú__name__Ú
__module__Ú__qualname__Ú__doc__Úintr   Ústrr   r   Ú__classcell__r   r   r   r   r      s    üþýüû
r   N)r   Úior   Útypingr   Úliquid.exceptionsr   r   r   r   r   r   Ú<module>   s
    