
    ;e%                         	 d dl Z ddZddZ G d de j                  Z G d de j                  Z G d	 d
e j                  Z G d de j                  Zd ZdS )    Nstrictc                 p    t           j        t          j        | |          d         z   t          |           fS Nr   )codecsBOM_UTF8utf_8_encodelen)inputerrorss     */usr/lib/python3.11/encodings/utf_8_sig.pyencoder      s1    Of1%@@CCJJ     c                     d}| d d         t           j        k    r| dd          } d}t          j        | |d          \  }}|||z   fS )Nr      T)r   r   utf_8_decode)r
   r   prefixoutputconsumeds        r   decoder      sV    FRaRyFO##abb	,UFDAAVXHVO$$r   c                   0    e Zd Zd	dZd
dZd Zd Zd ZdS )IncrementalEncoderr   c                 T    t           j                            | |           d| _        d S N   )r   r   __init__firstselfr   s     r   r   zIncrementalEncoder.__init__   s&    !**4888


r   Fc                     | j         r4d| _         t          j        t          j        || j                  d         z   S t          j        || j                  d         S r   )r   r   r   r   r   )r   r
   finals      r   r   zIncrementalEncoder.encode   sU    : 	>DJ?&udk::1=> > &udk::1==r   c                 R    t           j                            |            d| _        d S r   )r   r   resetr   r   s    r   r"   zIncrementalEncoder.reset'   s$    !''---


r   c                     | j         S Nr   r#   s    r   getstatezIncrementalEncoder.getstate+   s
    zr   c                     || _         d S r%   r&   r   states     r   setstatezIncrementalEncoder.setstate.   s    


r   Nr   )F)__name__
__module____qualname__r   r   r"   r'   r+    r   r   r   r      si           > > > >        r   r   c                   .    e Zd ZddZd Zd Zd Zd ZdS )	IncrementalDecoderr   c                 T    t           j                            | |           d| _        d S r   )r   BufferedIncrementalDecoderr   r   r   s     r   r   zIncrementalDecoder.__init__2   s&    )224@@@


r   c                 B   | j         rt          |          dk     r)t          j                            |          rdS d| _         nGd| _         |d d         t          j        k    r(t          j        |dd          ||          \  }}||dz   fS t          j        |||          S )Nr    r   r   )r   r	   r   r   
startswithr   )r   r
   r   r    r   r   s         r   _buffer_decodez!IncrementalDecoder._buffer_decode6   s    : 	05zzA~~?--e44 # #7!"DJJ
!9//*59feDD 'VX"HQJ//"5&%888r   c                 R    t           j                            |            d| _        d S r   )r   r4   r"   r   r#   s    r   r"   zIncrementalDecoder.resetG   s$    )//555


r   c                 ^    t           j                            |           }|d         | j        fS r   )r   r4   r'   r   r)   s     r   r'   zIncrementalDecoder.getstateK   s)    1::4@@a$*%%r   c                 `    t           j                            | |           |d         | _        d S r   )r   r4   r+   r   r)   s     r   r+   zIncrementalDecoder.setstateP   s*    )224???1X


r   Nr,   )r-   r.   r/   r   r9   r"   r'   r+   r0   r   r   r2   r2   1   sd           9 9 9"  & & &
    r   r2   c                       e Zd Zd ZddZdS )StreamWriterc                 l    t           j                            |            	 | `d S # t          $ r Y d S w xY wr%   )r   r>   r"   r   AttributeErrorr#   s    r   r"   zStreamWriter.resetV   I    !!$'''	 	 	 	DD	   % 
33r   c                 D    t           j        | _        t          ||          S r%   )r   r   r   )r   r
   r   s      r   r   zStreamWriter.encode]   s    )eV$$$r   Nr,   )r-   r.   r/   r"   r   r0   r   r   r>   r>   U   s7          % % % % % %r   r>   c                       e Zd Zd ZddZdS )StreamReaderc                 l    t           j                            |            	 | `d S # t          $ r Y d S w xY wr%   )r   rE   r"   r   r@   r#   s    r   r"   zStreamReader.resetb   rA   rB   r   c                 X   t          |          dk     r"t          j                            |          rdS nP|d d         t          j        k    r8t          j        | _        t          j        |dd          |          \  }}||dz   fS t          j        | _        t          j        ||          S )Nr   r6   )r	   r   r   r8   r   r   )r   r
   r   r   r   s        r   r   zStreamReader.decodei   s    u::>>))%00  w 2A2Y&/)) -DK!'!4U122Yv!F!FVXHQJ'')"5&111r   Nr,   )r-   r.   r/   r"   r   r0   r   r   rE   rE   a   s7          2 2 2 2 2 2r   rE   c            	      t    t          j        dt          t          t          t
          t          t                    S )Nz	utf-8-sig)namer   r   incrementalencoderincrementaldecoderstreamreaderstreamwriter)r   	CodecInfor   r   r   r2   rE   r>   r0   r   r   getregentryrO   y   s1    --!!   r   r,   )	r   r   r   r   r4   r2   r>   rE   rO   r0   r   r   <module>rP      s      % % % %    2   ." " " " ": " " "H
% 
% 
% 
% 
%6& 
% 
% 
%2 2 2 2 26& 2 2 20	 	 	 	 	r   