a
    ´i%  ã                   @   sp   d dl Z ddd„Zddd„ZG dd„ de jƒZG d	d
„ d
e jƒZG dd„ de jƒZG dd„ de jƒZdd„ ZdS )é    NÚstrictc                 C   s   t jt  | |¡d  t| ƒfS ©Nr   )ÚcodecsÚBOM_UTF8Úutf_8_encodeÚlen)ÚinputÚerrors© r
   ú+/usr/lib64/python3.9/encodings/utf_8_sig.pyÚencode   s    ÿr   c                 C   sD   d}| d d… t jkr&| dd … } d}t  | |d¡\}}||| fS )Nr   é   T)r   r   Úutf_8_decode)r   r	   ÚprefixÚoutputÚconsumedr
   r
   r   Údecode   s    r   c                   @   s8   e Zd Zddd„Zddd„Zdd„ Zd	d
„ Zdd„ ZdS )ÚIncrementalEncoderr   c                 C   s   t j | |¡ d| _d S ©Né   )r   r   Ú__init__Úfirst©Úselfr	   r
   r
   r   r      s    zIncrementalEncoder.__init__Fc                 C   s:   | j r$d| _ tjt || j¡d  S t || j¡d S d S r   )r   r   r   r   r	   )r   r   Úfinalr
   r
   r   r      s    ÿzIncrementalEncoder.encodec                 C   s   t j | ¡ d| _d S r   )r   r   Úresetr   ©r   r
   r
   r   r   '   s    zIncrementalEncoder.resetc                 C   s   | j S ©N©r   r   r
   r
   r   Úgetstate+   s    zIncrementalEncoder.getstatec                 C   s
   || _ d S r   r   ©r   Ústater
   r
   r   Úsetstate.   s    zIncrementalEncoder.setstateN)r   )F)Ú__name__Ú
__module__Ú__qualname__r   r   r   r   r"   r
   r
   r
   r   r      s
   

r   c                   @   s6   e Zd Zddd„Zdd„ Zdd„ Zdd	„ Zd
d„ ZdS )ÚIncrementalDecoderr   c                 C   s   t j | |¡ d| _d S r   )r   ÚBufferedIncrementalDecoderr   r   r   r
   r
   r   r   2   s    zIncrementalDecoder.__init__c                 C   sv   | j rht|ƒdk r*tj |¡r"dS d| _ n>d| _ |d d… tjkrht |dd … ||¡\}}||d fS t |||¡S )Nr   ©Ú r   r   )r   r   r   r   Ú
startswithr   )r   r   r	   r   r   r   r
   r
   r   Ú_buffer_decode6   s    ÿz!IncrementalDecoder._buffer_decodec                 C   s   t j | ¡ d| _d S r   )r   r'   r   r   r   r
   r
   r   r   G   s    zIncrementalDecoder.resetc                 C   s   t j | ¡}|d | jfS r   )r   r'   r   r   r    r
   r
   r   r   K   s    zIncrementalDecoder.getstatec                 C   s   t j | |¡ |d | _d S r   )r   r'   r"   r   r    r
   r
   r   r"   P   s    zIncrementalDecoder.setstateN)r   )r#   r$   r%   r   r+   r   r   r"   r
   r
   r
   r   r&   1   s
   
r&   c                   @   s   e Zd Zdd„ Zddd„ZdS )ÚStreamWriterc                 C   s,   t j | ¡ z| `W n ty&   Y n0 d S r   )r   r,   r   r   ÚAttributeErrorr   r
   r
   r   r   V   s
    zStreamWriter.resetr   c                 C   s   t j| _t||ƒS r   )r   r   r   )r   r   r	   r
   r
   r   r   ]   s    zStreamWriter.encodeN)r   )r#   r$   r%   r   r   r
   r
   r
   r   r,   U   s   r,   c                   @   s   e Zd Zdd„ Zddd„ZdS )ÚStreamReaderc                 C   s,   t j | ¡ z| `W n ty&   Y n0 d S r   )r   r.   r   r   r-   r   r
   r
   r   r   b   s
    zStreamReader.resetr   c                 C   sp   t |ƒdk rtj |¡r\dS n>|d d… tjkr\tj| _t |dd … |¡\}}||d fS tj| _t ||¡S )Nr   r(   )r   r   r   r*   r   r   )r   r   r	   r   r   r
   r
   r   r   i   s    zStreamReader.decodeN)r   )r#   r$   r%   r   r   r
   r
   r
   r   r.   a   s   r.   c                	   C   s   t jdttttttd�S )Nz	utf-8-sig)Únamer   r   ÚincrementalencoderÚincrementaldecoderÚstreamreaderÚstreamwriter)r   Ú	CodecInfor   r   r   r&   r.   r,   r
   r
   r
   r   Úgetregentryy   s    ùr5   )r   )r   )	r   r   r   r   r'   r&   r,   r.   r5   r
   r
   r
   r   Ú<module>
   s   

$