ruạṛ
a �u:j� � @ s� d dl Z d dlmZmZ ddlmZmZmZmZm Z m Z G dd� de j�ZG dd� de j�Z G d d � d e j�ZG dd� dee j�ZG d d� dee j�Zeee j d�dd�Ze �e� dS )� N)�Any�Optional� )� IDNAError�_unicode_dots_re�alabel�decode�encode�ulabelc @ sH e Zd ZdZd eeeeef d�dd�Zd eeeeef d�dd�Z dS )�Codecaf Stateless IDNA 2008 codec. Implements the :class:`codecs.Codec` protocol so that the whole-domain encoder (:func:`idna.encode`) and decoder (:func:`idna.decode`) are accessible through the standard codec machinery as ``"idna2008"``. Only the ``"strict"`` error handler is supported; any other handler raises :exc:`~idna.IDNAError`. �strict)�data�errors�returnc C s0 |dkrt d|� d���|s dS t|�t|�fS )Nr �Unsupported error handling "�"�� r )r r �len��selfr r � r �=/opt/bart/bart_venv/lib/python3.9/site-packages/idna/codec.pyr s zCodec.encodec C s0 |dkrt d|� d���|s dS t|�t|�fS )Nr r r �� r )r r r r r r r r s zCodec.decodeN)r )r ) �__name__� __module__�__qualname__�__doc__�str�tuple�bytes�intr r r r r r r s r c @ s, e Zd ZdZeeeeeef d�dd�Z dS )�IncrementalEncodera� Incremental IDNA 2008 encoder. Buffers a partial trailing label across calls until either the next label separator is seen or ``final=True``, so that streamed input is encoded one whole label at a time. Any of the four Unicode label separators (``U+002E``, ``U+3002``, ``U+FF0E``, ``U+FF61``) ends a label; the result always uses ``U+002E`` as the separator. Only the ``"strict"`` error handler is supported. �r r �finalr c C s� |dkrt d|� d���|s dS t�|�}d}|rX|d sFd}|d= n|sX|d= |rXd}g }d}|D ]*}|�t|�� |r�|d 7 }|t|�7 }qdd�|�| } |t|�7 }| |fS ) Nr r r r r ���� .r r )r r �split�appendr r �join) r r r r% �labels�trailing_dot�result�size�labelZresult_bytesr r r �_buffer_encode1 s0 z!IncrementalEncoder._buffer_encodeN) r r r r r �boolr r! r"