3 \% ã @ st d Z ddlZddd„Zddd„ZG dd „ d ejƒZG d d„ dejƒZG dd „ d ejƒZG dd„ dejƒZdd„ Z dS )a Python 'utf-8-sig' Codec This work similar to UTF-8 with the following changes: * On encoding/writing a UTF-8 encoded BOM will be prepended/written as the first three bytes. * On decoding/reading if the first three bytes are a UTF-8 encoded BOM, these bytes will be skipped. é NÚstrictc C s t jt j| |ƒd t| ƒfS )Nr )ÚcodecsÚBOM_UTF8Úutf_8_encodeÚlen)ÚinputÚerrors© r ú+/usr/lib64/python3.6/encodings/utf_8_sig.pyÚencode s r c C sD d}| d d… t jkr&| dd … } d}t j| |dƒ\}}||| fS )Nr é T)r r Úutf_8_decode)r r ÚprefixÚoutputÚconsumedr r r Údecode s r c @ s8 e Zd Zddd„Zddd„Zdd„ Zd d „ Zdd„ Zd S )ÚIncrementalEncoderr c C s t jj| |ƒ d| _d S )Né )r r Ú__init__Úfirst)Úselfr r r r r s zIncrementalEncoder.__init__Fc C s: | j r$d| _ tjtj|| jƒd S tj|| jƒd S d S )Nr )r r r r r )r r Úfinalr r r r s zIncrementalEncoder.encodec C s t jj| ƒ d| _d S )Nr )r r Úresetr )r r r r r ' s zIncrementalEncoder.resetc C s | j S )N)r )r r r r Úgetstate+ s zIncrementalEncoder.getstatec C s || _ d S )N)r )r Ústater r r Úsetstate. s zIncrementalEncoder.setstateN)r )F)Ú__name__Ú __module__Ú__qualname__r r r r r r r r r r s r c @ s6 e Zd Zd dd„Zdd„ Zdd„ Zdd „ Zd d„ ZdS )ÚIncrementalDecoderr c C s t jj| |ƒ d| _d S )Nr )r ÚBufferedIncrementalDecoderr r )r r r r r r 2 s zIncrementalDecoder.__init__c C sv | j rht|ƒdk r*tjj|ƒr"dS d| _ n>d| _ |d d… tjkrhtj|dd … ||ƒ\}}||d fS tj|||ƒS )Nr Ú r )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 jj| ƒ d| _d S )Nr )r r r r )r r r r r G s zIncrementalDecoder.resetc C s t jj| ƒ}|d | jfS )Nr )r r r r )r r r r r r K s zIncrementalDecoder.getstatec C s t jj| |ƒ |d | _d S )Nr )r r r r )r r r r r r P s zIncrementalDecoder.setstateN)r )r r r r r# r r r r r r r r 1 s r c @ s e Zd Zdd„ Zddd„ZdS )ÚStreamWriterc C s. t jj| ƒ y| `W n tk r( Y nX d S )N)r r$ r r ÚAttributeError)r r r r r V s zStreamWriter.resetr c C s t j| _t||ƒS )N)r r r )r r r r r r r ] s zStreamWriter.encodeN)r )r r r r r r r r r r$ U s r$ c @ s e Zd Zdd„ Zddd„ZdS )ÚStreamReaderc C s. t jj| ƒ y| `W n tk r( Y nX d S )N)r r&