Ë
    ¾½ËjÝ)  ã                   ó  — d Z ddlZddlmZmZ ddlmZ dxZZddd	d
ddddœZ	i Z
d„ Zd„ Zd„ Z G d„ d«      Z ed«      Z ed«      Z ed«      Zd#d„Zd„ Zedfd„Zd#d„Zd„ Zedfd„Zd„ Z G d„ d «      Z G d!„ d"«      Zy)$a  

    webencodings
    ~~~~~~~~~~~~

    This is a Python implementation of the `WHATWG Encoding standard
    <http://encoding.spec.whatwg.org/>`. See README for details.

    :copyright: Copyright 2012 by Simon Sapin
    :license: BSD, see LICENSE for details.

é    Né   )Úreplacement_codec_infoÚuser_codec_info)ÚLABELSz0.6.1z	iso8859-8zmac-cyrillicz	mac-romanÚcp874Úcp932Ú	big5hkscsÚcp949)ziso-8859-8-izx-mac-cyrillicÚ	macintoshzwindows-874Ú	shift_jisÚbig5zeuc-krc                 óZ   — | j                  «       j                  «       j                  «       S )a2  Transform (only) ASCII letters to lower case: A-Z is mapped to a-z.

    :param string: An Unicode string.
    :returns: A new Unicode string.

    This is used for `ASCII case-insensitive
    <http://encoding.spec.whatwg.org/#ascii-case-insensitive>`_
    matching of encoding labels.
    The same matching is also used, among other things,
    for `CSS keywords <http://dev.w3.org/csswg/css-values/#keywords>`_.

    This is different from the :meth:`str.lower` method of Unicode strings
    which also affect non-ASCII characters,
    sometimes mapping them into the ASCII range:

        >>> keyword = 'Bac\N{KELVIN SIGN}ground'
        >>> assert keyword.lower() == 'background'
        >>> assert ascii_lower(keyword) != keyword.lower()
        >>> assert ascii_lower(keyword) == 'bac\N{KELVIN SIGN}ground'

    )ÚencodeÚlowerÚdecode)Ústrings    úM/home/Script/Script_env/lib/python3.12/site-packages/webencodings/__init__.pyÚascii_lowerr   &   s"   € ð. �=‰=‹?× Ñ Ó"×)Ñ)Ó+Ð+ó    c                 óH  — t        | j                  d«      «      } t        j                  | «      }|€yt        j                  |«      }|€X|dk(  rt
        }n7|dk(  rt        }n+t        j                  ||«      }t        j                  |«      }t        ||«      }|t        |<   |S )a6  Look for an encoding by its label.

    This is the spec's `get an encoding
    <http://encoding.spec.whatwg.org/#concept-encoding-get>`_ algorithm.
    Supported labels are listed there.

    :param label: A string.
    :returns:
        An :class:`Encoding` object, or :obj:`None` for an unknown label.

    z	
 Nzx-user-definedÚreplacement)r   Ústripr   ÚgetÚCACHEr   r   ÚPYTHON_NAMESÚcodecsÚlookupÚEncoding)ÚlabelÚnameÚencodingÚ
codec_infoÚpython_names        r   r   r   @   s•   € ô ˜Ÿ™ KÓ0Ó1€EÜ�:‰:�eÓ€DØ€|ØÜ�y‰y˜‹€HØÐØÐ#Ò#Ü(‰JØ�]Ò"Ü/‰Jä&×*Ñ*¨4°Ó6ˆKäŸ™ {Ó3ˆJÜ˜D *Ó-ˆØŒˆd‰Ø€Or   c                 óX   — t        | d«      r| S t        | «      }|€t        d| ›�«      ‚|S )zÖAccept either an encoding object or label.

    :param encoding: An :class:`Encoding` object or a label string.
    :returns: An :class:`Encoding` object.
    :raises: :exc:`LookupError` for an unknown label.

    r"   zUnknown encoding label: )Úhasattrr   ÚLookupError)Úencoding_or_labelr!   s     r   Ú_get_encodingr(   `   s@   € ô Ð  ,Ô/Ø Ð äÐ'Ó(€HØÐÜÐ4Ð5FÐ4IÐJÓKÐKØ€Or   c                   ó   — e Zd ZdZd„ Zd„ Zy)r   a2  A character encoding that can be used for decoding or encoding.

    .. attribute:: name

        Canonical name of the encoding

    .. attribute:: codec_info

        The actual implementation of the encoding,
        a stdlib :class:`~codecs.CodecInfo` object.
        See :func:`codecs.register`.

    c                 ó    — || _         || _        y ©N)r    r"   )Úselfr    r"   s      r   Ú__init__zEncoding.__init__   s   € ØˆŒ	Ø$ˆ�r   c                 ó"   — d| j                   › d�S )Nz
<Encoding ú>)r    )r,   s    r   Ú__repr__zEncoding.__repr__ƒ   s   € Ø˜DŸI™I˜; aÐ(Ð(r   N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r-   r0   © r   r   r   r   q   s   „ ñò%ó)r   r   zutf-8zutf-16lezutf-16bec                 ó‚   — t        |«      }t        | «      \  }} |xs |}|j                  j                  | |«      d   |fS )aÄ  Decode a single string.

    :param input: A byte string
    :param fallback_encoding:
        An :class:`Encoding` object or a label string.
        The encoding to use if :obj:`input` does not have a BOM.
    :param errors: Type of error handling. See :func:`codecs.register`.
    :raises: :exc:`LookupError` for an unknown encoding label.
    :return:
        A ``(output, encoding)`` tuple of an Unicode string
        and an :obj:`Encoding`.

    r   )r(   Ú_detect_bomr"   r   )ÚinputÚfallback_encodingÚerrorsÚbom_encodingr!   s        r   r   r   Ž   sM   € ô &Ð&7Ó8ÐÜ% eÓ,Ñ€L�%ØÒ0Ð0€HØ×Ñ×%Ñ% e¨VÓ4°QÑ7¸ÐAÐAr   c                 ó²   — | j                  d«      rt        | dd fS | j                  d«      rt        | dd fS | j                  d«      rt        | dd fS d| fS )zBReturn (bom_encoding, input), with any BOM removed from the input.s   ÿþé   Ns   þÿs   ï»¿é   )Ú
startswithÚ_UTF16LEÚ_UTF16BEÚUTF8)r8   s    r   r7   r7   £   sh   € à×Ñ˜Ô$Ü˜˜q˜r˜Ð"Ð"Ø×Ñ˜Ô$Ü˜˜q˜r˜Ð"Ð"Ø×Ñ˜Ô(Ü�U˜1˜2�YˆÐØ�ˆ;Ðr   Ústrictc                 óR   — t        |«      j                  j                  | |«      d   S )a*  Encode a single string.

    :param input: An Unicode string.
    :param encoding: An :class:`Encoding` object or a label string.
    :param errors: Type of error handling. See :func:`codecs.register`.
    :raises: :exc:`LookupError` for an unknown encoding label.
    :return: A byte string.

    r   )r(   r"   r   )r8   r!   r:   s      r   r   r   ®   s'   € ô ˜Ó"×-Ñ-×4Ñ4°U¸FÓCÀAÑFÐFr   c                 óP   — t        ||«      }t        | |«      }t        |«      }||fS )aÊ  "Pull"-based decoder.

    :param input:
        An iterable of byte strings.

        The input is first consumed just enough to determine the encoding
        based on the precense of a BOM,
        then consumed on demand when the return value is.
    :param fallback_encoding:
        An :class:`Encoding` object or a label string.
        The encoding to use if :obj:`input` does not have a BOM.
    :param errors: Type of error handling. See :func:`codecs.register`.
    :raises: :exc:`LookupError` for an unknown encoding label.
    :returns:
        An ``(output, encoding)`` tuple.
        ``output`` is an iterable of Unicode strings,
        ``encoding`` is the :obj:`Encoding` that is being used.

    )ÚIncrementalDecoderÚ_iter_decode_generatorÚnext)r8   r9   r:   ÚdecoderÚ	generatorr!   s         r   Úiter_decoderK   »   s1   € ô* !Ð!2°FÓ;€GÜ& u¨gÓ6€IÜ�I‹€HØ�hÐÐr   c              #   óH  K  — |j                   }t        | «      } | D ].  } ||«      }|sŒ|j                  €J ‚|j                  –— |–—  n.  |dd¬«      }|j                  €J ‚|j                  –— |r|–— y| D ]  } ||«      }|sŒ|–— Œ  |dd¬«      }|r|–— yy­w)z|Return a decode generator.

    It first yields the :obj:`Encoding`, then yields output chunks as Unicode
    strings.

    Nr   T©Úfinal)r   Úiterr!   )r8   rI   r   ÚchunckÚoutputs        r   rG   rG   Ö   sÍ   è ø€ ð �^‰^€FÜ�‹K€EØò ˆÙ˜“ˆÚØ×#Ñ#Ð/Ð/Ð/Ø×"Ñ"Ò"ØŠLÙðñ ˜ 4Ô(ˆØ×ÑÐ+Ð+Ð+Ø×ÑÒÙØŠLØàò ˆÙ˜“ˆÚØ‹Lðñ �C˜tÔ$€FÙØ‹ð ùs   ‚'B"ªAB"Â
B"c                 óF   — t        ||«      j                  }t        | |«      S )aD  "Pull"-based encoder.

    :param input: An iterable of Unicode strings.
    :param encoding: An :class:`Encoding` object or a label string.
    :param errors: Type of error handling. See :func:`codecs.register`.
    :raises: :exc:`LookupError` for an unknown encoding label.
    :returns: An iterable of byte strings.

    )ÚIncrementalEncoderr   Ú_iter_encode_generator)r8   r!   r:   r   s       r   Úiter_encoderU   ø   s#   € ô   ¨&Ó1×8Ñ8€FÜ! %¨Ó0Ð0r   c              #   óZ   K  — | D ]  } ||«      }|sŒ|–— Œ  |dd¬«      }|r|–— yy­w)zReturn an encode generator.Ú TrM   Nr5   )r8   r   rP   rQ   s       r   rT   rT     sA   è ø€ àò ˆÙ˜“ˆÚØ‹Lðñ �B˜dÔ#€FÙØ‹ð ùs   ‚+“+c                   ó    — e Zd ZdZdd„Zdd„Zy)rF   a9  "Push"-based decoder.

    :param fallback_encoding:
        An :class:`Encoding` object or a label string.
        The encoding to use if :obj:`input` does not have a BOM.
    :param errors: Type of error handling. See :func:`codecs.register`.
    :raises: :exc:`LookupError` for an unknown encoding label.

    c                 ó\   — t        |«      | _        || _        d| _        d | _        d | _        y )Nr   )r(   Ú_fallback_encodingÚ_errorsÚ_bufferÚ_decoderr!   )r,   r9   r:   s      r   r-   zIncrementalDecoder.__init__  s.   € ä"/Ð0AÓ"BˆÔØˆŒØˆŒØˆŒð
 ˆ�r   c                 óB  — | j                   }|�	 |||«      S | j                  |z   }t        |«      \  }}|€$t        |«      dk  r
|s|| _        y| j                  }|j
                  j                  | j                  «      j                  }|| _         || _	         |||«      S )zùDecode one chunk of the input.

        :param input: A byte string.
        :param final:
            Indicate that no more input is available.
            Must be :obj:`True` if this is the last call.
        :returns: An Unicode string.

        r>   rW   )
r]   r\   r7   ÚlenrZ   r"   Úincrementaldecoderr[   r   r!   )r,   r8   rN   rI   r!   s        r   r   zIncrementalDecoder.decode(  sŸ   € ð —-‘-ˆØÐÙ˜5 %Ó(Ð(à—‘˜uÑ$ˆÜ% eÓ,‰ˆ�%ØÐÜ�5‹z˜AŠ~¡eØ$�”Øà×2Ñ2�Ø×%Ñ%×8Ñ8¸¿¹ÓF×MÑMˆØˆŒØ ˆŒÙ�u˜eÓ$Ð$r   N©Úreplace)F)r1   r2   r3   r4   r-   r   r5   r   r   rF   rF     s   „ ñó
ô%r   rF   c                   ó   — e Zd ZdZedfd„Zy)rS   aä  "Push"-based encoder.

    :param encoding: An :class:`Encoding` object or a label string.
    :param errors: Type of error handling. See :func:`codecs.register`.
    :raises: :exc:`LookupError` for an unknown encoding label.

    .. method:: encode(input, final=False)

        :param input: An Unicode string.
        :param final:
            Indicate that no more input is available.
            Must be :obj:`True` if this is the last call.
        :returns: A byte string.

    rC   c                 ón   — t        |«      }|j                  j                  |«      j                  | _        y r+   )r(   r"   Úincrementalencoderr   )r,   r!   r:   s      r   r-   zIncrementalEncoder.__init__T  s*   € Ü  Ó*ˆØ×)Ñ)×<Ñ<¸VÓD×KÑKˆ�r   N)r1   r2   r3   r4   rB   r-   r5   r   r   rS   rS   D  s   „ ñð !%¨Xô Lr   rS   ra   )r4   r   Úcustomr   r   Úlabelsr   ÚVERSIONÚ__version__r   r   r   r   r(   r   rB   r@   rA   r   r7   r   rK   rG   rU   rT   rF   rS   r5   r   r   ú<module>rj      sÊ   ðñó ç ;Ý àÐ €ˆ+ð
  Ø$ØØð ØØñ€ð 	€ò,ò4ò@÷")ñ )ñ. ˆgƒ€á�*Ó€Ù�*Ó€óBò*ð  ¨ó 
Góò6ðD !%¨Xó 1ò÷/%ñ /%÷dLò Lr   