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&