2biS) S r SSKJr SSKrSSKJr SrSSS S
S.r0 rS r S
r
S r " S S\5 r
\
" S5 r\
" S5 r\
" S5 rS S jrS r\S4S jrS S jrS r\S4S jrS r " S S\5 r " S S\5 rg)!z
webencodings
~~~~~~~~~~~~
This is a Python implementation of the `WHATWG Encoding standard
`. See README for details.
:copyright: Copyright 2012 by Simon Sapin
:license: BSD, see LICENSE for details.
)unicode_literalsN )LABELSz0.5.1z
iso-8859-8zmac-cyrillicz mac-romancp874)ziso-8859-8-izx-mac-cyrillic macintoshzwindows-874c ^ U R S5 R 5 R S5 $ )a 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
`_
matching of encoding labels.
The same matching is also used, among other things,
for `CSS keywords `_.
This is different from the :meth:`~py:str.lower` method of Unicode strings
which also affect non-ASCII characters,
sometimes mapping them into the ASCII range:
>>> keyword = u'Bac\N{KELVIN SIGN}ground'
>>> assert keyword.lower() == u'background'
>>> assert ascii_lower(keyword) != keyword.lower()
>>> assert ascii_lower(keyword) == u'bac\N{KELVIN SIGN}ground'
utf8)encodelowerdecode)strings ړ/builddir/build/BUILDROOT/alt-python313-pip-23.3.1-3.el8.x86_64/opt/alt/python313/lib/python3.13/site-packages/pip/_vendor/webencodings/__init__.pyascii_lowerr # s' . == &&(//77 c 6 [ U R S5 5 n [ R " U 5 nUc g[ R U5 nUcL US:X a SSKJn O+[ R X5 n[ R " U5 n[ X5 nU[ U' U$ )u
Look for an encoding by its label.
This is the spec’s `get an encoding
`_ algorithm.
Supported labels are listed there.
:param label: A string.
:returns:
An :class:`Encoding` object, or :obj:`None` for an unknown label.
z
Nzx-user-definedr )
codec_info)r stripr getCACHEx_user_definedr PYTHON_NAMEScodecslookupEncoding)labelnameencodingr python_names r r r = s
K01E::eD|yyH##2&**46K{3JD-dOr c d [ U S5 ( a U $ [ U 5 nUc [ SU - 5 eU$ )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:`~exceptions.LookupError` for an unknown label.
r zUnknown encoding label: %r)hasattrr LookupError)encoding_or_labelr s r
_get_encodingr# [ s@ ,// '(H69JJKKOr c $ \ rS rSrSrS rS rSrg)r m a/ Reresents a character encoding such as UTF-8,
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 Xl X l g N)r r )selfr r s r __init__Encoding.__init__| s $r c SU R - $ )Nz
)r )r( s r __repr__Encoding.__repr__ s **r )r r N)__name__
__module____qualname____firstlineno____doc__r) r, __static_attributes__ r r r r m s
%+r r zutf-8zutf-16lezutf-16bec [ U5 n[ U 5 u p0U=( d UnUR R X5 S U4$ )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 note have a BOM.
:param errors: Type of error handling. See :func:`codecs.register`.
:raises: :exc:`~exceptions.LookupError` for an unknown encoding label.
:return:
A ``(output, encoding)`` tuple of an Unicode string
and an :obj:`Encoding`.
r )r# _detect_bomr r )inputfallback_encodingerrorsbom_encodingr s r r r sI &&78%e,L00H%%e4Q7AAr c U R S5 ( a [ U SS 4$ U R S5 ( a [ U SS 4$ U R S5 ( a [ U SS 4$ SU 4$ )zBReturn (bom_encoding, input), with any BOM removed from the input.s Ns s )
startswith_UTF16LE_UTF16BEUTF8)r7 s r r6 r6 sq $$qr""$$qr""((U12Y;r strictc P [ U5 R R X5 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:`~exceptions.LookupError` for an unknown encoding label.
:return: A byte string.
r )r# r r
)r7 r r9 s r r
r
s% "--44UCAFFr c J [ X5 n[ X5 n[ U5 nXE4$ )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 note have a BOM.
:param errors: Type of error handling. See :func:`codecs.register`.
:raises: :exc:`~exceptions.LookupError` for an unknown encoding label.
:returns:
An ``(output, encoding)`` tuple.
:obj:`output` is an iterable of Unicode strings,
:obj:`encoding` is the :obj:`Encoding` that is being used.
)IncrementalDecoder_iter_decode_generatornext)r7 r8 r9 decoder generatorr s r iter_decoderJ s+ , !!2;G&u6IIHr c # r # UR n[ U 5 n U H5 nU" U5 nU( d M UR c eUR v Uv O2 U" SSS9nUR c eUR v U( a Uv gU H nU" U5 nU( d M Uv M U" SSS9nU( a Uv gg7f)ziReturn a generator that first yields the :obj:`Encoding`,
then yields output chukns as Unicode strings.
Nr Tfinal)r iterr )r7 rH r chunckoutputs r rF rF s
^^FKE6##///"""L
4(+++L6L Ct
$F
s *B7A'B7B7c B [ X5 R n[ X5 $ )u=
“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:`~exceptions.LookupError` for an unknown encoding label.
:returns: An iterable of byte strings.
)IncrementalEncoderr
_iter_encode_generator)r7 r r9 r
s r iter_encoderT s
1
8
8F!%00r c # n # U H nU" U5 nU( d M Uv M U" SSS9nU( a Uv g g 7f)N TrL r4 )r7 r
rO rP s r rS rS s= 6L Bd
#F
s 55c , \ rS rSrSrSS jrSS jrSrg) rE i u3
“Push”-based decoder.
:param fallback_encoding:
An :class:`Encoding` object or a label string.
The encoding to use if :obj:`input` does note have a BOM.
:param errors: Type of error handling. See :func:`codecs.register`.
:raises: :exc:`~exceptions.LookupError` for an unknown encoding label.
c Z [ U5 U l X l SU l S U l S U l g )Nr )r# _fallback_encoding_errors_buffer_decoderr )r( r8 r9 s r r) IncrementalDecoder.__init__ s, "/0A"B
r c F U R nUb U" X5 $ U R U- n[ U5 u pAUc) [ U5 S: a U( d Xl gU R nUR
R
U R 5 R nX0l X@l U" X5 $ )zDecode 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= rV )
r\ r[ r6 lenrY r incrementaldecoderrZ r r )r( r7 rM rH r s r r IncrementalDecoder.decode' s --5((u$%e,5zA~e$22%%88FMM
u$$r )r[ r\ rZ rY r Nreplace)F)r. r/ r0 r1 r2 r) r r3 r4 r r rE rE s
%r rE c &