Xj`ddlZddlmZmZddlmZmZmZmZm Z m Z GddejZ GddejZ Gd d ejZGd d e ej ZGd de ej"Zdedeej&fdZej*ey)N)AnyOptional) IDNAError_unicode_dots_realabeldecodeencodeulabelc PeZdZdZddededeeeffdZddededeeeffdZ y) CodecafStateless 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`. dataerrorsreturnc\|dk7rtd|d|syt|t|fS)NstrictUnsupported error handling ""r)rr lenselfrrs ^/mnt/ssd/data/Dropbox/adrian/vault-secondbrain/venv/lib/python3.12/site-packages/idna/codec.pyr z Codec.encodes8 X :6(!DE Ed|SY&&rc\|dk7rtd|d|syt|t|fS)Nrrrr)rr rrs rr z Codec.decodes8 X :6(!DE Ed|SY&&rN)r) __name__ __module__ __qualname____doc__strtuplebytesintr r rrr r sL'3''5;L''5'#'U38_'rr c 2eZdZdZdedededeeeffdZ y)IncrementalEncoderaIncremental 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. rrfinalrcJ|dk7rtd|d|sytj|}d}|r|dsd}|d=n |s|d=|rd}g}d}|D]1}|jt ||r|d z }|t |z }3dj ||z} |t |z }| |fS) Nrrrrr.rr)rrsplitappendrrjoin) rrrr)labels trailing_dotresultsizelabel result_bytess r_buffer_encodez!IncrementalEncoder._buffer_encode1s X :6(!DE E!''- ":# 2J2J#'L E MM&- (  CJ D  yy(<7  L!!T!!rN) rrr r!r"boolr#r$r%r6r&rrr(r(%s2 "3""D"U5RU:EV"rr(c 2eZdZdZdedededeeeffdZ y)IncrementalDecoderaIncremental 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. rrr)rc|dk7rtd|d|syt|ts t|d}tj|}d}|r|dsd}|d=n |s|d=|rd}g}d }|D]1}|j t ||r|d z }|t|z }3dj||z} |t|z }| |fS) Nrrrrasciirr+.rr) r isinstancer"rr-r.r rr/) rrrr)r0r1r2r3r4 result_strs r_buffer_decodez!IncrementalDecoder._buffer_decode\s X :6(!DE E$$tW%D!''- ":" 2J2J#&L E MM&- (  CJ D   XXf% 4  L!!D!!rN) rrr r!rr"r7r#r%r?r&rrr9r9Rs1 "3 " "D "U3PS8_ "rr9c eZdZy) StreamWriterNrrr r&rrrArArrAc eZdZy) StreamReaderNrBr&rrrErErCrrEnamerc |dk7rytj|tjtjt t ttS)aCodec 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)rFr r incrementalencoderincrementaldecoder streamwriter streamreader) codecs CodecInfor r r r(r9rArE)rFs rsearch_functionrOsC z    w~~w~~--!! r)rMtypingrrcorerrrr r r r BufferedIncrementalEncoderr(BufferedIncrementalDecoderr9rArEr"rNrOregisterr&rrrUs MM'FLL'<*"::*"Z*"::*"Z 5&--  5&-- #(6+;+;"<0 r