
    !j                     J   d dl Z d dlmZmZmZ ddlmZmZmZm	Z	m
Z
mZ  G d de j                  Z G d de j                  Z G d	 d
e j                  Z G d dee j                  Z G d dee j                  Zdedee j                 fdZ e j        e           dS )    N)AnyOptionalTuple   )	IDNAError_unicode_dots_realabeldecodeencodeulabelc            	       ^    e Zd ZdZd	dededeeef         fdZd	dededeeef         fdZ	dS )
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                 x    |dk    rt          d| d          |sdS t          |          t          |          fS )Nr   Unsupported error handling ""    r   )r   r   lenselfr   r   s      F/var/www/html/bolsaweb/venv/lib/python3.11/site-packages/idna/codec.pyr   zCodec.encode   sK    XD6DDDEEE 	6d||SYY&&r   c                 x    |dk    rt          d| d          |sdS t          |          t          |          fS )Nr   r   r    r   )r   r
   r   r   s      r   r
   zCodec.decode   sK    XD6DDDEEE 	5d||SYY&&r   N)r   )
__name__
__module____qualname____doc__strr   bytesintr   r
    r   r   r   r      s         ' '3 ' '5;L ' ' ' '' '5 '# 'U38_ ' ' ' ' ' 'r   r   c            
       :    e Zd ZdZdedededeeef         fdZ	dS )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                 ~   |dk    rt          d| d          |sdS t          j        |          }d}|r|d         sd}|d= n	|s|d= |rd}g }d}|D ]=}|                    t	          |                     |r|d	z  }|t          |          z  }>d                    |          |z   }	|t          |          z  }|	|fS )
Nr   r   r   r   r      .r   r   )r   r   splitappendr	   r   join)
r   r   r   r)   labelstrailing_dotresultsizelabelresult_bytess
             r   _buffer_encodez!IncrementalEncoder._buffer_encode1   s   XD6DDDEEE 	6!'-- 	(": (#2JJ (2J (#'L 	 	EMM&--((( 	CJJDD yy((<7L!!!T!!r   N)
r   r    r!   r"   r#   boolr   r$   r%   r6   r&   r   r   r(   r(   %   sX        	 	"3 " "D "U5RU:EV " " " " " "r   r(   c            
       :    e Zd ZdZdedededeeef         fdZ	dS )IncrementalDecodera  Incremental IDNA 2008 decoder.

    Buffers a partial trailing label across calls until either the next
    label separator is seen or ``final=True``, so that streamed input is
    decoded one whole label at a time.

    Only the ``"strict"`` error handler is supported.
    r   r   r)   r   c                    |dk    rt          d| d          |sdS t          |t                    st          |d          }t          j        |          }d}|r|d         sd}|d= n	|s|d= |rd}g }d	}|D ]=}|                    t          |                     |r|d
z  }|t          |          z  }>d                    |          |z   }	|t          |          z  }|	|fS )Nr   r   r   r   asciir   r+   .r   r   )	r   
isinstancer#   r   r-   r.   r   r   r/   )
r   r   r   r)   r0   r1   r2   r3   r4   
result_strs
             r   _buffer_decodez!IncrementalDecoder._buffer_decode\   s/   XD6DDDEEE 	7$$$ 	&tW%%D!'-- 	'": '"2JJ '2J '#&L 	 	EMM&--((( 	CJJDDXXf%%4
L!!!D!!r   N)
r   r    r!   r"   r   r#   r7   r   r%   r?   r&   r   r   r9   r9   R   sW          "3  "  "D  "U3PS8_  "  "  "  "  "  "r   r9   c                       e Zd ZdS )StreamWriterNr   r    r!   r&   r   r   rA   rA              Dr   rA   c                       e Zd ZdS )StreamReaderNrB   r&   r   r   rE   rE      rC   r   rE   namer   c           	          | dk    rdS t          j        | t                      j        t                      j        t
          t          t          t                    S )a  Codec search function registered with :mod:`codecs`.

    Returns a :class:`codecs.CodecInfo` for the ``"idna2008"`` codec name
    so that ``str.encode("idna2008")`` and ``bytes.decode("idna2008")``
    invoke the IDNA 2008 codec defined in this module.

    :param name: The codec name being looked up.
    :returns: A :class:`codecs.CodecInfo` instance if ``name`` is
        ``"idna2008"``, otherwise ``None``.
    idna2008N)rF   r   r
   incrementalencoderincrementaldecoderstreamwriterstreamreader)	codecs	CodecInfor   r   r
   r(   r9   rA   rE   )rF   s    r   search_functionrO      sO     ztww~ww~--!!   r   )rM   typingr   r   r   corer   r   r	   r
   r   r   r   BufferedIncrementalEncoderr(   BufferedIncrementalDecoderr9   rA   rE   r#   rN   rO   registerr&   r   r   <module>rU      s    ' ' ' ' ' ' ' ' ' ' M M M M M M M M M M M M M M M M' ' ' ' 'FL ' ' '<*" *" *" *" *": *" *" *"Z*" *" *" *" *": *" *" *"Z	 	 	 	 	5&- 	 	 		 	 	 	 	5&- 	 	 	# (6+;"<    0           r   