cjFddlZddlmZmZddlmZmZmZmZm Z m Z Gddej Z Gddej Z Gd d ejZGd d e ejZGd de ejZdedeejfdZejedS)N)AnyOptional) IDNAError_unicode_dots_realabeldecodeencodeulabelc ^eZdZdZd dededeeeffdZd dededeeeffdZ dS) 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`. strictdataerrorsreturncx|dkrtd|d|sdSt|t|fS)NrUnsupported error handling ""r)rr lenselfrrs b/home/jenkins/jenkins/workspace/simtester-sanitize/venv/lib/python3.11/site-packages/idna/codec.pyr z Codec.encodesK X  D6DDDEE E 6d||SYY&&rcx|dkrtd|d|sdSt|t|fS)Nrrrr)rr rrs rr z Codec.decodesK X  D6DDDEE E 5d||SYY&&rN)r) __name__ __module__ __qualname____doc__strtuplebytesintr r rrr r s''3''5;L''''''5'#'U38_''''''rr c :eZdZdZdedededeeeffdZ dS)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. rrfinalrc~|dkrtd|d|sdStj|}d}|r|dsd}|d=n |s|d=|rd}g}d}|D]=}|t ||r|d z }|t |z }>d||z} |t |z }| |fS) Nrrrrr.rr)rrsplitappendrrjoin) rrrr)labels trailing_dotresultsizelabel result_bytess r_buffer_encodez!IncrementalEncoder._buffer_encode1s X  D6DDDEE E 6!'--  (": (# 2JJ (2J(#'L  E MM&-- ( ( (   CJJ DDyy((<7  L!!!T!!rN) rrr r!r"boolr#r$r%r6r&rrr(r(%sX  "3""D"U5RU:EV""""""rr(c :eZdZdZdedededeeeffdZ dS)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|dkrtd|d|sdSt|tst|d}tj|}d}|r|dsd}|d=n |s|d=|rd}g}d }|D]=}|t ||r|d z }|t|z }>d||z} |t|z }| |fS) Nrrrrasciirr+.rr) r isinstancer"rr-r.r rr/) rrrr)r0r1r2r3r4 result_strs r_buffer_decodez!IncrementalDecoder._buffer_decode\s/ X  D6DDDEE E 7$$$ &tW%%D!'--  '": '" 2JJ '2J'#&L  E MM&-- ( ( (   CJJ DDXXf%% 4  L!!!D!!rN) rrr r!rr"r7r#r%r?r&rrr9r9RsW "3 " "D "U3PS8_ " " " " " "rr9ceZdZdS) StreamWriterNrrr r&rrrArADrrAceZdZdS) StreamReaderNrBr&rrrErErCrrEnamerc |dkrdStj|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_functionrOsO zt   ww~ww~--!!   r)rMtypingrrcorerrrr r r r BufferedIncrementalEncoderr(BufferedIncrementalDecoderr9rArEr"rNrOregisterr&rrrUs MMMMMMMMMMMMMMMM'''''FL'''<*"*"*"*"*":*"*"*"Z*"*"*"*"*":*"*"*"Z     5&-        5&-   #(6+;"<0 r